Re-label a matrix after using bwlabel.

조회 수: 8 (최근 30일)
Cristina
Cristina 2011년 11월 5일
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

채택된 답변

Image Analyst
Image Analyst 2011년 11월 5일
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
  댓글 수: 2
Cristina
Cristina 2011년 11월 5일
Thank you very much for your answers. But I have a problem with intlut . What second matriz (?) do I put in input? B=intlut(L,?)
My problem is that I have the matrix L I want to modify to L2
L= 1 1 0 0 y yo quiero que reorder in L2= 1 1 0 0
0 0 5 5 0 0 2 2
7 7 0 0 3 3 0 0
7 0 9 9 3 0 4 4
I want to do this because I have that extract features the different region that composed an image using regionprops. With bwlabel I have a lot of regions (more than 1000) and I have to simplify it to 20 features. This algorithm is to select exudates in fondus eyes images
Cristina
Cristina 2011년 11월 5일
Pardon
L= [1 1 0 0;0 0 5 5; 7 7 00; 7 0 9 9]
and I want
L2= [1 1 0 0; 0 0 2 2; 3 3 0 0;4 0 5 5]

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Recognition, Object Detection, and Semantic Segmentation에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by