Re: R,G,B image [message #10513] |
Tue, 09 December 1997 00:00 |
Erard
Messages: 11 Registered: November 1997
|
Junior Member |
|
|
In article <348D4320.18AF@gmv.es>, "Luis M. Gonzalez" <lmgc@gmv.es> wrote:
> Hello,
>
> I have a bi-dimensional image as a three R,G,B vectors.
> Is it possible to display it directly within IDL? Or should we
> convert each RGB triple into an index to the color table?.
>
There are two solutions, depending on your monitor capabilities:
1- You have a 24 bits monitor (meaning: either you are rich and have a
24-bits X terminal, or you are smart and have a PC/Mac with X emulation or
native IDL). All you have to do is:
TVLCT, indgen(256), ingen(256), indgen(256) ; loads a linear RGB color table
TV, ima24, TRUE=3 ���; Plots the 24 bits image
The value for TRUE is 1, 2, or 3 depending on how the 3 planes are
interleaved in your image (respectively band interleaved by pixel, band
interleaved by line, or band sequential).
If your image comes from a graphic file, it is usually stored with the
color table (see eg, Read_pict).
If you have 3 images, one for each color (for instance if you want to plot
a composite from astronomical images in 3 filters), type:
TV, imageR, Channel= 1 ; Red channel
TV, imageV, Channel= 2 ; G
TV, imageB, Channel= 3 ; B
Channel 0 addresses all 3 planes simultaneously.
2- You only have an 8-bit machine. Just pretend it's 24-bits and compute a
color table adapted to your image with COLOR_QUANT. Only the most frequent
colors are used, so check the quality of the result.
Example : color composite from 3 monochrome images.
x=read_fits('SaturneI.fits',h) ; Read the 3 images, correct position assumed
y=read_fits('SaturneV.fits',h)
z=read_fits('SaturneB.fits',h)
col=!D.N_colors
x=bytscl(x,TOP=col) ;Higher brightness is assumed white
y=bytscl(y,TOP=col) ; (same intensity in each filter)
z=bytscl(z,TOP=col)
trichro=color_quan(z,x,y,r,g,b) ;compute image and table
tv, trichro ; plot the image
tvlct, r, g, b ; load the table
You can use the keyword Cube to reduce the number of colors (from 2 to 6,
cubic root of the number of colors used). The resulting table is lower
quality, but can be used to plot several images simultaneously.
--
St�phane Erard
Institut d'Astrophysique Spatiale
Orsay, France
|
|
|
Re: R,G,B image [message #10514 is a reply to message #10513] |
Tue, 09 December 1997 00:00  |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
Luis M. Gonzalez (lmgc@gmv.es) writes:
> I have a bi-dimensional image as a three R,G,B vectors.
> Is it possible to display it directly within IDL? Or should we
> convert each RGB triple into an index to the color table?.
Here is what I would do. Suppose your vectors (r, g, b) describe
a 400 by 300 image.
; Create a 24-bit pixel interleaved image.
image24 = BytArr(3, 400, 300)
image24[0,*,*] = Reform(r, 400, 300)
image24[1,*,*] = Reform(g, 400, 300)
image24[2,*,*] = Reform(b, 400, 300)
; Display the 24-bit image directly in IDL.
TV, image24, True=1
The last command would tie your image to the color table
indices. That is, the image values would be run through
the color tables when they are displayed to select the
display color. You may prefer to see the "true" color.
If you are on an 8-bit system (I presume you are from your
color table question), then you may want to do this:
trueColorImage = Color_Quan(image24, 1, red, green, blue)
TVLCT, red, green, blue
TV, trueColorImage
Cheers,
David
-----------------------------------------------------------
David Fanning, Ph.D.
Fanning Software Consulting
E-Mail: davidf@dfanning.com
Phone: 970-221-0438
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|