OpenCV running kmeans algorithm on an image

旧街凉风 提交于 2019-12-03 15:10:32

The error says all: Assertion failed (data.dims <= 2 && type == CV_32F && K > 0)

These are very simple rules to understand, the function will work only if:

  • mImage.depth() is CV_32F

  • if mImage.dims is <= 2

  • and if K > 0. In this case, you define K as 6.

From what you stated on the question, it seems that:

IplImage* iplImage = cvLoadImage("C:/TestImages/rainbox_box.jpg");` 

is loading the image as IPL_DEPTH_8U by default and not IPL_DEPTH_32F. This means that mImage is also IPL_DEPTH_8U, which is why your code is not working.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!