<html><head></head><body><div style="color:#000; background-color:#fff; font-family:Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px"><div id="yui_3_16_0_1_1463664091266_2807" abp="2649"><span id="yui_3_16_0_1_1463664091266_2815" abp="2650">David, I cannot thank you enough for your kindness.</span></div><div id="yui_3_16_0_1_1463664091266_2825" abp="2649"><span id="yui_3_16_0_1_1463664091266_2824" abp="2650">Yes, I post the code used for case without LUT:</span></div><div id="yui_3_16_0_1_1463664091266_2974" abp="2649"><span abp="2650"></span><br></div><div id="yui_3_16_0_1_1463664091266_2979" abp="2649"><span abp="2650"></span><br></div><div id="yui_3_16_0_1_1463664091266_3029" dir="ltr" abp="2649"><span id="yui_3_16_0_1_1463664091266_3028" abp="2650"> vtkDICOMReader* m_pDICOMReader = vtkDICOMReader::New();<br id="yui_3_16_0_1_1463664091266_3002" abp="3015"> m_pDICOMReader->RemoveAllInputs();<br id="yui_3_16_0_1_1463664091266_3003" abp="3016"> vtkDICOMApplyRescale* m_pRescale = vtkDICOMApplyRescale::New();<br id="yui_3_16_0_1_1463664091266_3004" abp="3017"> m_pDICOMReader->SetFileNames(pFN); // all files from serie<br id="yui_3_16_0_1_1463664091266_3005" abp="3018"> m_pDICOMReader->AutoRescaleOff();<br id="yui_3_16_0_1_1463664091266_3006" abp="3019"> m_pDICOMReader->Update();<br id="yui_3_16_0_1_1463664091266_3007" abp="3020"> m_pRescale->SetInputConnection(m_pDICOMReader->GetOutputPort());<br id="yui_3_16_0_1_1463664091266_3008" abp="3021"> m_pRescale->Update();<br id="yui_3_16_0_1_1463664091266_3009" abp="3022"> vtkImageReslice* m_pResliceAxial = vtkImageReslice::New();<br id="yui_3_16_0_1_1463664091266_3010" abp="3023"> m_pResliceAxial->SetInputConnection(m_pRescale->GetOutputPort());<br id="yui_3_16_0_1_1463664091266_3011" abp="3024"> vtkImageMapToColors* m_pColorAxial = vtkImageMapToColors::New();<br id="yui_3_16_0_1_1463664091266_3012" abp="3025"> m_pColorAxial->SetInputConnection(m_pResliceAxial->GetOutputPort());<br id="yui_3_16_0_1_1463664091266_3013" abp="3026"> vtkImageActor* m_pImageActor = vtkImageActor::New();<br id="yui_3_16_0_1_1463664091266_3014" abp="3027"> // and then, forward, setup m_pColorAxial to an image actor:<br id="yui_3_16_0_1_1463664091266_3015" abp="3028"> pImageActor->GetMapper()->SetInputConnection(m_pColorAxial->GetOutputPort());<br id="yui_3_16_0_1_1463664091266_3016" abp="3029"> // and add image actor to a renderer<br id="yui_3_16_0_1_1463664091266_3017" abp="3030"> m_pRenderer->AddActor(m_pImageActor);</span></div><div id="yui_3_16_0_1_1463664091266_3100" abp="3032"><br></div><div id="yui_3_16_0_1_1463664091266_3079" dir="ltr" abp="3033">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 id="yui_3_16_0_1_1463664091266_3101" dir="ltr" abp="3033"><br></div><div dir="ltr" abp="3033">Flaviu.</div><span id="yui_3_16_0_1_1463664091266_3074" abp="2650"><div id="yui_3_16_0_1_1463664091266_3075" abp="3034"><br></div><div id="yui_3_16_0_1_1463664091266_3073" dir="ltr" abp="2649"><br id="yui_3_16_0_1_1463664091266_3018" abp="3031"></div></span><div id="yui_3_16_0_1_1463664091266_2822" abp="2649"><span abp="2650"></span><br></div><div id="yui_3_16_0_1_1463664091266_2823" abp="2649"><span abp="2650"></span><br></div> <div class="qtdSeparateBR"><br><br></div><div class="yahoo_quoted" 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 <david.gobbi@gmail.com> wrote:<br></font></div> <br><br> <div class="y_msg_container"><div id="yiv8932604733"><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 class="yiv8932604733gmail_extra"><br clear="none"><div class="yiv8932604733yqt0910960404" id="yiv8932604733yqt36038"><div class="yiv8932604733gmail_quote">On Thu, May 19, 2016 at 6:35 AM, Flaviu2 <span dir="ltr"><<a href="mailto:flaviu2@yahoo.com" target="_blank" rel="nofollow" shape="rect" ymailto="mailto:flaviu2@yahoo.com">flaviu2@yahoo.com</a>></span> wrote:<br clear="none"><blockquote class="yiv8932604733gmail_quote" 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" target="_blank" rel="nofollow" shape="rect" ymailto="mailto:flaviu2@yahoo.com">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" target="_blank" rel="nofollow" shape="rect">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></body></html>