comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Colored image
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Colored image [message #41060 is a reply to message #41059] Thu, 23 September 2004 08:45 Go to previous messageGo to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Julio writes:

> I'm using the following code to generate a JPEG of an image. The
> figure is generated in black and white format. Does anybody know how
> can I generate a colored image?? (e.g. using a color table).
>
> Thanks!
>
> image=[(ndvi)]
> ndvi_jpg='ndvi.jpg'
> ndvi = HIST_EQUAL(ndvi, percent=2)
> WRITE_JPEG, ndvi_jpg, ndvi, QUALITY=100, order=1

If you are talking about talking a 2D 8-bit image,
and saving it as a 24-bit color JPEG image, you might
do something like this:

Loadct, 5 ; Load a color table
TVLCT, r, g, b, /Get ; Get the color table vectors
s = Size(image2d, /Dimensions) ; Size of 2D image
image24 = BytArr(3, s[0], s[1]) ; Create 24-bit image.
image24[0,*,*] = r[image2d] ; Create color lookup planes.
image24[1,*,*] = g[image2d]
image24[2,*,*] = b[image2d]
Write_JPEG, 'myimage.jpg, image24, True=1, Quality=100

If you want the order to be reversed, I wouldn't use the ORDER
keyword, which I find completely unreliable, rather, I would
reverse the Y data:

Write_JPEG, 'myimage.jpg, Reverse(image24,3), True=1, Quality=100

Cheers,

David



--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http:/www.dfanning.com/
Phone: 970-221-0438, IDL Book Orders: 1-888-461-0155
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: IDL removes dimensions of size 1 automatically
Next Topic: widget IDs ever zero?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 11:16:35 PDT 2025

Total time taken to generate the page: 0.56131 seconds