Difference and use cases for `vtkMRMLProceduralColorNode` and `vtkMRMLColorTableNode`

Hi,

I’m wondering what is the difference between vtkMRMLProceduralColorNode and vtkMRMLColorTableNode?
For example I can see that vtkMRMLColorTableNode creates discrete color map while vtkMRMLProceduralColorNode creates continous.

Maybe they serve to different purposes?

All these mode types can store both discrete and continuous (depending on what you set inside - color transfer function or lookup table).

Procedural color node is a special kind of color node that does not need to be saved into a file because the color function or table entries are generated programmatically.

1 Like

Thank you, that make sense

I just can’t find a method that triggers discrete or contigous color.
This is my attemt that results in discrete color map:

  vtkNew<vtkMRMLColorTableNode> bwrColorTable;

  bwrColorTable->SetType(vtkMRMLColorTableNode::User);
  bwrColorTable->HideFromEditorsOff();  // make the color table selectable in the GUI outside Colors module
  bwrColorTable->SetSaveWithScene(true);
  bwrColorTable->SetNumberOfColors(5);
  bwrColorTable->GetLookupTable()->SetTableRange(0.,1.);

  bwrColorTable->SetColor(0, 0.0,     0.0,    0.5,    1.0);
  bwrColorTable->SetColor(1, 0.0,     0.375,  0.8314, 0.5);
  bwrColorTable->SetColor(2, 1.0,     1.0,    1.0,    0.0);
  bwrColorTable->SetColor(3, 0.8314,  0.375,  0.0,    0.5);
  bwrColorTable->SetColor(4, 0.5,     0.0,    0.0,    1.0);

  bwrColorTable->SetName("BWR");
  bwrColorTable->SetScene(this->GetMRMLScene());
  bwrColorTable->SetHideFromEditors(false);
  this->GetMRMLScene()->AddNode(bwrColorTable);