[vtkusers] Need help on vtkImageReslice, Why I can not get the image of Sagittal and coronal plane?

Liang Ma leo at esit.com
Fri Apr 17 16:57:08 EDT 2009


Hi all,



I am trying to display a set of Dicom images from MRI. I want display them in axial Sagittal and coronal plane. I read files by vtkDICOMImageReader, and tried to use  vtkImageReslice. But I only succeed in the axial display. For Sagittal and coronal plane, What I got is only black.  Who know the reasom? I try to feed the output of realice1 to viewer2 and viewer3, there are images. So it seems that vtkImageReslices for these two plane do not work at all. is it the problem of  no set the original of the reader? Please help me. The code is attached below. Thanks



Regards



Leo





// vtkDICOMImageReader read dicom files

            vtkDICOMImageReader *reader2= vtkDICOMImageReader::New();

            reader2->SetDirectoryName("E://FSPGR_3D"); 

            reader2->SetDataSpacing(1,1,1);

            reader2->Update();

 

 

// axial reslice

    t1=vtkTransform::New();      

        t1->RotateX(0);

        t1->RotateY(0);

        t1->RotateZ(0);

 

            res1=vtkImageReslice::New();

            res1->SetInputConnection(reader2-> GetOutputPort());

              res1->SetResliceTransform (t1);

              res1->InterpolateOn();

              res1->SetInterpolationModeToCubic(); 

              res1->SetBackgroundLevel(1023);

//Set viewer

    viewer1 = vtkImageViewer::New();

              viewer1->SetInput(res1->GetOutput());

              viewer1->SetColorWindow(255);

              viewer1->SetColorLevel(127);

              viewer1->SetZSlice(0);

              viewer1->SetPosition(3,3);

              

//////////////////////////////////////////////////////////////////////////////////////////////

// Sagittal reslice

   t2=vtkTransform::New();       

             t2->RotateX(90);

            t2->RotateY(0);

            t2->RotateZ(0);

 

            res2=vtkImageReslice::New();

            res2->SetOutputDimensionality(3);

              res2->SetInputConnection(reader2-> GetOutputPort());

              res2->SetResliceTransform(t2);

              res2->InterpolateOn();

              res2->SetInterpolationModeToCubic(); 

              res2->SetBackgroundLevel(0);

 

    viewer2 = vtkImageViewer::New();

              viewer2->SetInput(res2->GetOutput());

              viewer2->SetColorWindow(255);

              viewer2->SetColorLevel(127);

              int max=viewer2->GetWholeZMax ();

              int min=viewer2->GetWholeZMin ();

              viewer2->SetZSlice((max+min)/2);

              viewer2->SetPosition(268,8);

////////////////////////////////////////////////////////////////////////////

    t3=vtkTransform::New();      

        t3->RotateX(0);

            t3->RotateY(90);

            t3->RotateZ(90);

 

            res3=vtkImageReslice::New();

            res3->SetOutputDimensionality(3);

              res3->SetInputConnection(reader2-> GetOutputPort());

              res3->SetResliceTransform (t3);

              res3->InterpolateOn();

              res3->SetInterpolationModeToCubic(); 

              res3->SetBackgroundLevel(0);

 

    viewer3 = vtkImageViewer::New();

              viewer3->SetInput(res3->GetOutput());

              viewer3->SetColorWindow(255);

              viewer3->SetColorLevel(127);

              max=viewer3->GetWholeZMax ();

              min=viewer3->GetWholeZMin ();

              viewer3->SetZSlice((max+min)/2);

              viewer3->SetPosition(3,268);

///////////////////////////////////////////////////////////////////////////////////////////////////////

 

            

            iren1 = vtkWin32RenderWindowInteractor::New();

      viewer1->SetupInteractor(iren1);

 

            iren2 = vtkWin32RenderWindowInteractor::New();

      viewer2->SetupInteractor(iren2);

 

            iren3 = vtkWin32RenderWindowInteractor::New();

      viewer3->SetupInteractor(iren3);

 

            picker=vtkCellPicker::New();

    //picker->SetTolerance(0.00001);

            

            vtkCallbackCommand * cmd = vtkCallbackCommand::New();

            cmd->SetCallback(CVTK::MyExecute);

            cmd->SetClientData( this );

            picker->AddObserver(vtkCommand::EndPickEvent, cmd);

 

            iren1->SetPicker(picker);

            iren2->SetPicker(picker);

            iren3->SetPicker(picker);

            cmd->Delete();             
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090417/fb889707/attachment.htm>


More information about the vtkusers mailing list