How to Close an Open Contour
6 ビュー (過去 30 日間)
古いコメントを表示
Ashkan Javadzadegan
2015 年 4 月 18 日
コメント済み: Image Analyst
2020 年 6 月 25 日
Dear all, Attached image consists of two open contours. I would like to close these two contours. Please let me know if this is doable in Matlab.
Thanks Ashkan

0 件のコメント
採用された回答
Image Analyst
2015 年 4 月 18 日
Skeletonize the blob with bwmorph(), then use bwmorph() again to find the endpoints. Use regionprops() to get coordinates of the skeleton so you know which endpoints belong to the same blob. Then use imline() to draw a line connecting the endpoints of each blob. Demo of imline used to burn a line into an image is attached. Please try these steps yourself first and come back with your code if you can't do it. Again, the rough steps are
bwmorph(binaryImage, 'skel', inf);
bwmorph(binaryImage, 'endpoints');
[labeledImage, numBlobs] = bwlabel(binaryImage);
measurements = regionprops(labeledImage, 'PixelList');
for k = 1 : numBlobs
% find endpoints of this blob, then
imline();
% etc
end
Finish it up (it shouldn't be too hard) and let me know of any problems.
5 件のコメント
Image Analyst
2019 年 8 月 9 日
Didn't I outline the solution : use imline() to join the endpoints of each skeleton. Can't you find the endpoints of each blob? Hint: use ismember() or a for loop to find out which endpoints belong to regionprops(k).PixelList().
その他の回答 (1 件)
Daniel Thomas
2020 年 6 月 25 日
Don't "burn lines" with imline. Use insertShape instead to draw a line on an image. Additional trouble with insertShape is that it always produces RGB instead of grayscale. So you need to convert it to grayscale. Other than that, it works a lot better than "burning the lines."
参考
カテゴリ
Help Center および File Exchange で Image Segmentation and Analysis についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!