[vtk-developers] Incorrect color function in vtkImageMapToWindowLevelColors with lookupTable
xVict
suharev at roentgenprom.ru
Fri May 25 10:53:14 EDT 2018
Hi David!
Some code skeleton:
// Image viewer creation
this->imgViewer = vtkSmartPointer<vtkImageViewer2>::New();
// Lut creation
if (colorLut == nullptr)
colorLut = vtkSmartPointer<vtkLookupTable>::New();
int norm = Range[1] - Range[0] + 1;
colorLut->SetRange(Range[0], Range[1]);
colorLut->SetIndexedLookup(0);
colorLut->SetNumberOfTableValues(norm);
colorLut->Build();
for (int i = 0; i < norm; i++) {
double cl = double(i) / (norm - 1);
colorLut->SetTableValue(i, cl, cl, cl);
}
// change view option
double c = 0.5*(this->Range[1] + this->Range[0]);
double w = 1.0*(this->Range[1] - this->Range[0]);
this->imgViewer->GetWindowLevel()->SetLevel(c);
this->imgViewer->GetWindowLevel()->SetWindow(w);
if (this->optycaltype == PSEUDO_COLOR) {
createPseudoLUT();
if (this->imgViewer->GetWindowLevel()->GetLookupTable() ==
nullptr)
this->imgViewer->GetWindowLevel()->SetLookupTable(colorLut);
}
else {
if (this->imgViewer->GetWindowLevel()->GetLookupTable() !=
nullptr)
this->imgViewer->GetWindowLevel()->SetLookupTable(nullptr);
}
if (this->source != nullptr)
imgViewer->Render();
For 16bit image this code should show identical picture. But for
PSEUDO_COLOR==8bit-gray (r=g=b in range [0...1] == [0...255]).
Sincerely, Victor.
--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Dev-f1251487.html
More information about the vtk-developers
mailing list