]> Creatis software - bbtk.git/commitdiff
1493 Bug
authorEduardo Davila <Eduardo.Davila@creatis.insa-lyon.fr>
Mon, 9 Jul 2012 13:02:42 +0000 (13:02 +0000)
committerEduardo Davila <Eduardo.Davila@creatis.insa-lyon.fr>
Mon, 9 Jul 2012 13:02:42 +0000 (13:02 +0000)
 Image Planes:
    view orientation

packages/vtk/src/bbvtkImagePlanes.cxx
packages/vtk/src/bbvtkImagePlanes.h

index 746492a6d566cd691a9823989f6f67a89dc4d343..426189b031cf5d428edce3cc1b4cb5235d4d22d3 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbvtkImagePlanes.cxx,v $
   Language:  C++
-  Date:      $Date: 2012/07/04 08:38:21 $
-  Version:   $Revision: 1.36 $
+  Date:      $Date: 2012/07/09 13:02:42 $
+  Version:   $Revision: 1.37 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
 #include "bbstdRelay.h"
 
 #include "vtkObjectFactory.h"
+#include "vtkImageFlip.h"
 
+#include "vtkImageReslice.h"
+#include "vtkImageChangeInformation.h"
 
 namespace bbstd
 {
@@ -136,7 +139,7 @@ namespace bbvtk
  };
   //================================================================
 
-  //vtkCxxRevisionMacro(ImagePlanes::VtkCallbackType, "$Revision: 1.36 $");
+  //vtkCxxRevisionMacro(ImagePlanes::VtkCallbackType, "$Revision: 1.37 $");
 
   //================================================================
 
@@ -196,12 +199,39 @@ namespace bbvtk
      vtkImagePlaneWidget* planeWidget3Pts = GetPlaneWidget('3', 0, 1, 1, picker);       
      planeWidget3Pts->SetLookupTable(planeWidgetX->GetLookupTable());
 
+          // EED MPR view orientation correction..
+     vtkImageFlip  *flipYFilter = vtkImageFlip::New();
+     flipYFilter->SetFilteredAxis(1); // flip y axis
+     flipYFilter->SetInput( planeWidgetX->GetResliceOutput() );
+     flipYFilter->Update();
+
+          vtkImageChangeInformation *image = vtkImageChangeInformation::New();
+          image->SetInput(  planeWidgetY->GetResliceOutput()  );
+          image->SetOutputSpacing( 1,1,1 );       
+          image->CenterImageOn();
+          image->Update();
+          _imageTransform = vtkTransform::New();
+          vtkImageReslice *slicer =vtkImageReslice::New();
+          slicer->SetInput( image->GetOutput() );
+          slicer->SetInformationInput( image->GetOutput() );
+          slicer->SetResliceTransform( _imageTransform );
+          slicer->SetOutputOrigin(0 , 0 , 0 );
+          slicer->SetInterpolationModeToNearestNeighbor();
+          slicer->Update();       
+          vtkImageChangeInformation *imageResult = vtkImageChangeInformation::New();
+          imageResult->SetInput( slicer->GetOutput() );
+          double spc[3];
+           planeWidgetY->GetResliceOutput()->GetSpacing(spc);
+          imageResult->SetOutputSpacing( spc[1], spc[0], spc[2] ); 
+          imageResult->SetOutputOrigin( 0,0,0 ); 
+                  
+          
      bbSetOutputPlaneX(planeWidgetX);
      bbSetOutputPlaneY(planeWidgetY);
      bbSetOutputPlaneZ(planeWidgetZ);
      bbSetOutputPlane3Pts(planeWidget3Pts);     
-     bbSetOutputImageX(planeWidgetX->GetResliceOutput());
-     bbSetOutputImageY(planeWidgetY->GetResliceOutput());
+     bbSetOutputImageX( flipYFilter->GetOutput() );            // EED MPR view orientation correction..
+     bbSetOutputImageY( imageResult->GetOutput() );                    // EED MPR view orientation correction..
      bbSetOutputImageZ(planeWidgetZ->GetResliceOutput());
      bbSetInputInteractor(0);
      //bbSetOutputImage3Pts(planeWidget3Pts->GetResliceOutput());
