Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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);