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


hi new image segmentation, trying given code foreground objects, got error "unsupported format or combination of formats (only 8-bit, 3-channel input images 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::erode(img0,fg,cv::mat(),cv::point(-1,-1),6);  cv::mat bg; cv::dilate(img0,bg,cv::mat(),cv::point(-1,-1),6); cv::threshold(bg,bg,1,128,cv::thresh_binary_inv);  cv::mat markers(img0.size(),cv_8u,cv::scalar(0)); markers= fg+bg; 

// cv::namedwindow("markers"); // cv::imshow("markers", markers);

watershedsegmenter segmenter; segmenter.setmarkers(markers); cv::mat result1 = segmenter.process(img0); 

// cv::mat result1; result1.convertto(result1,cv_8u);

uiimage * result = [uiimage imagewithmat:result1 andimageorientation:[img imageorientation]]; return result; 

and try debugging , got error in line

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

thanks in advance

i again analyzed code , solved problem. convert image ilpimage , change 8 bit , 3 channel image using code

watershedsegmenter segmenter; segmenter.setmarkers(markers); markers=cvcreateimage(cvgetsize(my_iplimage), ipl_depth_8u, 3); cv::mat result1 = segmenter.process(markers); 

Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -