vtkColorTransferFunction + vtkImageData: Unexpected NaN opacity?
When I rendering an ImageData with many nan value, it works expected when the opacity of the lowest value is 0.0. Otherwise the nan value is still visible. How to always hide the nan value.
Opacity setting:
value_rng = img.GetScalarRange() opacity_pf = vtkPiecewiseFunction() opacity_pf.AddPoint(value_rng[0], 0.2) # the NaN value is still visible unless 0.0 here! opacity_pf.AddPoint(value_rng[1], 1.0)
Color setting:
color_tf = vtkColorTransferFunction() color_tf.AddRGBPoint(value_rng[0], 1.0, 0.0, 0.0) # red for low value color_tf.AddRGBPoint(valur_rng[1], 0.0, 0.0, 1.0) # green for high value color_tf.SetNanOpacity(0.0) # has no effect color_tf.Build()
A demo is attached here, all eight corners in the demo cubic are expected to be opacity (invisible).