#include <itkImageFileReader.h>
#include "vvImageReader.h"
#include "vvImageReader.txx"
+#include "clitkTransformUtilities.h"
//------------------------------------------------------------------------------
vvImageReader::vvImageReader()
}
if (bRead) {
- double mat[16];
-
//Transpose matrix (NKI format)
for(int j=0; j<4; j++)
for(int i=0; i<4; i++)
- mat[4*j+i]=readerTransfo->GetOutput()->GetBufferPointer()[4*i+j];
+ mImage->GetTransform()->GetMatrix()->SetElement(j,i,readerTransfo->GetOutput()->GetBufferPointer()[4*i+j]);
//From cm to mm
for(int i=0; i<3; i++)
- mat[4*i+3]*=10;
+ mImage->GetTransform()->GetMatrix()->SetElement(i,3,10*mImage->GetTransform()->GetMatrix()->GetElement(i,3));
+
+ mImage->GetTransform()->Inverse();
+ mImage->UpdateReslice();
+ }
+}
+//------------------------------------------------------------------------------
- //Set Transformation
- vtkSmartPointer<vtkTransform> pt = vtkSmartPointer<vtkTransform>::New();
- pt->SetMatrix( mat );
- pt->Inverse();
- mImage->SetTransform( pt );
+
+//------------------------------------------------------------------------------
+//Read transformation in ASCII format
+void vvImageReader::ReadMatImageTransform()
+{
+ std::string filename(mInputFilenames[0]+".mat");
+ std::ifstream f(filename.c_str());
+ if(f.is_open()) {
+ f.close();
+
+ itk::Matrix<double, 4, 4> itkMat = clitk::ReadMatrix3D(filename);
+ for(int j=0; j<4; j++)
+ for(int i=0; i<4; i++)
+ mImage->GetTransform()->GetMatrix()->SetElement(j,i,itkMat[j][i]);
+ mImage->UpdateReslice();
}
}
//------------------------------------------------------------------------------
else
std::cerr << "Error, input pixel type : " << InputPixelType << " unknown !" << std::endl;
- if (CLITK_EXPERIMENTAL)
- if (mLastError.size()==0)
- ReadNkiImageTransform();
+ if (CLITK_EXPERIMENTAL && mLastError.size()==0) {
+ ReadNkiImageTransform();
+ ReadMatImageTransform();
+ }
}
//----------------------------------------------------------------------------