[vtkusers] vtkResliceImageViewer: changing Window/Level contrast question

Daniel Mirota dan at cs.jhu.edu
Wed Apr 24 08:21:21 EDT 2013


Hi, Audrius,

I have run into the same issue as well.  I know this is solved in CTK
or Slicer.  I'm just not too sure where.  I've been skimming through
the source but haven't tracked down the exact lines of code that fix
this yet.  Perhaps the Slicer folks could help.  I've added their list
to the email.

Dan

On Mon, Jan 14, 2013 at 12:50 AM, Audrius Stundzia
<audrius at tomographix.com> wrote:
> 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();
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>



More information about the vtkusers mailing list