How can I determine the number of closed regions in an edge image?
조회 수: 8 (최근 30일)
이전 댓글 표시
Given an edge image as shown in the figure, how can I find the number of closed regions (4 in the figure) in it?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/149224/image.jpeg)
댓글 수: 0
채택된 답변
Image Analyst
2015년 4월 19일
Trivial - just 3, or even 2, lines of code. Just try this:
% Invert the image to form black curves on a white background
binaryImage = ~binaryImage;
% Get rid of huge background that touches the border
binaryImage = imclearborder(binaryImage);
% Count the objects remaining
[~, numberOfClosedRegions] = bwlabel(binaryImage);
댓글 수: 4
Image Analyst
2015년 4월 20일
The small blob at the bottom was SUPPOSED to be eliminated because it is not a closed curve.
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!