[vtkusers] Mapping NaN through a vtkLookupTable

David.Pont at ForestResearch.co.nz David.Pont at ForestResearch.co.nz
Tue Nov 11 17:03:43 EST 2003


Hi Sidney,
   vtkLookupTable maps scalar values linearly from the scalar range you
specify (to the vtkMapper?) into a discrete set of colors, the number of
which you specify.  Scalar values outside the specified range are clamped,
so I guess NaN ends up as either the min (or max?) value of your scalar
range.

I think you are looking at a derived (or modified) vtkLookupTable that
allows the user to specify a set of scalar values that define the
boundaries between adjacent colors, ie the user specifies a NumberOfColors,
then sets scalar values (NumberOfColors+1) that define boundary scalar
values for the color mapping.

Take a look at vtkContourFilter, it has SetNumberOfContours, then you have
the option of calling GenerateValues to get uniformly spaced values, or of
calling SetValue( i...) to get contours at arbitrary values. This is the
kind of interface you could use with a lookup table, ie have a uniformly
spaced set of color classes, or a set with arbitrary boundaries. You can
probably borrow chunks of code from vtkContourFilter (and its internal
vtkContourValues).

I dont know about vtk policy on extending existing classes (which you could
safely and usefully do in this case) versus deriving a new class, the
latter might be safer.

By the way, if you have point rather than cell data associated with
polydata the point colors are sent to OpenGL which then interpolates across
polygon faces as part of its lighting/shading process, at least I think
that is what happens? As a result the original discrete colors are blended
in the rendering process. So if you make a special color for NaN be aware
that it would be blended with the color of adjacent points across polygons.
Perhaps you have vtkImageData, in which case I dont know what happens :-P

Let me know how you get on, I would be interested in this capability.

  regards
   Dave P



|---------+--------------------------------->
|         |           Sidney Cadot          |
|         |           <cadot at science-and-tec|
|         |           hnology.nl>           |
|         |           Sent by:              |
|         |           vtkusers-admin at vtk.org|
|         |                                 |
|         |                                 |
|         |           12/11/2003 02:39      |
|         |                                 |
|---------+--------------------------------->
  >--------------------------------------------------------------------------------------------------------------------------------|
  |                                                                                                                                |
  |       To:       vtkusers at vtk.org                                                                                               |
  |       cc:                                                                                                                      |
  |       Subject:  [vtkusers] Mapping NaN through a vtkLookupTable                                                                |
  >--------------------------------------------------------------------------------------------------------------------------------|




Hi all,

I have a 2D dataset containing floating point values that is converted
to RGB colors using a vtkLookupTable. However, the originating dataset
may contain NaN values where no measurements are available. Ideally, I
would like to be able to specify a special RGB color value for NaN
values.

Could someone explain if the behavior of the vtkLookupTable is
well-defined for NaN values? Currently, it seems to always be mapped to
the first RGB value in the table. Is this correct?

Furthermore, would anyone venture an opinion of whether this would be
useful enough to warrant a change to the vtkLookupTable implementation?
I'd be quite willing to have a go at this.

Best regards,

   Sidney Cadot
   Science and Technology Corp.
   The Netherlands

_______________________________________________
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








More information about the vtkusers mailing list