Hello,
I am attempting to use the vtkColorTransferFunction or the vtkDiscretizableColorTransferFunction class to create a custom colormap for my vtk-based application. I am using this class in lieu of the vtkLookupTable class, because (I think?) it gives me more control over the color range. But, as is possible with vtkLookupTable, I would like to set any value that is either above or below range to be transparent. How can I achieve this?
jet_table = vtk.vtkDiscretizableColorTransferFunction()
jet_table.SetColorSpaceToRGB()
jet_table.SetScaleToLinear()
jet_table.SetAboveRangeColor(216/255, 0/255, 221/255)
jet_table.AddRGBPoint(50, 216/255, 0/255, 221/255)
jet_table.AddRGBPoint(49, 224/255, 14/255, 0/255)
jet_table.AddRGBPoint(47.5, 255/255, 83/255, 0/255)
jet_table.AddRGBPoint(46, 249/255, 255/255, 6/255)
jet_table.AddRGBPoint(44, 152/255, 255/255, 103/255)
jet_table.AddRGBPoint(42, 0/255, 229/255, 255/255)
jet_table.AddRGBPoint(40, 0/255, 51/255, 255/255)
jet_table.AddRGBPoint(38, 0/255, 0/255, 128/255)
# doesn't work ...
# opacity = vtk.vtkPiecewiseFunction()
# opacity.AddSegment(0, 0, 38, 0) # Range [0, min] will have zero opacity.
# opacity.AddSegment(38, 1, 50, 1) # Range [min, max] will have full (1) opacity.
# jet_table.SetScalarOpacityFunction(opacity)
# jet_table.EnableOpacityMappingOn()
Thanks!
Michelle