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
{
};
//================================================================
- //vtkCxxRevisionMacro(ImagePlanes::VtkCallbackType, "$Revision: 1.36 $");
+ //vtkCxxRevisionMacro(ImagePlanes::VtkCallbackType, "$Revision: 1.37 $");
//================================================================
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());
//---------------------------------------------------------------------
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);
{
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();