X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=common%2FvvImageReader.txx;h=3ef04c6e0487f9b6bcec51e294e4f3075a6032e0;hb=3f1a99051165ef065b28fdf25b9fdecefdaca4af;hp=e15e6d7688ff4a6a202e8f9e62bd42d133128ca5;hpb=cc2f3e22307a2ddb835c4ae15dbe5302a143653f;p=clitk.git diff --git a/common/vvImageReader.txx b/common/vvImageReader.txx index e15e6d7..3ef04c6 100644 --- a/common/vvImageReader.txx +++ b/common/vvImageReader.txx @@ -23,8 +23,7 @@ #include #include #include -#include -#include +#include #include @@ -36,7 +35,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") @@ -68,8 +72,6 @@ void vvImageReader::UpdateWithDim(std::string InputPixelType) template void vvImageReader::UpdateWithDimAndInputPixelType() { - itk::AnalyzeImageIO *analyzeImageIO = NULL; - if (mType == MERGEDWITHTIME) // In this case we can load the images // one at the time to avoid excessive // memory use @@ -92,7 +94,6 @@ void vvImageReader::UpdateWithDimAndInputPixelType() mLastError = error.str(); return; } - analyzeImageIO = dynamic_cast( reader->GetImageIO() ); } } else if (mType == SLICED) { mImage=vvImage::New(); @@ -129,7 +130,6 @@ void vvImageReader::UpdateWithDimAndInputPixelType() << "(slice #" << mSlice << ") " << err << std::endl; return; } - analyzeImageIO = dynamic_cast( reader->GetImageIO() ); } else { if (mInputFilenames.size() > 1) { typedef itk::Image< InputPixelType, VImageDimension > InputImageType; @@ -172,22 +172,6 @@ void vvImageReader::UpdateWithDimAndInputPixelType() mLastError = error.str(); return; } - analyzeImageIO = dynamic_cast( reader->GetImageIO() ); - } - } - - // For unknown analyze orientations, we set identity - if(analyzeImageIO) { - const double m[16] = {1.,0.,0.,0., - 0.,0.,1.,0., - 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++); - 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(); } } } @@ -197,8 +181,6 @@ void vvImageReader::UpdateWithDimAndInputPixelType() template void vvImageReader::UpdateWithDimAndInputVectorPixelType() { - itk::AnalyzeImageIO *analyzeImageIO = NULL; - typedef itk::Image< InputPixelType, VImageDimension > InputImageType; typename InputImageType::Pointer input; @@ -233,35 +215,17 @@ void vvImageReader::UpdateWithDimAndInputVectorPixelType() mLastError = error.str(); return; } - 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 - if (analyzeImageIO) - { - const double m[16] = {1.,0.,0.,0., - 0.,0.,1.,0., - 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++) - ; - 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(); - } - } } //----------------------------------------------------------------------------