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
|