X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=common%2FvvImageReader.txx;h=9b0e21ae6c17f8fd498008272c53fa84a9aaaa5c;hb=dd6976090ab45c4ac8e483355851e4d35c828259;hp=e15e6d7688ff4a6a202e8f9e62bd42d133128ca5;hpb=89a782167f649e3667519233c30ec11c759c23b2;p=clitk.git diff --git a/common/vvImageReader.txx b/common/vvImageReader.txx index e15e6d7..9b0e21a 100644 --- a/common/vvImageReader.txx +++ b/common/vvImageReader.txx @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include @@ -36,7 +36,12 @@ template void vvImageReader::UpdateWithDim(std::string InputPixelType) { if (mType == VECTORFIELD || mType == VECTORFIELDWITHTIME) - UpdateWithDimAndInputVectorPixelType,VImageDimension>(); + { + if (VImageDimension == 4) + UpdateWithDimAndInputVectorPixelType,VImageDimension>(); + else + UpdateWithDimAndInputVectorPixelType,VImageDimension>(); + } else if (InputPixelType == "short") UpdateWithDimAndInputPixelType(); else if (InputPixelType == "unsigned_short") @@ -182,12 +187,13 @@ void vvImageReader::UpdateWithDimAndInputPixelType() 0.,0.,1.,0., 0.,-1.,0.,0., 0.,0.,0.,1.}; + // TODO SR and BP: check on the list of transforms and not the first only int i; - for(i=0; i<16 && m[i]==mImage->GetTransform()->GetMatrix()->GetElement(i%4, i/4); i++); + for(i=0; i<16 && m[i]==mImage->GetTransform()[0]->GetMatrix()->GetElement(i%4, i/4); i++); if(i==16) { itkWarningMacro(<< "Analyze image file format detected with unknown orientation. " << "Forcing identity orientation, use other file format if not ok."); - mImage->GetTransform()->Identity(); + mImage->GetTransform()[0]->Identity(); } } } @@ -235,14 +241,15 @@ void vvImageReader::UpdateWithDimAndInputVectorPixelType() } analyzeImageIO = dynamic_cast( reader->GetImageIO() ); } - + typedef itk::Image< itk::Vector, VImageDimension > VectorImageType; - typedef itk::VectorCastImageFilter CasterType; + typedef itk::FlexibleVectorCastImageFilter CasterType; typename VectorImageType::Pointer casted_input; typename CasterType::Pointer caster = CasterType::New(); caster->SetInput(input); + caster->Update(); casted_input = caster->GetOutput(); - + mImage = vvImageFromITK >(casted_input, mType == IMAGEWITHTIME || mType == VECTORFIELDWITHTIME); // For unknown analyze orientations, we set identity @@ -253,13 +260,13 @@ void vvImageReader::UpdateWithDimAndInputVectorPixelType() 0.,-1.,0.,0., 0.,0.,0.,1.}; int i; - for (i = 0; i < 16 && m[i] == mImage->GetTransform()->GetMatrix()->GetElement(i % 4, i / 4); i++) + for (i = 0; i < 16 && m[i] == mImage->GetTransform()[0]->GetMatrix()->GetElement(i % 4, i / 4); i++) ; if (i == 16) { itkWarningMacro(<< "Analyze image file format detected with unknown orientation. " << "Forcing identity orientation, use other file format if not ok."); - mImage->GetTransform()->Identity(); + mImage->GetTransform()[0]->Identity(); } } }