X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=common%2FvvImageReader.cxx;h=ddc4ad3833ae2e60050fee3debd5c58e106ee4c7;hb=4288e22b0855b6c201333256629238795536032b;hp=c795cd9299697c7a34c784c1973541c7012e777d;hpb=bec6f659babc742382ca007b53800e7305fa298f;p=clitk.git diff --git a/common/vvImageReader.cxx b/common/vvImageReader.cxx index c795cd9..ddc4ad3 100644 --- a/common/vvImageReader.cxx +++ b/common/vvImageReader.cxx @@ -77,13 +77,13 @@ void vvImageReader::Update(int dim,std::string inputPixelType, LoadedImageType t switch(mDim) { case 2: UpdateWithDim<2>(mInputPixelType); - break;; + break; case 3: UpdateWithDim<3>(mInputPixelType); - break;; + break; case 4: UpdateWithDim<4>(mInputPixelType); - break;; + break; default: std::cerr << "dimension unknown in Update ! " << std::endl; } @@ -161,7 +161,15 @@ void vvImageReader::ReadMatImageTransform() if(f.is_open()) { f.close(); - itk::Matrix itkMat = clitk::ReadMatrix3D(filename); + itk::Matrix itkMat; + itkMat.SetIdentity(); + try { + itkMat = clitk::ReadMatrix3D(filename); + } + catch (itk::ExceptionObject & err) { + itkWarningMacro(<< "Found " << filename + << " but this is not a 4x4 matrix so it is ignored."); + } vtkSmartPointer matrix = vtkSmartPointer::New(); matrix->Identity(); @@ -193,9 +201,21 @@ void vvImageReader::ReadMatImageTransform() } // TODO SR and BP: check on the list of transforms and not the first only - mImage->GetTransform()[0]->PostMultiply(); + mImage->GetTransform()[0]->PreMultiply(); mImage->GetTransform()[0]->Concatenate(matrix); mImage->GetTransform()[0]->Update(); + + //for image sequences, apply the transform to each images of the sequence + if (mImage->IsTimeSequence()) + { + for (unsigned i = 1 ; iGetTransform().size() ; i++) + { + mImage->GetTransform()[i]->PreMultiply(); + mImage->GetTransform()[i]->Concatenate(matrix); + mImage->GetTransform()[i]->Update(); + } + } + } } //------------------------------------------------------------------------------