pythonvtk

Are there colormap presets available in vtk?


My python script includes the line

lut = vtk.vtkColorTransferFunction()

I would like to apply a preset. I have found this link discussing presets in the context of vtk-js but can find no equivalent in the vtkColorTransferFunction class reference document.

Is there anyway I can exploit presets? I have found transfer functions in paraview.simple module that permit presets. E.g.

  lut = paraview.simple.GetColorTransferFunction('dummy')                      
  lut.ApplyPreset('rainbow)

could I draw from the paraview presets by e.g. converting a PVLookuptable object to a vtk lookup table object?


Solution

  • You can use vtkColorSeries. Basic use:

    colorSeries = vtk.vtkColorSeries()
    colorSeries.SetColorScheme(vtk.vtkColorSeries.BREWER_DIVERGING_SPECTRAL_11)
    lut = vtk.vtkLookupTable()
    colorSeries.BuildLookupTable(lut, vtk.vtkColorSeries.ORDINAL)
    

    Some (c++) doc here: https://vtk.org/doc/nightly/html/classvtkColorSeries.html

    Take a look at those examples:

    edit: update dead links