[vtkusers] vtkLookUpTable not well defined for NaNs

Sarah Macumber S.Macumber at QuestReliability.com
Thu Oct 16 13:47:43 EDT 2008


I did find a work around for this issue, thanks to the Kitware folks and
wanted to pass it along.

 

Here is some C# code to build a vtkColorTransferFunction, which you
should be able to use instead of a vtkLookupTable. (They both inherit
from vtkScalarsToColors and the APIs are usually designed to work with
the vtkScalarsToColors class.)

 

            // More generic: use a vtkColorTransferFunction instead of
vtkLookupTable

            // for better NaN handling... (Add discrete scalar values
that map directly

            // to known color values, anything in between the discrete
scalar values

            // are interpolated.)

            //

            vtkColorTransferFunction tf =
vtkColorTransferFunction.New();

            double data_min = -10000;

            double data_max = 10000;

            tf.AddRGBPoint(data_min - 1, 1.0, 0.0, 0.0); // red == below
valid data range, including NaNs

            tf.AddRGBPoint(data_min, 0.0, 0.0, 0.0);

            tf.AddRGBPoint(data_max, 1.0, 1.0, 1.0);

            tf.AddRGBPoint(data_max + 1, 0.0, 0.0, 1.0); // blue ==
above valid data range

 

Sarah

 

From: vtkusers-bounces at vtk.org [mailto:vtkusers-bounces at vtk.org] On
Behalf Of Sarah Macumber
Sent: Wednesday, October 01, 2008 11:51 AM
To: VTKUsers
Subject: [vtkusers] vtkLookUpTable not well defined for NaNs

 

Hello,

 

I was hoping someone could help with mapping scalar data containing NaNs
through a vtkLookUpTable where one wants the NaNs to be a certain color.
Internally vtkLookUpTable uses the range to determine the index of the
color used for a specific scalar value:

 

                index = (value-min)/(max-min)*(N-1)

 

which means that NaNs do not have well defined index.  Currently, NaN's
default to an index of 0.  Changing the 0th color value conflicts with
the min scalar value being displayed which also has an index of 0.

 

Is there any way to set the color of a NaN using a vtkLookUpTable
without it conflicting with the viewable data?

 

Thanks,

Sarah

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20081016/d02f94dc/attachment.htm>


More information about the vtkusers mailing list