[vtk-developers] Incorrect color function in vtkImageMapToWindowLevelColors with lookupTable

David Gobbi david.gobbi at gmail.com
Fri May 25 14:02:59 EDT 2018


Hi xVict,

I've never trusted that code either, a per-component shift and scale only
makes sense to me if the input data is RGB.  I don't understand why
this class applies per-component shift and scale after vtkLookupTable.

Can anyone explain what's going on in this code?

 - David


On Fri, May 25, 2018 at 8:53 AM, xVict <suharev at roentgenprom.ru> wrote:

> 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.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://vtk.org/pipermail/vtk-developers/attachments/20180525/4153ff89/attachment.html>


More information about the vtk-developers mailing list