How to selectively apply colors using label2rgb to a watershed segmentation

5 visualizzazioni (ultimi 30 giorni)
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!
  1 Commento
Sean de Wolski
Sean de Wolski il 23 Dic 2011
So what you want is to be able to select certain regions in the label image and give them the same color?

Accedi per commentare.

Risposte (2)

Image Analyst
Image Analyst il 24 Dic 2011
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 il 6 Ott 2020
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

Categorie

Scopri di più su Modify Image Colors in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by