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 #66880 is a reply to message #66879] Thu, 18 June 2009 21:30 Go to previous messageGo to previous message
Jeremy Bailin is currently offline  Jeremy Bailin
Messages: 618
Registered: April 2008
Senior Member
On Jun 18, 6:01 pm, David Fanning <n...@dfanning.com> wrote:
> 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.")

Another way of going from array to scaledData (i.e. everything in
between TVLCT and TVImage in David's code), that's probably easier to
deal with if you want to change the values (or number) of the cutoffs,
is:

cutoffs = [0.2, 0.3, 0.5, 0.8]
scaledData = byte(value_locate(cutoffs, array) + 2)

-Jeremy.
[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 10:21:38 PDT 2025

Total time taken to generate the page: 1.28546 seconds