[vtkusers] scalar value to color mapping
Dr. Jörg Seemann (V2T)
seemann at v2t.de
Mon Jun 30 14:10:34 EDT 2003
Dear VTK-users,
I tried to map scalar image data to a color map.
Firstly, I defined a rainbow lookup table:
vtkLookupTable *lut = vtkLookupTable::New();
lut->SetTableRange (minimumResult1, maximumResult1);
lut->SetHueRange (0.6667, 0.0);
lut->SetSaturationRange (1.0, 1.0);
lut->SetValueRange (1.0, 1.0);
lut->SetAlphaRange (1.0, 1.0);
lut->SetNumberOfColors (256);
lut->Build();
Here minimumResult1 and maximumResult1 are the minimum and maximum of the
image data.
Next, I used the vtkImageMapToWindowLevelColors filter:
vtkImageMapToWindowLevelColors *Colors =
vtkImageMapToWindowLevelColors::New();
Colors->SetInput(resample->GetOutput());
Colors->SetLookupTable(lut);
Colors->SetWindow(maximumResult1-minimumResult1);
Colors->SetLevel((maximumResult1-minimumResult1)/2);
Colors->Update();
Finally, I used the vtkImageViewer to render the image.
vtkImageViewer *viewer = vtkImageViewer::New();//window to visualisation
viewer->SetInput(Colors->GetOutput());
viewer->SetColorWindow (255.0);
viewer->SetColorLevel (127.5);
viewer->Render();
I expected that the data range would cover the whole color palette,
but I does nor work, if minimumResult1 is a negative (negative values are
missing using the
above code).
May somebody know how to set the parameter for the filters correctly?
Best regards,
Jörg
More information about the vtkusers
mailing list