Re-label a matrix after using bwlabel.
1 view (last 30 days)
Show older comments
Partners I have a question. I'm working on the division of a matrix by means connected regions using labels through bwlabel, but it turns out a high number of connected regions. I have tried to simplify calculating the area of the labels and if areas are lower than the a value they are eliminated.
[L, NUM] = bwlabel (M);
regionrops s = (L, 'Area');
y = [s.Area];
ind = find (y <10)
for j = 1:1959
for i = 1:199
for k = 1: length (ind)
if (L (i, j) == 0 | | L (i, j) == ind (k))
L (i, j) = 0
end
end
end
But when I delete the labels that meet the above condition. The matrix L is disordered. How can I order it?
if the pixels that do not meet the condition I put to one and next step I apply bwlabel, only a label has been removed. Is there any function that reorders labels in the matrix L?
Thanks and best regards
0 Comments
Accepted Answer
Image Analyst
on 5 Nov 2011
Yes, it's called intlut(). But why do you want to reorder the labels? Anyway, back to your first question, there are other ways of getting rid of blobs less than 10 pixels in size including bwareaopen() and ismember(). See my BlobsDemo in the File Exchange : http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!