[vtkusers] LookupTable and ScalarBar

David.Pont at ForestResearch.co.nz David.Pont at ForestResearch.co.nz
Wed Aug 4 17:45:27 EDT 2004






nikhil butala <nvbutala at yahoo.com> wrote on 05/08/2004 03:24:12:

> Dear VTK users,
>
>
>                        I am trying to plot (pressure) values from
> 10^ -7 to 10^ +7 in VTK. But most of the values are centered around
> 10^ +5.  I want the full range of colors in the scalar bar between
> 10^+4 and 10^ +6. Is there a way to do this in VTK?? I cannot set
> range between 10^ +4 and 10^+6, because I want to plot the other
> values as well.
>
>                       In other words, I want to map particular
> values(of pressure) to particular colors on the scalar bar. Can I
> build a lookuptable which can do this??
>
>                      I tried using the log scale. But all it does is
> it converts the colors into logarthmic fashion keeping the values
> linear.I would have expected the labels to progress logorithmically
> over the range so that I can clearly see the colors in the map. Can
> I get this effect without having to write my own lookup table/scalar bar?
> Thanking you,
> Nikhil Butala_______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at: <http://public.
> kitware.com/cgi-bin/vtkfaq>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers

Hi Nikhil,
   There is an alternative way to create a lookuptable: use SetRange,
SetNumberOfColors, SetTableValue (called 'NumberOfColors' times) and Build.
If you want more colours in the middle of the range you could specify the
same colour for several table entries at the ends...

For example with classes of size 10^1 you would SetNumberOfColors=14 and
then could call SetTableValue:
0 to 10  (scalar range 10^-7 to 10^4) with 1,0,0,1  (red)
11          (scalar range 10^4 to 10^5) with 1,1,0,1 (red+green)
12          (scalar range 10^5 to 10^6) with 0,1,0,1 (green)
13          (scalar range 10^6 to 10^7) with 0,0,1,1 (blue)
finally call Build.

You probably want more colours in the range of interest so use a smaller
class size. A good way to get a nice colour range might be to construct a
standard lookuptable (red-blue), specifiying the NumberOfColors to match
what you want, call Build, then use GetTableValue to pull out the nicely
graded set of colours and place them in your new lookuptable to create your
non-linear transition from red to blue.
A final tip, you can use the alpha value to make ranges of scalars 'fade
out' or disappear completely, a powerful form of clipping based on scalar
value, so you could use alpha<0 for the uninteresting parts of the range.

  Dave P




More information about the vtkusers mailing list