problem filling a contour
1 回表示 (過去 30 日間)
古いコメントを表示
Hello,
I have a problem. I have an image (a masc) which has a hole. I detect de contour of the masc and I use "fill" to fill with a colour. My problem is that the hole is also painted and I don't want that.
Is there any option to avoid filling the holes? Thanks
Silvia
0 件のコメント
回答 (1 件)
Image Analyst
2013 年 11 月 20 日
If you have the coordinates of the contour, you can use poly2mask() to create binary images. For nested contours, you might have to call it twice, then subtract the binary image from the inner "hole" from the larger outer mask to make the hole zero and the torus 1.
2 件のコメント
Image Analyst
2013 年 11 月 21 日
You need to get the hole iteself. So invert the mask of the donut, call imclearborder() and then assign:
holeMask = imclearborder(!binaryMask);
grayImage(holeMask) = whateverIntensityYouWant;
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!