#include <itkImageFileReader.h>
#include <itkImageSeriesReader.h>
#include <itkImageToVTKImageFilter.h>
-#include <itkAnalyzeImageIO.h>
-#include <itkVectorCastImageFilter.h>
+#include <itkFlexibleVectorCastImageFilter.h>
#include <vtkTransform.h>
void vvImageReader::UpdateWithDim(std::string InputPixelType)
{
if (mType == VECTORFIELD || mType == VECTORFIELDWITHTIME)
- UpdateWithDimAndInputVectorPixelType<itk::Vector<float,VImageDimension>,VImageDimension>();
+ {
+ if (VImageDimension == 4)
+ UpdateWithDimAndInputVectorPixelType<itk::Vector<float,3>,VImageDimension>();
+ else
+ UpdateWithDimAndInputVectorPixelType<itk::Vector<float,VImageDimension>,VImageDimension>();
+ }
else if (InputPixelType == "short")
UpdateWithDimAndInputPixelType<short,VImageDimension>();
else if (InputPixelType == "unsigned_short")
template<class InputPixelType, unsigned int VImageDimension>
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
mLastError = error.str();
return;
}
- analyzeImageIO = dynamic_cast<itk::AnalyzeImageIO*>( reader->GetImageIO() );
}
} else if (mType == SLICED) {
mImage=vvImage::New();
<< "(slice #" << mSlice << ") " << err << std::endl;
return;
}
- analyzeImageIO = dynamic_cast<itk::AnalyzeImageIO*>( reader->GetImageIO() );
} else {
if (mInputFilenames.size() > 1) {
typedef itk::Image< InputPixelType, VImageDimension > InputImageType;
mLastError = error.str();
return;
}
- analyzeImageIO = dynamic_cast<itk::AnalyzeImageIO*>( 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();
}
}
}
template<class InputPixelType, unsigned int VImageDimension>
void vvImageReader::UpdateWithDimAndInputVectorPixelType()
{
- itk::AnalyzeImageIO *analyzeImageIO = NULL;
-
typedef itk::Image< InputPixelType, VImageDimension > InputImageType;
typename InputImageType::Pointer input;
mLastError = error.str();
return;
}
- analyzeImageIO = dynamic_cast<itk::AnalyzeImageIO*>( reader->GetImageIO() );
}
-
+
typedef itk::Image< itk::Vector<float , 3>, VImageDimension > VectorImageType;
- typedef itk::VectorCastImageFilter<InputImageType, VectorImageType> CasterType;
+ typedef itk::FlexibleVectorCastImageFilter<InputImageType, VectorImageType> CasterType;
typename VectorImageType::Pointer casted_input;
typename CasterType::Pointer caster = CasterType::New();
caster->SetInput(input);
+ caster->Update();
casted_input = caster->GetOutput();
-
+
mImage = vvImageFromITK<VImageDimension, itk::Vector<float, 3> >(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();
- }
- }
}
//----------------------------------------------------------------------------