Problem with intlut to reorder label

1 view (last 30 days)
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;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]
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

Accepted Answer

Image Analyst
Image Analyst on 5 Nov 2011
You can do this:
L= uint8([1 1 0 0;0 0 5 5; 7 7 0 0; 7 0 9 9])
% Want L2= [1 1 0 0; 0 0 2 2; 3 3 0 0;4 0 5 5]
lut = uint8([0 1 0 0 0 2 0 3 0 5]);
lut(end+1:256) = 0;
L2 = intlut(L, lut)
but that doesn't make sense for two reasons. One, your blob originally labeled 7 you want to somehow split into two blobs: one blob with 2 pixels labeled 3 and another blob of a single pixels labeled 4. Or look at it this way: you said you want to reduce the number of blobs (labels) but in your example you start with 4 labels (1,5,7,9) and end up with 5 labels (1,2,3,4,5). That is not reducing.
And two, reordering the labels won't reduce the number of blobs unless you just outright set some to zero. Like I said in your related post today where you said you want to reduce the number of blobs based on area, if you want to filter out small blobs, you can use bwareaopen or ismember (as demonstrated in my BlobsDemo on the File Exchange). OR you can try to prevent getting so many small blobs in your binary image in the first place. This could be done by changing the threshold, or blurring the image before a watershed is done, or changing your kernel, or whatever - it depends on what you do before you obtain the binary image. What you do depends on what you're looking for.
andrei's code gives you exactly what you asked for but I'm telling you that (what you asked for, not his code) is nonsense because what you asked for literally is not what you want. To reorder, yes, you can use intlut, but you don't want to reorder, you want to reduce the number of blobs in a sensible way, such as by size filtering.
  5 Comments
Cristina
Cristina on 5 Nov 2011
And if I want to eliminate area is greater than 500. Is there other function similar to bwareaopen?
Image Analyst
Image Analyst on 6 Nov 2011
If you look at what bwareaopen does, it labels, calls regionprops, and does size filtering. Exactly what my BlobsDemo does. So that's a similar way but, like I said, it's what bwareaopen does internally. I'm not sure why you'd need any other way. Perhaps you can explain why?

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!