MATLAB Answers

How to extract second largest blob from image?

8 views (last 30 days)
Roark Menezes
Roark Menezes on 16 Jun 2020
Edited: KALYAN ACHARJYA on 18 Jun 2020
I have a binary image, and have extracted the largest and second largest images from a grayscale image (using bwareafilt). This gives me the image below:
How do i extract the image on the right (the second largest image)?
Using regionprops I have the Area, Centroid and Bounding Box for both blobs, but I am not sure how to use these values to extract the image on the right.
Thank you.

  4 Comments

Show 1 older comment
darova
darova on 16 Jun 2020
You can also use bwregionprops to find area of each blob
Roark Menezes
Roark Menezes on 18 Jun 2020
How would I remove the larger image knowing just the area?
KSSV
KSSV on 18 Jun 2020
Replace that region pixel values with black ones....

Sign in to comment.

Answers (1)

KALYAN ACHARJYA
KALYAN ACHARJYA on 18 Jun 2020
Edited: KALYAN ACHARJYA on 18 Jun 2020
large_1=bwareafilt(binary_image,1); %Extracting Large Blob
large_2=binary_image & ~large_1; % Logical Operation to get 2nd largest Blob
large_2=bwareafilt(large_2,1); % Remove extra small blobs
imshow(large_2);

  0 Comments

Sign in to comment.


Translated by