Watershed Error OpenCV Error: Assertion failed (src.type() == CV_8UC3 && dst.type() == CV_32SC1)
I am trying to use watershed on a segmented image I made the watershed data and watershedmarker the way it required and keeps getting this error.Which part has gone wrong?
OpenCV Error: Assertion failed (src.type() == CV_8UC3 && dst.type() == CV_32SC1) in watershed, file /home/WXH/Desktop/opencv-3.2.0/modules/imgproc/src/segmentation.cpp, line 161
the code is here
Canny(imageCluster,edges,100,150,3, true);
edges.convertTo(watershedData,CV_8UC3);
watershedMarker=Mat(imageWork.rows,imageWork.cols,CV_32SC1,Scalar::all(0));
watershedMarker.row(0)=255;
watershedMarker.row(imageWork.rows-1)=255;
watershedMarker.col(0)=255;
watershedMarker.col(imageWork.cols-1)=255;
printf("WatershedData Type is %d \n",watershedData.type());
printf("watershedMarker Typed is %d\n",watershedMarker.type());
watershed(watershedData,watershedMarker);
watershed works on color images, so, what's the Canny doing there ?
the image is already segmented in grayscale and I want the watershed to flood all surronding region in white.canny will just highlight the boarder the turn all segments into black.
wait, if the input to Canny is 1channel, the output will be too.
convertTo() only changes the depth of your image, not the number of channels.
cvtColor(.... GRAY2BGR)
watershed prabably not a good way to do it,but still dont understand why the data type missmatch
ok I got it.The way convertTo() accepts a CV_8UC3 parameter got me think it convert channels too.Now I know it doent.Thanks
common pitfall