MATLAB: How to select the object with the largest area

image processingImage Processing ToolboxMATLABobjects

hi…i have i used bwconvhull to detect a certain part of the image, as you can see in the image that there are number of objects with certain centroids. what i want to do is to detect the object with the largest area(1st big one from the left) and neglect the others.
which method should i follow?
i will will be very thankful for your help.
following is the code(its very roughly written as i am still working on it. Sorry for any inconvenience in advance)
CH_objects = bwconvhull(c,'objects');
imshow(CH_objects);
title('Objects Convex Hull');
bwarea(CH_objects)
Ilabel =bwlabel(CH_objects,8);
stat = regionprops(Ilabel,'centroid');
imshow(CH_objects); hold on;
for x = 1: numel(stat)
plot(stat(x).Centroid(1),stat(x).Centroid(2),'ro');
end

Best Answer

I have a demo for exactly that purpose. Please click the blue link (ExtractBiggestBlob.m) below copy the program to MATLAB and run it.