<div dir="ltr">And the values (W: 80, L: 35) that are shown on the image... where do they come from?</div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, May 19, 2016 at 7:30 AM, Flaviu2 <span dir="ltr"><<a href="mailto:flaviu2@yahoo.com" target="_blank">flaviu2@yahoo.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div style="color:#000;background-color:#fff;font-family:Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;font-size:16px"><div><span>David, I cannot thank you enough for your kindness.</span></div><div><span>Yes, I post the code used for case without LUT:</span></div><div><span></span><br></div><div><span></span><br></div><div dir="ltr"><span><span class=""> vtkDICOMReader* m_pDICOMReader = vtkDICOMReader::New();<br> m_pDICOMReader->RemoveAllInputs();<br> vtkDICOMApplyRescale* m_pRescale = vtkDICOMApplyRescale::New();<br> m_pDICOMReader->SetFileNames(pFN); // all files from serie<br> m_pDICOMReader->AutoRescaleOff();<br> m_pDICOMReader->Update();<br> m_pRescale->SetInputConnection(m_pDICOMReader->GetOutputPort());<br> m_pRescale->Update();<br> vtkImageReslice* m_pResliceAxial = vtkImageReslice::New();<br> m_pResliceAxial->SetInputConnection(m_pRescale->GetOutputPort());<br></span><span class=""> vtkImageMapToColors* m_pColorAxial = vtkImageMapToColors::New();<br></span><span class=""> m_pColorAxial->SetInputConnection(m_pResliceAxial->GetOutputPort());<br> vtkImageActor* m_pImageActor = vtkImageActor::New();<br> // and then, forward, setup m_pColorAxial to an image actor:<br> pImageActor->GetMapper()->SetInputConnection(m_pColorAxial->GetOutputPort());<br> // and add image actor to a renderer<br> m_pRenderer->AddActor(m_pImageActor);</span></span></div><div><br></div><div dir="ltr">In fact, I am using the same code, but I am not using vtkLookupTable at all ... I know, it is not quite ok, but it is the only way to have the original window level from the image ...</div><div dir="ltr"><br></div><div dir="ltr">Flaviu.</div><div><div class="h5"><span><div><br></div><div dir="ltr"><br></div></span><div><span></span><br></div><div><span></span><br></div> <div><br><br></div><div style="display:block"> <div style="font-family:Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;font-size:16px"> <div style="font-family:HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;font-size:16px"> <div dir="ltr"><font face="Arial" size="2"> On Thursday, May 19, 2016 4:03 PM, David Gobbi <<a href="mailto:david.gobbi@gmail.com" target="_blank">david.gobbi@gmail.com</a>> wrote:<br></font></div> <br><br> <div><div><div><div dir="ltr">I will try to answer your question, but I need to know more about your code first. Can you post the code you used for the "Snapshot_without_LUT" image? In particular, the screenshot has a Window/Level annotation (W: 80, L: 35), so show me how those values are used in the code.<div><br clear="none"><div><div>On Thu, May 19, 2016 at 6:35 AM, Flaviu2 <span dir="ltr"><<a href="mailto:flaviu2@yahoo.com" rel="nofollow" shape="rect" target="_blank">flaviu2@yahoo.com</a>></span> wrote:<br clear="none"><blockquote style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><div><div style="color:rgb(0,0,0);font-family:Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;font-size:16px;background-color:rgb(255,255,255)"><div dir="ltr">Hi David. Something strange is happen ... I had tried to set LUT as you said, but the image are still whiter than without LUT ... see attached images ...</div><div dir="ltr"><br clear="none"></div><div dir="ltr">And of course, I can not use vtkImageMapToColors without LUT, because the application is crashing ... is there a solution here ?</div><div dir="ltr"><br clear="none"></div><div dir="ltr">Flaviu.<br clear="none"></div><div><div> <div><br clear="none"><br clear="none"></div><div style="display:block"> <div style="font-family:Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;font-size:16px"> <div style="font-family:HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;font-size:16px"> <div dir="ltr"><font face="Arial" size="2"> </font><font face="Arial" size="2"><br clear="none"></font></div><div><div><div><div style="color:rgb(0,0,0);font-family:Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;font-size:16px;background-color:rgb(255,255,255)"><div><div style="display:block"><div style="font-family:Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;font-size:16px"><div style="font-family:HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;font-size:16px"> <br clear="none"><br clear="none"> <div><div><div><div dir="ltr">Hi Flaviu,<div><br clear="none"></div><div>This is incorrect:</div><div><br clear="none"></div><div>m_pLUTAxial->SetRange(dLevel, dWindow);<br clear="none"></div><div><br clear="none"></div><div>It should be something like this:</div><div><br clear="none"></div><div><div>m_pLUTAxial->SetRange(dLevel - 0.5*dWindow, dLevel + 0.5*dWindow);</div></div><div><br clear="none"></div><div> - David</div><div><br clear="none"></div></div><div><div><br clear="none"><div>On Fri, May 13, 2016 at 1:22 AM, Flaviu2 <span dir="ltr"><<a href="mailto:flaviu2@yahoo.com" rel="nofollow" shape="rect" target="_blank">flaviu2@yahoo.com</a>></span> wrote:<br clear="none"><blockquote style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><div><div style="color:rgb(0,0,0);font-family:Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;font-size:16px;background-color:rgb(255,255,255)"><div><span></span></div><div>This is a little pseudocode of the entire pipeline:</div><div><br clear="none"></div><div> vtkDICOMReader* m_pDICOMReader = vtkDICOMReader::New();</div><div>
</div><div> m_pDICOMReader->RemoveAllInputs();</div><div>
</div><div> vtkDICOMApplyRescale* m_pRescale = vtkDICOMApplyRescale::New();</div><div>
</div><div dir="ltr"> m_pDICOMReader->SetFileNames(pFN); // all files from serie</div><div>
</div><div> m_pDICOMReader->AutoRescaleOff();</div><div>
</div><div> m_pDICOMReader->Update();</div><div>
</div><div> m_pRescale->SetInputConnection(m_pDICOMReader->GetOutputPort());</div><div>
</div><div> m_pRescale->Update();</div><div>
</div><div> vtkImageReslice* m_pResliceAxial = vtkImageReslice::New();</div><div>
</div><div> m_pResliceAxial->SetInputConnection(m_pRescale->GetOutputPort());</div><div>
</div><div> vtkLookupTable* m_pLUTAxial = vtkLookupTable::New();</div><span></span><div>
</div><div> m_pLUTAxial->SetValueRange(0.0, 1.0); <font color="#008000">// from black to white</font></div><div><font color="#008000">
</font></div><div> m_pLUTAxial->SetSaturationRange(0.0, 0.0); <font color="#008000">// no color saturation</font></div><div><font color="#008000">
</font></div><div> vtkDICOMMetaData* pMeta = m_pDICOMReader->GetMetaData();</div><div>
</div><div> <font color="#0000ff">const</font> vtkDICOMValue& window = pMeta->GetAttributeValue(DC::WindowWidth);</div><div>
</div><div> <font color="#0000ff">const</font> vtkDICOMValue& level = pMeta->GetAttributeValue(DC::WindowCenter);</div><div>
</div><div> <font color="#0000ff">double</font> dWindow = window.AsDouble();</div><div>
</div><div> <font color="#0000ff">double</font> dLevel = level.AsDouble();</div><div>
</div><div> m_pLUTAxial->SetRange(dLevel, dWindow); <font color="#008000">// image intensity range</font></div><div><font color="#008000">
</font></div><div> m_pLUTAxial->SetRampToLinear();</div><div>
</div><div> m_pLUTAxial->Build();</div><div>
</div><div> vtkImageMapToColors* m_pColorAxial = vtkImageMapToColors::New();</div><div>
</div><div> m_pColorAxial->SetLookupTable(m_pLUTAxial);</div><div>
</div><div> m_pColorAxial->SetInputConnection(m_pResliceAxial->GetOutputPort());</div><div>
</div><div> vtkImageActor* m_pImageActor = vtkImageActor::New();</div><div>
</div><div> <font color="#008000">// and then, forward, setup m_pColorAxial to an image actor:</font></div><div><font color="#008000">
</font></div><div> pImageActor->GetMapper()->SetInputConnection(m_pColorAxial->GetOutputPort());</div><div>
</div><div> <font color="#008000">// and add image actor to a renderer</font></div><div><font color="#008000">
</font></div><div> m_pRenderer->AddActor(m_pImageActor);</div><div dir="ltr"><br clear="none"></div><div style="display:block"><div style="font-family:Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;font-size:16px"><div style="font-family:HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;font-size:16px"><div><div><div><div style="color:rgb(0,0,0);font-family:Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;font-size:16px;background-color:rgb(255,255,255)"><div style="font-family:HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;font-size:16px;display:block"><font face="Arial" size="2"></font><br clear="none"></div><div style="font-family:HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;font-size:16px;display:block" dir="ltr">I had taken "Window center" and "Window width" and put them as range on lookuptable ... the image are little dark, and is not like the original (without setup lookup table looks good, but I get those warning like in post subject) ... might not understand well what you said about this range, but I am feel I am not far from solve this problem ... can you guide me a little bit ?</div><div style="font-family:HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;font-size:16px;display:block" dir="ltr"><br clear="none"></div><div style="font-family:HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;font-size:16px;display:block" dir="ltr">Flaviu.</div><span><font face="Arial" size="2"></font></span><div style="font-family:HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;font-size:16px;display:block"><br clear="none"></div><div style="font-family:HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;font-size:16px;display:block"><br clear="none"></div><div style="font-family:HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;font-size:16px;display:block" dir="ltr"><br clear="none"></div><div style="font-family:HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;font-size:16px;display:block"><font face="Arial" size="2"></font> <br clear="none"><br clear="none"> </div><div style="font-family:HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;font-size:16px;display:block"><div><div><div dir="ltr">Since you're already using vtk-dicom, you can use vtkDICOMApplyRescale<div>to convert your CT image to Hounsfield units (if you use this filter, you should</div><div>also call AutoRescaleOff() on the reader).</div><div><br clear="none"></div><div>After the image has been converted to Hounsfield units, you can use the</div><div>"Window Center" and "Window Width" presets that are stored in the meta</div><div>data to set the range for the lookup table.</div><div><br clear="none"></div><div>However, I usually ignore these presets, and instead use the VTK class</div><div>vtkImageHistogramStatistics to compute the range. Its GetAutoRange()</div><div>computes a range by doing some simple histogram analysis.</div><div><br clear="none"></div><div>If you enjoy doing a lot of reading, the relevant parts the DICOM standard</div><div>are here:</div><div><a href="http://dicom.nema.org/MEDICAL/Dicom/current/output/chtml/part03/sect_C.11.html" rel="nofollow" shape="rect" target="_blank">http://dicom.nema.org/MEDICAL/Dicom/current/output/chtml/part03/sect_C.11.html</a></div><div><br clear="none"></div><div>After the image goes through vtkImageMapToColors, how are you</div><div>rendering it?</div><div><br clear="none"></div><div> - David<br clear="none"><br clear="none"></div></div></div></div></div></div></div></div></div> </div> </div> </div></div></div></blockquote></div><br clear="none"></div></div></div></div><br clear="none"><br clear="none"></div> </div> </div> </div></div></div></div></div><br clear="none"><br clear="none"></div> </div> </div> </div></div></div></div></div></blockquote></div></div><br clear="none"></div></div></div></div><br><br></div> </div> </div> </div></div></div></div></div></blockquote></div><br></div>