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

Home » Public Forums » archive » Re: Converting 24 bit images to 8 bit images with a specific colour table
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: Converting 24 bit images to 8 bit images with a specific colour table [message #15257 is a reply to message #15251] Thu, 06 May 1999 00:00 Go to previous message
Liam Gumley is currently offline  Liam Gumley
Messages: 473
Registered: November 1994
Senior Member
Phil Aldis wrote:
> If I have a 24bit image and I want to convert it to an 8bit image
> which uses a particular table, so find nearest values.
> This is of particular use, when you're writing multiple gifs from 24
> bit images, because color_quan, will obviously not work, because the
> colour table has to be global.

If you want to create a GIF which contains 2 sub images derived from 24
bit true color images, you need to split the color table. Here's an
example:

PRO TEST_COLORS

;- Create a true color image

dim = 256
truedata = rebin( indgen( dim ), dim, dim )
data = intarr( dim, dim, 3 )
data[ *, *, 0 ] = truedata
data[ *, *, 1 ] = rotate( truedata, 1 )
data[ *, *, 2 ] = rotate( truedata, 2 )
bottom = 0B
ncolors = 256
image = bytscl( data, top=ncolors-1 ) + bottom

;- Convert to pseudo color with 128 colors
;- (bottom half of color table)

pseudo1 = color_quan( image, 3, r1, g1, b1, colors=128 )

;- Create another true color image

data[ *, *, 0 ] = truedata
data[ *, *, 1 ] = truedata
data[ *, *, 2 ] = truedata
image = bytscl( data, top=ncolors-1 ) + bottom

;- Convert to pseudo color with 128 colors
;- (top half of color table)

pseudo2 = color_quan( image, 3, r2, g2, b2, colors=128 ) + 128B

;- Save the images and color tables to GIF

write_gif, 'test_colors.gif', [pseudo1,pseudo2], [r1,r2], [g1,g2],
[b1,b2]

END

Cheers,
Liam.

---
Liam E. Gumley
Space Science and Engineering Center, UW-Madison
http://cimss.ssec.wisc.edu/~gumley
[Message index]
 
Read Message
Read Message
Previous Topic: Re: using !P.MULTI to oplot to different regions
Next Topic: Re: TVRD'ing under windows

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

Current Time: Sat Oct 11 12:18:43 PDT 2025

Total time taken to generate the page: 1.19993 seconds