Kamal Sharma Kamal Sharma - 1 year ago 185
iOS Question

Unsupported format or combination of formats (Only 8-bit, 3-channel input images are supported) in cvWatershed

Hi I am new to image segmentation, i am trying the given code to get foreground objects, but i got error like "Unsupported format or combination of formats (Only 8-bit, 3-channel input images are supported) in cvWatershed"

cv::Mat img0 = [img toMat];
cv::Mat img1;
cv::cvtColor(img0, img0, CV_RGB2GRAY);
cv::threshold(img0, img0, 100, 255, cv::THRESH_BINARY);

cv::Mat fg;

cv::Mat bg;

cv::Mat markers(img0.size(),CV_8U,cv::Scalar(0));
markers= fg+bg;

// cv::namedWindow("Markers");
// cv::imshow("Markers", markers);

WatershedSegmenter segmenter;
cv::Mat result1 = segmenter.process(img0);

// cv::Mat result1;

UIImage * result = [UIImage imageWithMat:result1 andImageOrientation:[img imageOrientation]];
return result;

And i try by debugging and got error in line

cv::Mat result1 = segmenter.process(img0);

Thanks in advance

Answer Source

I again analyzed my code and solved the problem. Convert the image to ilpImage and then change it to a 8 bit and 3 channel image using code

WatershedSegmenter segmenter;
markers=cvCreateImage(cvGetSize(my_iplImage), IPL_DEPTH_8U, 3);
cv::Mat result1 = segmenter.process(markers);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download