X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=filters%2FclitkVFResampleGenericFilter.cxx;h=2cd6b7d58de51940ce383925687bbf9535c96345;hb=dcf1b58a69fbd464fb447bf4bddef182d1a2dfd4;hp=554f3a2800d57e95048733a8de349d2ab814da27;hpb=0b7c9b1e1215634b02cbd38d4e4ba101d6111ba8;p=clitk.git diff --git a/filters/clitkVFResampleGenericFilter.cxx b/filters/clitkVFResampleGenericFilter.cxx index 554f3a2..2cd6b7d 100644 --- a/filters/clitkVFResampleGenericFilter.cxx +++ b/filters/clitkVFResampleGenericFilter.cxx @@ -1,7 +1,7 @@ /*========================================================================= Program: vv http://www.creatis.insa-lyon.fr/rio/vv - Authors belong to: + Authors belong to: - University of LYON http://www.universite-lyon.fr/ - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr @@ -23,7 +23,7 @@ * @author David Sarrut * @date 23 Feb 2008 08:37:53 - * @brief + * @brief -------------------------------------------------------------------*/ @@ -31,7 +31,8 @@ //-------------------------------------------------------------------- clitk::VFResampleGenericFilter::VFResampleGenericFilter(): - clitk::ImageToImageGenericFilter("VFResample") { + clitk::ImageToImageGenericFilter("VFResample") +{ InitializeImageType<2>(); InitializeImageType<3>(); InitializeImageType<4>(); @@ -45,7 +46,8 @@ clitk::VFResampleGenericFilter::VFResampleGenericFilter(): //-------------------------------------------------------------------- template -void clitk::VFResampleGenericFilter::InitializeImageType() { +void clitk::VFResampleGenericFilter::InitializeImageType() +{ ADD_IMAGE_TYPE(Dim, float); } //-------------------------------------------------------------------- @@ -53,28 +55,30 @@ void clitk::VFResampleGenericFilter::InitializeImageType() { //-------------------------------------------------------------------- template -void clitk::VFResampleGenericFilter::UpdateWithInputImageType() { +void clitk::VFResampleGenericFilter::UpdateWithInputImageType() +{ - if (mNbOfComponents == 1) { + if (m_NbOfComponents == 1) { std::cerr << "Error, only one components ? Use clitkImageResample instead." << std::endl; exit(0); } typedef typename ImageType::PixelType PixelType; - if (mNbOfComponents == 2) Update_WithDimAndPixelTypeAndComponent(); - if (mNbOfComponents == 3) Update_WithDimAndPixelTypeAndComponent(); - if (mNbOfComponents == 4) Update_WithDimAndPixelTypeAndComponent(); + if (m_NbOfComponents == 2) Update_WithDimAndPixelTypeAndComponent(); + if (m_NbOfComponents == 3) Update_WithDimAndPixelTypeAndComponent(); + if (m_NbOfComponents == 4) Update_WithDimAndPixelTypeAndComponent(); } //-------------------------------------------------------------------- //-------------------------------------------------------------------- template -void clitk::VFResampleGenericFilter::Update_WithDimAndPixelTypeAndComponent() { +void clitk::VFResampleGenericFilter::Update_WithDimAndPixelTypeAndComponent() +{ // Reading input typedef itk::Vector DisplacementType; typedef itk::Image< DisplacementType, Dim > ImageType; - typename ImageType::Pointer input = clitk::readImage(mInputFilenames, mIOVerbose); + typename ImageType::Pointer input = clitk::readImage(m_InputFilenames, m_IOVerbose); // Main filter typename ImageType::Pointer outputImage = ComputeImage(input); @@ -86,8 +90,9 @@ void clitk::VFResampleGenericFilter::Update_WithDimAndPixelTypeAndComponent() { //-------------------------------------------------------------------- template -typename ImageType::Pointer -clitk::VFResampleGenericFilter::ComputeImage(typename ImageType::Pointer inputImage) { +typename ImageType::Pointer +clitk::VFResampleGenericFilter::ComputeImage(typename ImageType::Pointer inputImage) +{ // Check options static unsigned int dim = ImageType::ImageDimension; @@ -114,7 +119,7 @@ clitk::VFResampleGenericFilter::ComputeImage(typename ImageType::Pointer inputIm // Create Image Filter typedef itk::VectorResampleImageFilter FilterType; typename FilterType::Pointer filter = FilterType::New(); - + // Instance of the transform object to be passed to the resample // filter. By default, identity transform is applied typedef itk::AffineTransform TransformType; @@ -138,18 +143,16 @@ clitk::VFResampleGenericFilter::ComputeImage(typename ImageType::Pointer inputIm // Select interpolator if (mInterpolatorName == "nn") { - typedef itk::VectorNearestNeighborInterpolateImageFunction InterpolatorType; + typedef itk::VectorNearestNeighborInterpolateImageFunction InterpolatorType; typename InterpolatorType::Pointer interpolator = InterpolatorType::New(); filter->SetInterpolator(interpolator); - } - else { + } else { if (mInterpolatorName == "linear") { - typedef itk::VectorLinearInterpolateImageFunction InterpolatorType; + typedef itk::VectorLinearInterpolateImageFunction InterpolatorType; typename InterpolatorType::Pointer interpolator = InterpolatorType::New(); filter->SetInterpolator(interpolator); - } - else { - std::cerr << "Sorry, I do not know the interpolator (for vector field) '" << mInterpolatorName + } else { + std::cerr << "Sorry, I do not know the interpolator (for vector field) '" << mInterpolatorName << "'. Known interpolators are : nn, linear" << std::endl; exit(0); } @@ -172,50 +175,52 @@ clitk::VFResampleGenericFilter::ComputeImage(typename ImageType::Pointer inputIm else gaussianFilters[i]->SetInput(gaussianFilters[i-1]->GetOutput()); } filter->SetInput(gaussianFilters[ImageType::ImageDimension-1]->GetOutput()); - } - else { + } else { filter->SetInput(inputImage); } // Go ! - try { + try { filter->Update(); - } - catch( itk::ExceptionObject & err ) { - std::cerr << "Error while filtering " << mInputFilenames[0].c_str() - << " " << err << std::endl; + } catch( itk::ExceptionObject & err ) { + std::cerr << "Error while filtering " << m_InputFilenames[0].c_str() + << " " << err << std::endl; exit(0); } // Return result return filter->GetOutput(); - + } //-------------------------------------------------------------------- //-------------------------------------------------------------------- -void clitk::VFResampleGenericFilter::SetOutputSize(const std::vector & size) { +void clitk::VFResampleGenericFilter::SetOutputSize(const std::vector & size) +{ mOutputSize.resize(size.size()); std::copy(size.begin(), size.end(), mOutputSize.begin()); } //-------------------------------------------------------------------- //-------------------------------------------------------------------- -void clitk::VFResampleGenericFilter::SetOutputSpacing(const std::vector & spacing) { +void clitk::VFResampleGenericFilter::SetOutputSpacing(const std::vector & spacing) +{ mOutputSpacing.resize(spacing.size()); std::copy(spacing.begin(), spacing.end(), mOutputSpacing.begin()); } //-------------------------------------------------------------------- //-------------------------------------------------------------------- -void clitk::VFResampleGenericFilter::SetInterpolationName(const std::string & inter) { +void clitk::VFResampleGenericFilter::SetInterpolationName(const std::string & inter) +{ mInterpolatorName = inter; } //-------------------------------------------------------------------- //-------------------------------------------------------------------- -void clitk::VFResampleGenericFilter::SetGaussianSigma(const std::vector & sigma) { +void clitk::VFResampleGenericFilter::SetGaussianSigma(const std::vector & sigma) +{ mApplyGaussianFilterBefore = true; mSigma.resize(sigma.size()); std::copy(sigma.begin(), sigma.end(), mSigma.begin());