How to extract second largest blob from image?

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 件のコメント

Roark Menezes
Roark Menezes 2020 年 6 月 16 日
Sorry I solved it, dont know if i should delete or not but I did the following, BW is the binary image:
bwareafilt(BW, 2)-bwareafilt(BW, 1);
darova
darova 2020 年 6 月 16 日
You can also use bwregionprops to find area of each blob
Roark Menezes
Roark Menezes 2020 年 6 月 18 日
How would I remove the larger image knowing just the area?
KSSV
KSSV 2020 年 6 月 18 日
Replace that region pixel values with black ones....

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

回答 (1 件)

KALYAN ACHARJYA
KALYAN ACHARJYA 2020 年 6 月 18 日
編集済み: KALYAN ACHARJYA 2020 年 6 月 18 日

1 投票

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);

質問済み:

2020 年 6 月 16 日

編集済み:

2020 年 6 月 18 日

Community Treasure Hunt

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

Start Hunting!

Translated by