How can I determine the number of closed regions in an edge image?

11 ビュー (過去 30 日間)
coolguynp
coolguynp 2015 年 4 月 19 日
コメント済み: Image Analyst 2015 年 4 月 20 日
Given an edge image as shown in the figure, how can I find the number of closed regions (4 in the figure) in it?

採用された回答

Image Analyst
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 件のコメント
coolguynp
coolguynp 2015 年 4 月 20 日
Thank you for the detailed answer. The small blob at the bottom was missing because of small opening. bwmorph with 'bridge' after obtaining the binary image solved that as well.
binaryImage = bwmorph(binaryImage, 'bridge');
Image Analyst
Image Analyst 2015 年 4 月 20 日
The small blob at the bottom was SUPPOSED to be eliminated because it is not a closed curve.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeComputer Vision with Simulink についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by