<div dir="ltr">I'm going to try to answer my own question, hopefully someone<div>will jump in and correct me if I am wrong.<div><br></div><div>The idea behind vtkImageMapToWindowLevelColors seems to</div><div>be that the vtkLookupTable is intended to map the input values</div><div>to different hues (using whatever Range was specified), and</div><div>then the Window/Level is used to adjust the luminance.</div><div><br></div><div>My own typical use of VTK is medical image display, using</div><div>16-bit input images. So I want the window/level to be applied</div><div>directly to the 16-bit values. I definitely do not want to convert</div><div>my 16-bit values to 8-bit, and then rescale each 8-bit value</div><div>according to where the 16-bit value sits in the Window/Level.</div><div>But this seems to be what vtkImageMapToWindowLevelColors</div><div>does.</div><div><br></div><div> - David</div><div><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, May 25, 2018 at 12:02 PM, David Gobbi <span dir="ltr"><<a href="mailto:david.gobbi@gmail.com" target="_blank">david.gobbi@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi xVict,<div><br></div><div>I've never trusted that code either, a per-component shift and scale only</div><div>makes sense to me if the input data is RGB. I don't understand why</div><div>this class applies per-component shift and scale after vtkLookupTable.</div><div><br></div><div>Can anyone explain what's going on in this code?</div><span class="HOEnZb"><font color="#888888"><div><br></div><div> - David</div></font></span><div><div class="h5"><div> </div><div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, May 25, 2018 at 8:53 AM, xVict <span dir="ltr"><<a href="mailto:suharev@roentgenprom.ru" target="_blank">suharev@roentgenprom.ru</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi David!<br>
<br>
Some code skeleton:<br>
// Image viewer creation<br>
this->imgViewer = vtkSmartPointer<vtkImageViewer<wbr>2>::New();<br>
<br>
// Lut creation<br>
if (colorLut == nullptr)<br>
colorLut = vtkSmartPointer<vtkLookupTable<wbr>>::New();<br>
int norm = Range[1] - Range[0] + 1;<br>
colorLut->SetRange(Range[0], Range[1]);<br>
colorLut->SetIndexedLookup(0);<br>
colorLut->SetNumberOfTableValu<wbr>es(norm);<br>
colorLut->Build();<br>
for (int i = 0; i < norm; i++) {<br>
double cl = double(i) / (norm - 1);<br>
colorLut->SetTableValue(i, cl, cl, cl);<br>
}<br>
<br>
// change view option<br>
double c = 0.5*(this->Range[1] + this->Range[0]);<br>
double w = 1.0*(this->Range[1] - this->Range[0]);<br>
this->imgViewer->GetWindowLeve<wbr>l()->SetLevel(c);<br>
this->imgViewer->GetWindowLeve<wbr>l()->SetWindow(w);<br>
if (this->optycaltype == PSEUDO_COLOR) {<br>
createPseudoLUT();<br>
if (this->imgViewer->GetWindowLev<wbr>el()->GetLookupTable() ==<br>
nullptr)<br>
this->imgViewer->GetWindowLeve<wbr>l()->SetLookupTable(colorLut);<br>
}<br>
else {<br>
if (this->imgViewer->GetWindowLev<wbr>el()->GetLookupTable() !=<br>
nullptr)<br>
this->imgViewer->GetWindowLeve<wbr>l()->SetLookupTable(nullptr);<br>
}<br>
if (this->source != nullptr)<br>
imgViewer->Render();<br>
<br>
For 16bit image this code should show identical picture. But for<br>
PSEUDO_COLOR==8bit-gray (r=g=b in range [0...1] == [0...255]). <br>
<div class="m_-4524290031679834979HOEnZb"><div class="m_-4524290031679834979h5"><br>
Sincerely, Victor.<br></div></div></blockquote></div></div></div></div></div></div>
</blockquote></div><br></div>