counting holes in an image
22 ビュー (過去 30 日間)
古いコメントを表示
writing an algorithm that will count the number of holes in the image that do not touch the border
採用された回答
Image Analyst
2020 年 3 月 27 日
Threshold then call imclearborder() and bwlabel(). Assuming you have dark holes on a bright background:
% Binarize:
binaryImage = grayImage < someValue;
% Remove those touching border
binaryImage = imclearborder(binaryImage);
% Count holes:
[~, numHoles] = bwlabel(binaryImage);
0 件のコメント
その他の回答 (1 件)
Walter Roberson
2020 年 3 月 26 日
Invert the image so the holes become solid and the solid gets removed. Remove from that all solid touching the border -- those correspond to holes that were touching the border in the original. Now count the number of solid objects remaining, and that will be the number of holes in the original.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Convert Image Type についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!