[Insight-users] how to map grayscale to color

Pete Carswell pete at osc.edu
Fri Aug 18 12:45:41 EDT 2006


kdsfinger at gmail.com wrote:

> hi, all
> After finishing segmentation, I'd like to label each region in color
> and display in the widget. Is there any feasible way to map the
> grayscale (the label on the original segmented image) to color rgb?
> Thank you.
> Basically, I am looking for a user defined filter, taking the input
> image, do some calculation for each pixel, and produce an output
> image.
> zl2k
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
>
One way to consider the problem is to use the greyscale value as a 
single scalar value mapped to hue, using hsv for color. Attached is some 
python code which takes the hue value and returns an rgb triple. This 
uses the color wheel representation of hue, 0 to 360 degrees. Start by 
mapping your greyscale, normalized to 0.0 to 1.0, to 0.0 to 240.0. This 
will give you the red to blue, through green, continuous color map.

pete

-------------- next part --------------
A non-text attachment was scrubbed...
Name: HSV2RGB.py
Type: application/x-python
Size: 1512 bytes
Desc: not available
Url : http://public.kitware.com/pipermail/insight-users/attachments/20060818/ebe8b5a6/HSV2RGB.bin


More information about the Insight-users mailing list