[vtkusers] vtkResliceImageViewer: changing Window/Level contrast question
Audrius Stundzia
audrius at tomographix.com
Mon Jan 14 00:50:25 EST 2013
Hello vtk users,
Have run into a problem/puzzle with regards to the Window/Level
adjustment settings in vtkResliceImageViewer.
[It's a very useful class, btw, so thanks to it's developers.]
I've attached 2 example images that illustrate the issue. PET as the
effect is most dramatic ;-)
The same issue occurs for other modalities: MR and CT.
The code [relevant fragment is below] reads the DICOM data and displays
it as expected [re PT_before.jpg].
However, when the left mouse button is pressed and the icon is moved,
rather then the expected minor change
in the Window/Level settings, there is a very large change [re
PT_after.jpg].
So,
Is there something missing or wrong from the code below?
Is the Window/Level change functionality missing
from vtkResliceImageViewer?
Is there a callback that I need to add? If so, is there a sample code
fragment somewhere?
Any insight would be appreciated.
Audrius
OS: Windows 7 x64
vtk: 5.10.1
compiler: VS 2008 version 9 [x64]
Code fragment:
vtkSmartPointer<vtkGDCMImageReader> imageReader =
vtkSmartPointer<vtkGDCMImageReader>::New();
// . . . gets the DICOM data here
// Scalar image data display
vtkSmartPointer<vtkResliceImageViewer> resliceImageViewer =
vtkSmartPointer<vtkResliceImageViewer>::New();
resliceImageViewer->SetInput( imageReader->GetOutput()); //
std::string dicomModality =
imageReader->GetMedicalImageProperties()->GetModality();
if( dicomModality == "PT" ||
dicomModality == "NM" ||
dicomModality == "ST" )
{
std::cout << "DICOM modality: " << dicomModality << std::endl;
double window;
double level;
imageReader->GetMedicalImageProperties()->GetNthWindowLevelPreset (
0, &window, &level );
// A colour map of {r, g, b} triplets
boost::scoped_ptr<aRainbowColourMap> rainbowColourMapPtr(new
aRainbowColourMap);
const vtkIdType nColours =
static_cast<vtkIdType>(rainbowColourMapPtr->GetNColours()); // 256
colours
vtkSmartPointer<vtkWindowLevelLookupTable> windowLevelLookupTable =
vtkSmartPointer<vtkWindowLevelLookupTable>::New();
windowLevelLookupTable->SetWindow( window);
windowLevelLookupTable->SetLevel( level);
windowLevelLookupTable->SetNumberOfTableValues( nColours);
for( vtkIdType iC = 0; iC < nColours; ++iC)
{
double r; double g; double b;
rainbowColourMapPtr->GetRGB( iC, r, g, b );
windowLevelLookupTable->SetTableValue( iC, r, g, b, 1.0 );
}
windowLevelLookupTable->SetRampToLinear();
windowLevelLookupTable->Build();
resliceImageViewer->SetLookupTable( windowLevelLookupTable);
}
else
if( dicomModality == "MR" )
{
// . . . Analogous code for MR here
}
else
if( dicomModality == "CT" )
{
// . . . Analogous code for CT here
}
vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
// Callback functions
// 1/ Close and exit vtk window
vtkSmartPointer<vtkCallbackCommand> keypressCallback =
vtkSmartPointer<vtkCallbackCommand>::New();
keypressCallback->SetCallback( KeypressCallbackFunction);
renderWindowInteractor->AddObserver( vtkCommand::KeyPressEvent,
keypressCallback );
resliceImageViewer->SetupInteractor( renderWindowInteractor);
// Initialize rendering and interaction
resliceImageViewer->GetRenderWindow()->SetSize( 900, 900 );
resliceImageViewer->GetRenderer()->SetBackground( 0.0, 0.0, 0.0 );
resliceImageViewer->GetRenderer()->ResetCamera();
resliceImageViewer->SliceScrollOnMouseWheelOn();
resliceImageViewer->Render();
renderWindowInteractor->Initialize();
renderWindowInteractor->Start();
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130114/fa81371c/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PT_before.jpg
Type: image/jpeg
Size: 55367 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130114/fa81371c/attachment.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PT_after.jpg
Type: image/jpeg
Size: 82751 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130114/fa81371c/attachment-0001.jpg>
More information about the vtkusers
mailing list