BW cluster removal based on size (all parameters identified)
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Brian
am 9 Feb. 2016
Bearbeitet: Brian
am 10 Feb. 2016
Hello all,
I have a stack of 512 by 512 labeled binary images ("lab") from which I wish to remove clusters that are smaller than 8 pixel sizes in dimension. The cell array "idx" contains 33 matrices, specifying the indices of clusters that are larger than 8 pixel sizes in each of the 33 slices.
I encounter the error: "Error using ~= Matrix dimensions must agree." with the following code when I attempt my removal.
lab_large = zeros(512,512,33);
for i = 1:33
tmp = lab(:,:,i);
tmp2 = idx{i};
tmp(tmp~=tmp2(:))=0;
tmp(tmp~=0)=1;
lab_large(:,:,i) = tmp;
end
How should I tell MATLAB to maintain clusters identified in "idx" from "lab" and turn everything else into zeros?
I am aware that morphology operations may achieve a similar result with imclose, but I want to minimize altering the shapes of the surviving clusters.
Thank you so much!
0 Kommentare
Akzeptierte Antwort
Image Analyst
am 9 Feb. 2016
Bearbeitet: Image Analyst
am 9 Feb. 2016
You can use bwareaopen() to get rid of blobs less than a certain size. If you have a bunch of other criteria, like circularity or solidity or whatever, then you can get rid of blobs by passing the list of indexes into ismember(). See my Image Segmentation Tutorial at http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862
binaryImage = bwareaopen(binaryImage, 8); % Only 8 pixels or bigger survive.
or
labeledImage = bwlabel(binaryImage);
indexesToKeep = [2,4,13,33]; % Whatever....
newBinaryImage = ismember(labeledImage, indexesToKeep) > 0;
By the way, in image processing we don't call them "clusters". They're called "blobs" or "connected components".
1 Kommentar
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Image Processing Toolbox finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!