| Re: about color table [message #66882 is a reply to message #66880] |
Thu, 18 June 2009 21:12   |
Hu
Messages: 35 Registered: January 2009
|
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.")
Great, Thanks David
|
|
|
|