LEADTOOLS Support
Imaging
Imaging SDK Examples
How To: Convert Grayscale to Pseudo-color Images
#1
Posted
:
Thursday, October 27, 2016 7:28:44 AM(UTC)
Groups: Registered, Tech Support
Posts: 14
The attached sample C# project shows how RasterImage.GetPalette and RasterImage.SetPalette can be used with 8-bit ordered grayscale images to convert the grayscale image to an image with pseudocolors.
The output image is derived from the grayscale image by mapping each intensity value to a color that ranges from pure blue for intensity zero (black) to pure green for intensity 255 (white).
Here the RasterImage.GetPalette() method from our toolkit is used to obtain the ordered grayscale palette of an 8-bit image. Then each element in the resulting ascending array is mapped to a desired color.
This code example implements a two-color fade with blue at the cold end and green at the hot end though you can get a more complex gradient by defining different color gradients for subsets of the palette, for example:
for (int i = 0; i < ourPalette.Length/3; ++i): Blue to Green
for (int i = ourPalette.Length/3; i < 2*ourPalette.Length/3; ++i): Green to Yellow
for (int i = 2*ourPalette.Length/3; i < ourPalette.Length; ++i): Yellow to Red
Finally, note that if you are using extended grayscale images (10-16) which are typical of medical images, then our medical SDK has the GetLookupTable and SetLookupTable Methods which can be used as above.
Hussam Barouqa
Developer Support Engineer
LEAD Technologies, Inc.
LEADTOOLS Support
Imaging
Imaging SDK Examples
How To: Convert Grayscale to Pseudo-color Images
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.