2 added 2 characters in body edited Dec 5 '18 at 12:41 Tolga Birdal 4,69311 gold badge99 silver badges3232 bronze badges Referring to MATLAB, the basic steps are Determine the connected components: CC = bwconncomp(BW, conn); Compute the area of each component: S = regionprops(CC, 'Area'); Remove small objects: L = labelmatrix(CC); BW2 = ismember(L, find([S.Area] >= P)); At the last step, after obtaining L$$L$$, you might as well retain the component with the largest area if you are interested in a single component. This would make the algorithm invariant to the size of the noise. Referring to MATLAB, the basic steps are Determine the connected components: CC = bwconncomp(BW, conn); Compute the area of each component: S = regionprops(CC, 'Area'); Remove small objects: L = labelmatrix(CC); BW2 = ismember(L, find([S.Area] >= P)); At the last step, after obtaining L, you might as well retain the component with the largest area if you are interested in a single component. This would make the algorithm invariant to the size of the noise. Referring to MATLAB, the basic steps are Determine the connected components: CC = bwconncomp(BW, conn); Compute the area of each component: S = regionprops(CC, 'Area'); Remove small objects: L = labelmatrix(CC); BW2 = ismember(L, find([S.Area] >= P)); At the last step, after obtaining $$L$$, you might as well retain the component with the largest area if you are interested in a single component. This would make the algorithm invariant to the size of the noise. 1 answered Mar 25 '14 at 15:41 Tolga Birdal 4,69311 gold badge99 silver badges3232 bronze badges Referring to MATLAB, the basic steps are Determine the connected components: CC = bwconncomp(BW, conn); Compute the area of each component: S = regionprops(CC, 'Area'); Remove small objects: L = labelmatrix(CC); BW2 = ismember(L, find([S.Area] >= P)); At the last step, after obtaining L, you might as well retain the component with the largest area if you are interested in a single component. This would make the algorithm invariant to the size of the noise.