How to selectively apply colors using label2rgb to a watershed segmentation

4 次查看(过去 30 天)
Hi everyone,
I have a question regarding watershed and using bwlabel. From what it shows at the example (Please check the link below), it seems that for visualization, the label2rgb is used in a shuffle configuration.
The question I have is, if anyone has had a situation where they have had to apply color for a range of bins pixel values. Essentially, I'm trying to selectively apply colors to regions identified by the watershed segmentation (ranges with the same pixel intensity), as opposed to having them applied shuffled.
Any help would be much appreciated and happy Festivus!

回答(2 个)

Image Analyst
Image Analyst 2011-12-24
You won't find regions that have the same pixel intensity in the original image by looking at the labeled image only. Just look how it assigns labels - upper left of the image, going down columns, working its way over to the lower right of the image. This scheme has nothing whatsoever to do with what the intensities in the original image were. It has only to do with the positions of the binary blobs in the binary image that got labeled. That said, you can call regionprops and figure out what binary blob has what original intensity and then, knowing that, you can create a custom colormap to apply to the labeled image instead of the default colormap. If you want to do that, then post your image somewhere (like tinypic.com) along with your code that makes the binary image, and what your scheme is for applying what colors to what intensities, and we'll see what we can do.

Veena Chatti
Veena Chatti 2020-10-6
I have a similar situation. I'm trying to use label2rgb to label the same specific objects tracked in multiple images with the same color.
How can I use imshow with a specific custom colormap linking labels to RGB colors? Here is my code linking the labels to the RGB values to create the colormap.
colors = NaN(257,4);
for i = 1:max(LL(:)) % LL is my labelmatrix
[r,c] = find(LL==i,1)
colors(i,1) = i;
colors(i,2) = RGB(r,c,1) % RGB contains the colors generated by 'turbo' and 'shuffle'
colors(i,3) = RGB(r,c,2)
colors(i,4) = RGB(r,c,3)
end

类别

Help CenterFile Exchange 中查找有关 Modify Image Colors 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by