MATLAB: Remove wanted portions in binary image

binary image

i wanted to extract only the white portion from the image
i get more than one region… i should get only one region…. please do reply…..

Best Answer

There is a function for removing blobs smaller than a specified size. It's called bwareaopen():
cleanedBinaryImage = bwareaopen(binaryImage, 40); % Remove blobs smaller than 40.
Alternatively you can use a function I wrote to keep, or eliminate, the N largest, or smallest (whichever you specify), blobs. See attached demo in blue text below. This is more general and flexible than bwareaopen, but more complicated.