blobs filtering is not working

4 views (last 30 days)
mW
mW on 10 Feb 2015
Answered: mW on 10 Feb 2015
Using some examples in this forum , have put a script together. I like to keep some blobs and delete the rest. M is my gray scale image.
Part of my code is shown in below. When ran it, it left me one blob (one horz. line) in the image. It should leave me two blobs or two horizontal lines?. what is wrong? How to correct that?.
L = bwlabel(M,8);
mymeasures = regionprops(L, 'Area', 'BoundingBox');
bb = mymeasures.BoundingBox;
Keepers = (bb(4) <= 2 || bb(3) <= 2) %... etc .. more conditins to be added later;
keepersIndexes = find(Keepers );
keeperBlobsImage = ismember(L, keeperIndexes);
M(~keeperBlobsImage) = 0;
this prints me the two blobs (or two horz. lines) I want to see.
mymeasures = regionprops(L, 'Area', 'BoundingBox');
for n = 1 : length(mymeasures)
bb = mymeasures(k).BoundingBox;
if (bb(4) <= 2 || bb(3) <= 2)
fprintf('Blob #%d %d\n', n, mymeasures(n).Area);
end
end

Answers (1)

mW
mW on 10 Feb 2015
any ideas?

Categories

Find more on Images in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!