MATLAB: How to find the size of the biggest component

Image Processing Toolboxsize of the biggest component

I am trying to find the size of the biggest cluster and the dimension of it. Is the code that I am using gives the size of the biggest cluster. On the other words, is the size of the biggest cluster,the number of pixels in the cluster? Then how to find the dimension of the biggest cluster?
A=rand(100);
A=A<.5
connected_comp=bwconncomp(A,4);
cluster_size=cellfun(@numel,connected_comp.PixelIdxList)
[biggest,idx] = max(numPixels)

Best Answer

Measuring the number of pixels in the cluster is a valid measure of size that is correct for a number of purposes.
Sometimes what is desired would correspond to using imfill('holes') and then counting the pixels: this would be the area "inside" the boundaries.
Sometimes you want to take the convex hull and find its area; one way of finding this is regionprops('convexarea')
Sometimes you want the area of the bounding box; regionprops('area')
With regards to "dimension", sometimes you mean the length or width of the bounding box; regionprops('boundingbox') and extract the appropriate information.
Sometimes you mean the length of the major axes when approximating as an ellipse; regionprops('majoraxeslength')
Sometimes you want to find the two pixels that are furthest apart in Euclidean space and call that distance the "dimension"