I am trying to run kmeans on a 3 channel color image, but every time I try to run the function it seems to crash with the following error:
OpenCV Error: Assertio
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.