X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=common%2FvvImageReader.txx;h=2d7d5b573f3c9a2985bfef023c21f4a542c53537;hb=4f6aadc0552db99c03057d4aa40a7fc4a1697350;hp=7607ab3a43cf27fc6b90c06ac926775b3f116e72;hpb=1c3533dee871b6d396c91c07f6c73a0dc46b2cd3;p=clitk.git diff --git a/common/vvImageReader.txx b/common/vvImageReader.txx index 7607ab3..2d7d5b5 100644 --- a/common/vvImageReader.txx +++ b/common/vvImageReader.txx @@ -34,7 +34,7 @@ template void vvImageReader::UpdateWithDim(std::string InputPixelType) { - if (mType == VECTORFIELD) + if (mType == VECTORFIELD || mType == VECTORFIELDWITHTIME) UpdateWithDimAndInputPixelType,VImageDimension>(); else if (InputPixelType == "short") UpdateWithDimAndInputPixelType(); @@ -67,7 +67,7 @@ void vvImageReader::UpdateWithDim(std::string InputPixelType) template void vvImageReader::UpdateWithDimAndInputPixelType() { - itk::AnalyzeImageIO *analyzeImageIO; + itk::AnalyzeImageIO *analyzeImageIO = NULL; if (mType == MERGEDWITHTIME) // In this case we can load the images // one at the time to avoid excessive @@ -118,6 +118,9 @@ void vvImageReader::UpdateWithDimAndInputPixelType() filter->SetExtractionRegion(extractedRegion); filter->SetInput(reader->GetOutput()); filter->ReleaseDataFlagOn(); +#if ITK_VERSION_MAJOR == 4 + filter->SetDirectionCollapseToSubmatrix(); +#endif try { mImage->AddItkImage(filter->GetOutput()); } catch ( itk::ExceptionObject & err ) { @@ -136,7 +139,12 @@ void vvImageReader::UpdateWithDimAndInputPixelType() try { if (mType == IMAGEWITHTIME) - mImage=vvImageFromITK(reader->GetOutput(),true); + { + std::cerr << "We should never come here:" << std::endl + << " Calling vvImageReader with multiple images and IMAGEWITHTIME is undefined." << std::endl + << " You are probably looking for MERGEDWITHTIME Type." << std::endl; + return; + } else mImage=vvImageFromITK(reader->GetOutput()); } catch ( itk::ExceptionObject & err ) { @@ -154,7 +162,7 @@ void vvImageReader::UpdateWithDimAndInputPixelType() reader->ReleaseDataFlagOn(); try { - if (mType == IMAGEWITHTIME) + if (mType == IMAGEWITHTIME || mType == VECTORFIELDWITHTIME) mImage=vvImageFromITK(reader->GetOutput(),true); else mImage=vvImageFromITK(reader->GetOutput()); @@ -172,11 +180,14 @@ void vvImageReader::UpdateWithDimAndInputPixelType() // 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.}; + 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; m[i]==mImage->GetTransform()->GetMatrix()->GetElement(i%4, i/4) && i<16; 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." + itkWarningMacro(<< "Analyze image file format detected with unknown orientation. " << "Forcing identity orientation, use other file format if not ok."); mImage->GetTransform()->Identity(); }