@@ -244,16 +274,28 @@ namespace bbvtk
 //---------------------------------------------------------------------  
   void ImagePlanes::Process()
   {
+         
        if (bbGetInputIn()!=0)
        {
-               int xMin, xMax, yMin, yMax, zMin, zMax;
-               bbGetInputIn()->GetExtent(xMin, xMax, yMin, yMax, zMin, zMax);
-
+               int dim[3];
+               int ext[6];
+               bbGetOutputPlaneX()->GetResliceOutput()->GetWholeExtent(ext);
+               dim[0] = ext[1]-ext[0]+1;
+               dim[1] = ext[3]-ext[2]+1;
+               dim[2] = ext[5]-ext[4]+1;
+               _imageTransform->Identity();
+               _imageTransform->PostMultiply();
+               _imageTransform->Translate( (int)(-(dim[0]/2)) , (int)(-(dim[1]/2)) ,0);
+               _imageTransform->RotateZ(90);
+               
+               
                if ( image != bbGetInputIn()){//bbGetInputStatus("In") != bbtk::UPTODATE ){
                        // Input image has changed : reinitialize planes
                        image = bbGetInputIn();                 
 
                        // Initial values : center of the volume (in real world, not in pixels!)
+                       int xMin, xMax, yMin, yMax, zMin, zMax;
+                       bbGetInputIn()->GetExtent(xMin, xMax, yMin, yMax, zMin, zMax);
                        double xSpacing, ySpacing, zSpacing;
                        bbGetInputIn()->GetSpacing(xSpacing, ySpacing, zSpacing);
 
@@ -277,24 +319,33 @@ namespace bbvtk
                        {
                                bbGetOutputPlaneZ()->SetWindowLevel(bbGetInputWindowLevel()[0],
                                                                bbGetInputWindowLevel()[1]);
-                       }
-                       else 
-                       {
+                       } else {
                                double *range = image->GetScalarRange();
                                bbGetOutputPlaneZ()->SetWindowLevel(range[1]-range[0],
                                                               0.5*(range[1]+range[0]));
-                       }
+                       } // windowlevel
                        updateInteractor();
-          }
+                       
+                       dim[0] = xMax-xMin+1;
+                       dim[1] = yMax-yMin+1;
+                       dim[2] = zMax-zMin+1;
+                       _imageTransform->Identity();
+                       _imageTransform->PostMultiply();
+                       _imageTransform->Translate( (int)(-(dim[0]/2)*(1/xSpacing)) , (int)(-(dim[2]/2)*(1/zSpacing)) ,0);
+                       _imageTransform->RotateZ(90);
+                       
+          } // image
+               
                        // UPDATE DES SORTIES 
                bbGetOutputPlaneX()->SetResliceInterpolate( bbGetInputInterpolation() );
                bbGetOutputPlaneY()->SetResliceInterpolate( bbGetInputInterpolation() );
                bbGetOutputPlaneZ()->SetResliceInterpolate( bbGetInputInterpolation() );
+
                
                bbGetOutputPlaneX()->GetResliceOutput()->Update();
                bbGetOutputPlaneY()->GetResliceOutput()->Update(); 
                bbGetOutputPlaneZ()->GetResliceOutput()->Update();               
-
+               
                std::vector<int> pointsx = bbGetInputPointsX();
                std::vector<int> pointsy = bbGetInputPointsY();
                std::vector<int> pointsz = bbGetInputPointsZ();
index 3f0c3a8a6d7105b6807ee9f7f0b8049b2921cc1e..778748d430737252d033d59452e96fdfd5dc4a9d 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbvtkImagePlanes.h,v $
   Language:  C++
-  Date:      $Date: 2012/07/04 08:38:21 $
-  Version:   $Revision: 1.23 $
+  Date:      $Date: 2012/07/09 13:02:45 $
+  Version:   $Revision: 1.24 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
@@ -89,6 +89,10 @@ namespace bbvtk
     BBTK_PROCESS(Process);
     void Process();
     
+         
+       vtkTransform *_imageTransform;
+
+         
   protected:
 
   private: