X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vv%2FvvImageReader.cxx;h=25e235a08edb3b713b347b5a5a1147aaed7fb061;hb=ff1d5b8af965e75ecdbc1b0cbff0dad6f3b3c511;hp=593ef7018e34eab3071db24c531e6ba9a1c814ac;hpb=647a6322e7d8f4c456bfe56414d8d9a879fb7f3a;p=clitk.git diff --git a/vv/vvImageReader.cxx b/vv/vvImageReader.cxx index 593ef70..25e235a 100644 --- a/vv/vvImageReader.cxx +++ b/vv/vvImageReader.cxx @@ -173,8 +173,27 @@ void vvImageReader::ReadMatImageTransform() for(int i=0; i<4; i++) matrix->SetElement(j,i,itkMat[j][i]); + // RP: 14/03/2011 + // For some reason, the transformation matrix given in the MHD + // file is inverted wrt the transformation given in the MAT file. + // We don't really know where the inversion takes place inside + // VTK or ITK. For what we could see in VV, the transformation + // given in the MHD file seems "more correct" than that given in + // the MAT file. For this reason, we invert the matrix read from + // the MAT file before concatenating it to the current transformation. + // Still, it would be nice to find out what happens exactly between + // VTK and ITK... + // + vtkSmartPointer inv_matrix = vtkSmartPointer::New(); + if (matrix->Determinant() == 0) + { + vtkGenericWarningMacro("Matrix in " << filename.c_str() << " cannot be inverted (determinant = 0)"); + } + else + matrix->Invert(*matrix, *inv_matrix); + mImage->GetTransform()->PostMultiply(); - mImage->GetTransform()->Concatenate(matrix); + mImage->GetTransform()->Concatenate(inv_matrix); mImage->GetTransform()->Update(); } }