Re: color table question [message #29764 is a reply to message #435] |
Fri, 15 March 2002 17:19   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Rob Dimeo (robert.dimeo@nist.gov) writes:
> I suspect that this question will have a very simple answer (hoping,
> anyway).
>
> I want to display an image using color table 6 but this color table
> does not have white in it. Next I want to display a white crosshairs
> on top of the image. The way that I do this is not ideal because I am
> loading the black-white color table after displaying the color image
> in the window but before I draw the crosshairs (see test code below).
> The reason that this is not ideal is that, in my application, I am
> really moving this crosshairs around the screen as the cursor moves
> over the image. Motion events are being generated resulting in many
> calls to loadct, slowing down the whole works.
>
> I guess what I am really asking for is a persistent way to specify the
> color of something as white (for instance) when a particular color
> table has been loaded. I suspect that I can replace one of the color
> table entries with [255,255,255] for instance? I just am not sure how
> to do this.
Typically, one loads "image" colors in one part of
the color table and "drawing" colors in another.
I always put drawing colors at the top of the color
table, because it is easier to restrict image
display to the bottom of the color table (you
don't have to add anything to the byte scaled
image data). I'd set this color table up like
this:
topColorIndex = !D.Table_Size - 1
LOADCT, 6, NColors=topColorIndex
TVLCT, 255, 255, 255, topColorIndex
Then, I'd display my image like this:
TV, BytScl(image, Top=topColorIndex-1)
And I would draw the cursor like this:
PlotS, x, y, /Device, Color=topColorIndex
If you liked this color table you could save it
and use it over again. Here, for example, is one
way to do that:
TVLCT, rr, gg, bb, /Get
Save, rr, gg, bb, File='mycolortable.sav'
Then, when you wanted to use it, you could do
this:
Restore, 'mycolortable.sav'
TVLCT, rr, gg, bb
Just remember to scale your image data into the
number of colors you are using as "image" colors
in the color table. You might even want to save
a variable with this information with your color
table information.
Cheers,
David
--
David W. Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|