[vtkusers] No LookupTable was set but input data is not VTK_UNSIGNED_CHAR

Flaviu2 flaviu2 at yahoo.com
Fri May 20 08:08:25 EDT 2016


Hi David.Because of your excellent explanation, I have found my mistake ... after I had setup WL correctly on LUT on vtkImageMapToColors, I had taken these values, and setup vtkImageActor WL.
Here is the code that I had used:
// read the CT
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());
// setup LUT
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 - 0.5 * dWindow, dLevel + 0.5 * dWindow); // image intensity range
m_pLUTAxial->SetRampToLinear();
m_pLUTAxial->Build();
vtkImageMapToColors* m_pColorAxial = vtkImageMapToColors::New();
m_pColorAxial->SetLookupTable(m_pLUTAxial);     // setup LUT
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);
// setup the actor WL with original values - my misake - that is why the image was whiter
m_pImageActor->GetProperty()->SetColorWindow(dWindow);  // !! these are lines that I have removed 
m_pImageActor->GetProperty()->SetColorLevel(dLevel);    // !! these are lines that I have removed
Now everything are working well.
"And the values (W: 80, L: 35) that are shown on the image... where do they come from?"
These values are coming from the original DICOM images, and it has been taken like this:
void CMyDoc::GetOriginalWindowLevel(double& dWindow, double& dLevel, BOOL bUpdateReader/* = FALSE*/)
{
 if(NULL == m_pDICOMReader)
  return;
 if(bUpdateReader)
  m_pDICOMReader->Update();
 vtkDICOMMetaData* pMeta = m_pDICOMReader->GetMetaData();
 const vtkDICOMValue& window = pMeta->GetAttributeValue(DC::WindowWidth);
 const vtkDICOMValue& level = pMeta->GetAttributeValue(DC::WindowCenter);
 dWindow = window.AsDouble();
 dLevel = level.AsDouble();
}


"but you posted code, and an output image that the code produced.  So I am confused.  Did the code crash?  Or did it just display an error message?"
In the code case without using LUT, the program has started, and shown images like the original ones ... but after few image handling (zooming, moving, etc.) the program was crashed. All time when I handling the image (before crash, of course), the debugger shows me the error like in the post title: "No LookupTable was set but input data is not VTK_UNSIGNED_CHAR".
One thing is sure: without your help, I would didn't make it ! I really appreciate your help ! Kindly thank you David !
Flaviu.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160520/b3cb8592/attachment.html>


More information about the vtkusers mailing list