MATLAB: Using bwareafilt to get area in a range

image processing

i used
bw2 = bwareafilt(bw, [40 50]);
to get regions having area in the range 40-50.
but more than one region is coming. How can i get only one region, either the first region or last region in that particular range

Best Answer

bw3 = bwareafilt(bw2, 1);
Related Question