[vtkusers] About sharing window/level values of vtkimageactor from 2D and 3D viewers
Waldo Valenzuela
waldo.valenzuela at hotmail.com
Thu Jul 2 11:57:39 EDT 2015
Hi guys,
I am having a problem to shared the values of window/level between a image actor of 2D viewer and 3D viewer, with the same values on both the colour image are different.
I create the vtkimageactor like this:
// Create a greyscale lookup table
vtkSmartPointer<vtkLookupTable> table =
vtkSmartPointer<vtkLookupTable>::New();
table->SetRange(0, 255); // image intensity range
table->SetValueRange(0.0, 1.0); // from black to white
table->SetSaturationRange(0.0, 0.0); // no color saturation
table->SetRampToLinear();
table->Build();
m_imagemaper = VTKImageMapToWindowLevelColors::New();
m_imagemaper->SetLookupTable(table);
m_imagemaper->SetInputConnection(resliceimage->GetOutputPort());
m_imagemaper->Update();
VTKImageActor m_imageactor3D = VTKImageActor::New();
#if VTK_MAJOR_VERSION <= 5
m_imageactor3D->SetInput(resliceimage->GetOutput());
#else
m_imageactor3D->SetInputData(resliceimage->GetOutput());
#endif
m_imageactor3D->GetMapper()->SetInputConnection(m_imagemaper->GetOutputPort());
m_imageactor3D->Update();
VTKImageActor m_imageactor2D = VTKImageActor::New();
#if VTK_MAJOR_VERSION <= 5
m_imageactor2D->SetInput(resliceimage->GetOutput());
#else
m_imageactor2D->SetInputData(resliceimage->GetOutput());
#endif
m_imageactor2D->GetMapper()->SetInputConnection(m_imagemaper->GetOutputPort());
m_imageactor2D->Update();
For 2D visualisation I set the interactor style to vtkInteractorStyleImage.
and 3D visualisation I set the interactor to vtkInteractorStyleTrackballCamera.
After, from the 2D viewer a get the window/level values like this:
double window = this->CurrentImageProperty->GetColorWindow();
double level = this->CurrentImageProperty->GetColorLevel();
and set this values to 3D visualisation:
vtkImageMapToWindowLevelColors *mapper = vtkImageMapToWindowLevelColors::SafeDownCast(m_imageactor3D->GetMapper()->GetInputAlgorithm());
if (mapper) {
mapper->SetLevel(level);
mapper->SetWindow(window);
mapper->Update();
}
But the problem is that colour (brightness and contrast) from 2D viewer is different from 3D viewer. I attached a screenshot of the problem.
I really appreciate any help on this problem.
Cheers,
Waldo.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20150702/93f7b68e/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 3Dview.png
Type: image/png
Size: 91704 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20150702/93f7b68e/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 2Dview.png
Type: image/png
Size: 26205 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20150702/93f7b68e/attachment-0003.png>
More information about the vtkusers
mailing list