[vtkusers] No LookupTable was set but input data is not VTK_UNSIGNED_CHAR
David Gobbi
david.gobbi at gmail.com
Thu May 19 10:41:33 EDT 2016
And the values (W: 80, L: 35) that are shown on the image... where do they
come from?
On Thu, May 19, 2016 at 7:30 AM, Flaviu2 <flaviu2 at yahoo.com> wrote:
> David, I cannot thank you enough for your kindness.
> Yes, I post the code used for case without LUT:
>
>
> vtkDICOMReader* m_pDICOMReader = vtkDICOMReader::New();
> m_pDICOMReader->RemoveAllInputs();
> vtkDICOMApplyRescale* m_pRescale = vtkDICOMApplyRescale::New();
> m_pDICOMReader->SetFileNames(pFN); // all files from serie
> m_pDICOMReader->AutoRescaleOff();
> m_pDICOMReader->Update();
> m_pRescale->SetInputConnection(m_pDICOMReader->GetOutputPort());
> m_pRescale->Update();
> vtkImageReslice* m_pResliceAxial = vtkImageReslice::New();
> m_pResliceAxial->SetInputConnection(m_pRescale->GetOutputPort());
> vtkImageMapToColors* m_pColorAxial = vtkImageMapToColors::New();
> m_pColorAxial->SetInputConnection(m_pResliceAxial->GetOutputPort());
> vtkImageActor* m_pImageActor = vtkImageActor::New();
> // and then, forward, setup m_pColorAxial to an image actor:
>
> pImageActor->GetMapper()->SetInputConnection(m_pColorAxial->GetOutputPort());
> // and add image actor to a renderer
> m_pRenderer->AddActor(m_pImageActor);
>
> 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 ...
>
> Flaviu.
>
>
>
>
>
>
> On Thursday, May 19, 2016 4:03 PM, David Gobbi <david.gobbi at gmail.com>
> wrote:
>
>
> 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.
>
> On Thu, May 19, 2016 at 6:35 AM, Flaviu2 <flaviu2 at yahoo.com> wrote:
>
> 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 ...
>
> And of course, I can not use vtkImageMapToColors without LUT, because the
> application is crashing ... is there a solution here ?
>
> Flaviu.
>
>
>
>
>
> Hi Flaviu,
>
> This is incorrect:
>
> m_pLUTAxial->SetRange(dLevel, dWindow);
>
> It should be something like this:
>
> m_pLUTAxial->SetRange(dLevel - 0.5*dWindow, dLevel + 0.5*dWindow);
>
> - David
>
>
> On Fri, May 13, 2016 at 1:22 AM, Flaviu2 <flaviu2 at yahoo.com> wrote:
>
> This is a little pseudocode of the entire pipeline:
>
> vtkDICOMReader* m_pDICOMReader = vtkDICOMReader::New();
> m_pDICOMReader->RemoveAllInputs();
> vtkDICOMApplyRescale* m_pRescale = vtkDICOMApplyRescale::New();
> m_pDICOMReader->SetFileNames(pFN); // all files from serie
> m_pDICOMReader->AutoRescaleOff();
> m_pDICOMReader->Update();
> m_pRescale->SetInputConnection(m_pDICOMReader->GetOutputPort());
> m_pRescale->Update();
> vtkImageReslice* m_pResliceAxial = vtkImageReslice::New();
> m_pResliceAxial->SetInputConnection(m_pRescale->GetOutputPort());
> vtkLookupTable* m_pLUTAxial = vtkLookupTable::New();
> m_pLUTAxial->SetValueRange(0.0, 1.0); // from black to white
> m_pLUTAxial->SetSaturationRange(0.0, 0.0); // no color saturation
> vtkDICOMMetaData* pMeta = m_pDICOMReader->GetMetaData();
> const vtkDICOMValue& window = pMeta->GetAttributeValue(DC::WindowWidth);
> const vtkDICOMValue& level = pMeta->GetAttributeValue(DC::WindowCenter);
> double dWindow = window.AsDouble();
> double dLevel = level.AsDouble();
> m_pLUTAxial->SetRange(dLevel, dWindow); // image intensity range
> m_pLUTAxial->SetRampToLinear();
> m_pLUTAxial->Build();
> vtkImageMapToColors* m_pColorAxial = vtkImageMapToColors::New();
> m_pColorAxial->SetLookupTable(m_pLUTAxial);
> m_pColorAxial->SetInputConnection(m_pResliceAxial->GetOutputPort());
> vtkImageActor* m_pImageActor = vtkImageActor::New();
> // and then, forward, setup m_pColorAxial to an image actor:
>
> pImageActor->GetMapper()->SetInputConnection(m_pColorAxial->GetOutputPort());
> // and add image actor to a renderer
> m_pRenderer->AddActor(m_pImageActor);
>
>
> 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 ?
>
> Flaviu.
>
>
>
>
>
> Since you're already using vtk-dicom, you can use vtkDICOMApplyRescale
> to convert your CT image to Hounsfield units (if you use this filter, you
> should
> also call AutoRescaleOff() on the reader).
>
> After the image has been converted to Hounsfield units, you can use the
> "Window Center" and "Window Width" presets that are stored in the meta
> data to set the range for the lookup table.
>
> However, I usually ignore these presets, and instead use the VTK class
> vtkImageHistogramStatistics to compute the range. Its GetAutoRange()
> computes a range by doing some simple histogram analysis.
>
> If you enjoy doing a lot of reading, the relevant parts the DICOM standard
> are here:
>
> http://dicom.nema.org/MEDICAL/Dicom/current/output/chtml/part03/sect_C.11.html
>
> After the image goes through vtkImageMapToColors, how are you
> rendering it?
>
> - David
>
>
>
>
>
>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160519/1cec0b33/attachment.html>
More information about the vtkusers
mailing list