How to extract the largest area?

6 ビュー (過去 30 日間)
ZWY
ZWY 2022 年 6 月 30 日
コメント済み: ZWY 2022 年 7 月 2 日
Hi, I have a grayscale image as shown. How can I extract out the largest area? Thank you.

採用された回答

Image Analyst
Image Analyst 2022 年 6 月 30 日
It looks like there is a black path separating the different regions. I think you can just binarize the image and use bwareafilt
% Binarize the image
binaryImage = yourImage > 0;
% Make sure it's 2-D, not 3-D (which would be the case if yourImage was RGB).
if size(binaryImage, 3)) == 3
binaryImage = binaryImage(:, :, 1);
end
binaryImage = bwareafilt(binaryImage, 1); % Take largest 8-connected region.
If you get multiple regions (because regions touch on a diagonal), then try using 4-connected:
binaryImage = bwareafilt(binaryImage, 1, 4); % Take largest 4-connected region.
  1 件のコメント
ZWY
ZWY 2022 年 7 月 2 日
Yes, there are separated regions.
Thank you very much.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImage Segmentation and Analysis についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by