Re: How to load a customized color table? [message #64627 is a reply to message #64626] |
Mon, 12 January 2009 10:51   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Spon writes:
> On Jan 12, 9:26=A0am, RussellGrew <russell.g...@gmail.com> wrote:
>> g[*] =3D 0.
>>
>> may be more appropriate.
>
> Also completely unnecessary, as IDL will set all elements of a newly
> created array to 0 by default unless you use the /NoZero keyword. I'm
> also not sure what that common block is doing there, or the double
> precision numbers that get turned into bytes anyway.
>
> This is how I'd write such a procedure:
>
> ***
>
> ; OldRGB is an output variable that
> ; returns the previous colour table values
> PRO LOADREDBLUE, OldRGB
> ; Store current colour table
> TVLCT, OldRGB, /GET
> ; Generate new colour table values
> R =3D [2B*REVERSE(BINDGEN(128)), BYTARR(128)]
> G =3D BYTARR(256)
> B =3D [BYTARR(128), 2B*BINDGEN(128)]
> ; And load them
> TVLCT, R, G, B
> PRINT, 'Loading table: Red-Black-Blue'
> RETURN
> END
>
> ***
>
> So if you cared about turning your old colour table back on after your
> call, you could use the procedure like in this example:
> IDL> Device, Decomposed =3D 0
> IDL> Image =3D Dist(256)
> IDL> LOADREDBLUE, Previous ; load your custom table. The 'Previous'
> variable contains the old table's values.
> IDL> TVSCL, Image ; display the image
> IDL> TVLCT, Previous ; reload the old table
> IDL> Window, /Free & Plot, Image ; using previous colour table in a
> new window
>
> And if you don't care what the previous colour table looked like, just
> type:
> IDL> LOADREDBLUE
> and you're away (assuming that, again, you've turned off decomposed
> colours)
> IDL> TV, Bindgen(256,256)
Yeah, I'd do it like this:
IDL> CTLoad, 22, /Brewer
Of course, that goes through white rather than black, but
that's better for the...uh, old folks who might be looking
at your plot. :-)
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|