Deleting objects from a binary image.

2 views (last 30 days)
Hello everyone. I have a binary image with different objects. In the image I want to remove 5th, 13th, and 20th objects. How can I remove it. Thnks.

Accepted Answer

Matthew Eicholtz
Matthew Eicholtz on 21 Mar 2016
L = bwlabel(bw); %where bw is your binary image
bw2 = bw; %copy of binary image
bw2(L==5) = 0; %deletes the 5th object
  2 Comments
Image Analyst
Image Analyst on 18 Apr 2019
Try my answer below. If that doesn't work, explain more in a new question, and attach your image. And say which blob you want to delete.

Sign in to comment.

More Answers (1)

Image Analyst
Image Analyst on 21 Mar 2016
You can use ismember() to extract the ones you want.
newBinaryImage = ismember(labeledImage, listOfBlobsToKeep) > 0;

Categories

Find more on Image Processing Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!