How to manually remove certain blobs from image?

7 vues (au cours des 30 derniers jours)
Nimos Sereth
Nimos Sereth le 21 Jan 2019
Commenté : Image Analyst le 3 Fév 2019
Hello, I get the following image or very similar images back from my Image Segmentation. I have all the blobs numbered and labled. Now I want to add the possibility to delete every blob I want by entering its number in a text field. The criteria to keep or delete a blob are not fixed so as far as I am concerned no region function will work.

Réponses (1)

Image Analyst
Image Analyst le 21 Jan 2019
You can use bwselect() or ismember()
labelsPresent = unique(labeledImage(:));
labelsToKeep = setdiff(labeledPresent, labelIndexToDelete);
binaryImage = ismember(labeledImage, labelsToKeep);
labeledImage = bwlabel(binaryImage);
  2 commentaires
Nimos Sereth
Nimos Sereth le 22 Jan 2019
Great idea, works well.
On another note is there a "simple" way to choose the blobs to be deleted by clicking them?
Image Analyst
Image Analyst le 3 Fév 2019
You can use ginput(). Something like
uiwait(helpdlg('Click on the blob to delete'));
[column, row] = ginput(1);
pixelValue = labeledImage(row, column); % Get the label of the blob they clicked on.
mask = ismember(labeledImage, pixelValue); % Extract this one blob.
% Remove it from the labeled image.
labeledImage(mask) = 0;

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by