MATLAB: How to get the two biggest objects/blobs from a binary image

image analysisimage processingImage Processing Toolboximage segmentation

I have a binary image having 3 or more blobs…I need to display an image which displays only the two biggest(biggest in terms of area) blobs while rejectingrejecting others….how can I do this?

Best Answer

Try bwareafilt():
BW2 = bwareafilt(BW, 2, 'Largest');