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

Home » Public Forums » archive » Re: about color 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: about color table [message #66903 is a reply to message #66882] Thu, 18 June 2009 15:01 Go to previous messageGo to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Hu writes:

> I want to do something like this: I got an 2-D array with values range
> from 0.0 to 1.0. and I want to display the array using different
> colors. for example, if the value is greater than 0.8, the elements
> will be displayed as red, if the values is between 0.5 and 0.8, the
> color will be blue, and the relationship can be listed as follows:
>
>> 0.8 red
> 0.5-0.8 blue
> 0.3-0.5 yellow
> 0.2-0.3 green
> <0.2 white
>
> I know I need to set up a color table, and the book 'IDL Programming
> techniques' demostrate how to set up a color table, and I set up the
> table including those above colors.
>
> The question is , How can I set up the relationship between the color
> table and the different ranges? I mean how to 'tell' the computer
> display the array using this relationship?

TVLCT, FSC_Color(['white','green','yellow','blue','red'], /TRIPLE), 1
s = Size(array, /DIMENSIONS)
scaledData = BytArr(s[0], s[1])
I = Where(array LT 0.2, count)
IF count GT 0 THEN scaledData[I] = 1
I = Where(array GE 0.2 AND array LT 0.3, count)
IF count GT 0 THEN scaledData[I] = 2
I = Where(array GE 0.3 AND array LT 0.5, count)
IF count GT 0 THEN scaledData[I] = 3
I = Where(array GE 0.5 AND array LT 0.8, count)
IF count GT 0 THEN scaledData[I] = 4
I = Where(array GT 0.8, count)
IF count GT 0 THEN scaledData[I] = 5
TVImage, scaledData, /KEEP, /NOINTERP

Cheers,

David
--
David Fanning, Ph.D.
Coyote's Guide to IDL Programming (www.dfanning.com)
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Using t3d to perform a reflection
Next Topic: about color table

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

Current Time: Sat Oct 11 00:46:10 PDT 2025

Total time taken to generate the page: 0.72140 seconds