Re: display an image from RGB [message #46777 is a reply to message #46773] |
Fri, 16 December 2005 16:50   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Chi-Kuei Wang writes:
> I am an ENVI user. In the context of multi- and hyper-spectral data,
> I always wonder how does ENVI display an image using 3 different
> wavelengths representing red, green, and blue colors.
>
> I am trying to reproduce this function using my own code in IDL (as
> an exercise to understand IDL color table). But I couldn't find a way to
> do it. I suspose I need to know the relationship between (red, green,
> blue) triplets and IDL color table. Say,
> zcolors = red * var_red + green * var_red + blue * var_blue
> Once I know this relationship, I can use it to generate a new image,
> whose pixel values will correspond to IDL color table.
>
> Is this correct? If so, can anyone provide me the relationship for
> color triplets and IDL color table.
I don't have any idea how ENVI does this, but I think you
have a couple of choices. You can take your three images
(call them R, G, and B) and create a flat 2D gray-scale image
that you can display with any color table you like. A typical
formula for creating a gray-scale image that preserves color
"sensitivity" is this:
IDL> Y = 0.3*R + 0.59*G + 0.11*B
IDL> LoadCT, 22
IDL> Device, Decomposed=0
IDL> TV, BytScl(y)
Or, you can create what is called a "pseudocolor"
image by using the three (byte scaled) images directly
as the red, green, and blue channel of a 24-bit image:
IDL> image24 = [ [[Bytscl(R)]], [[BytScl(G]], [[Bytscl(B)]] ]
IDL> Device, Decomposed=1
IDL> TV, image24, True=3
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|