there are several ways to accomplish that, for example histogram the content of the nonzero elements:
L=bwlabel(I);
[a val]=hist(L(:),1:max(L(:)))
val(a==max(a))
will yield the value that is most occuring
another way is to use tabulate :
a=tabulate(L(:))
a(a(:,2)==max(a(2:end,2)),1)
tabulate creates a frequency table of data in vector L(:). The information is arranged as follows:
1st column — The unique values of L
2nd column — The number of instances of each value
3rd column — The percentage of each value
etc...