How to extract the largest area?

7 vues (au cours des 30 derniers jours)
ZWY
ZWY le 30 Juin 2022
Commenté : ZWY le 2 Juil 2022
Hi, I have a grayscale image as shown. How can I extract out the largest area? Thank you.

Réponse acceptée

Image Analyst
Image Analyst le 30 Juin 2022
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 commentaire
ZWY
ZWY le 2 Juil 2022
Yes, there are separated regions.
Thank you very much.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Image Processing Toolbox dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by