MATLAB Answers


remove wanted portions in binary image

Asked by Elysi Cochin on 30 Nov 2013
Latest activity Commented on by Elysi Cochin on 2 Dec 2013

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.....



No products are associated with this question.

2 Answers

Answer by Image Analyst
on 30 Nov 2013
 Accepted 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.

  1 Comment

thank you so much sir for the reply... it helped me a lot.... thank u sir....

Answer by Jeremy Wurbs on 30 Nov 2013

If you wish to remove small regions from the binary image itself, you could start by looking at morphological operations ( help bwmorph), specifically erode and dilate.

You could also just remove the small regions from your bounding box list, or just take the largest one. I.e. only take bounding boxes where boundingBox(3)*boundingBox(4) >= minSize.

  1 Comment

thank u all for the answers....

Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!