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

Home » Public Forums » archive » about color table
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
about color table [message #66904] Thu, 18 June 2009 14:40 Go to next message
Hu is currently offline  Hu
Messages: 35
Registered: January 2009
Member
Hi, folks

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?

Thanks
Re: about color table [message #67118 is a reply to message #66904] Sun, 21 June 2009 12:46 Go to previous message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
David Fanning wrote:
> Jeremy Bailin writes:
>
>> Yeah, value_locate is very handy for problems like this! I
>> particularly like using it as a precursor to histogram - i.e. if you
>> want to do something fancy using reverse_indices but don't have
>> uniformly-spaced bins, first use value_locate to get integer indices
>> and then use histogram to do the heavy lifting.
>
> All right, I'll bite. Let's see an example of this.
> Maybe you can write an article and become the JD Smith
> of Value_Locate. :-)

No article, but I think this is what Jeremy is talking about:

IDL> ; get some random data
IDL> d = randomu(12345678L, 20)
IDL> print, d
0.765989 0.0234537 0.589727 0.535102 0.982231
0.693016 0.328147
0.295642 0.849918 0.592262 0.558133 0.534926
0.541119 0.594831
0.410172 0.928598 0.161021 0.928724 0.952072
0.522173

IDL> ; specify cutoffs
IDL> cutoffs = [0.3, 0.4, 0.8]

IDL> ; compute index of "bin" to put each value into
IDL> bins = value_locate(cutoffs, d) + 1L
IDL> print, ind
2 0 2 2 3
2 1 0
3 2 2 2 2
2 2 3
0 3 3 2

IDL> ; compute histogram of bins
IDL> h = histogram(bins, reverse_indices=r)
IDL> print, h
3 1 11 5

IDL> ; values less than 0.3
IDL> print, d[r[r[0]:r[1] - 1]]
0.0234537 0.295642 0.161021

IDL> ; values between 0.3 and 0.4
IDL> print, d[r[r[1]:r[2] - 1]]
0.328147

IDL> ; values between 0.4 and 0.8
IDL> print, d[r[r[2]:r[3] - 1]]
0.765989 0.589727 0.535102 0.693016 0.592262
0.558133 0.534926
0.541119 0.594831 0.410172 0.522173

IDL> ; values greater than 0.8
IDL> print, d[r[r[3]:r[4] - 1]]
0.982231 0.849918 0.928598 0.928724 0.952072

Mike
--
www.michaelgalloy.com
Associate Research Scientist
Tech-X Corporation
Re: about color table [message #67119 is a reply to message #66904] Fri, 19 June 2009 20:58 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Jeremy Bailin writes:

> Yeah, value_locate is very handy for problems like this! I
> particularly like using it as a precursor to histogram - i.e. if you
> want to do something fancy using reverse_indices but don't have
> uniformly-spaced bins, first use value_locate to get integer indices
> and then use histogram to do the heavy lifting.

All right, I'll bite. Let's see an example of this.
Maybe you can write an article and become the JD Smith
of Value_Locate. :-)

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.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: about color table
Next Topic: matrix - element extraction

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

Current Time: Sat Oct 11 08:45:58 PDT 2025

Total time taken to generate the page: 0.64132 seconds