+/*=========================================================================
+ Program: vv http://www.creatis.insa-lyon.fr/rio/vv
+
+ 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
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the copyright notices for more information.
+
+ It is distributed under dual licence
+
+ - BSD See included LICENSE.txt file
+ - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+======================================================================-====*/
/**
-------------------------------------------------------------------
* @file clitkImageResampleGenericFilter.cxx
* @author David Sarrut <David.Sarrut@creatis.insa-lyon.fr>
* @date 23 Feb 2008 08:37:53
/**
-------------------------------------------------------------------
* @file clitkImageResampleGenericFilter.cxx
* @author David Sarrut <David.Sarrut@creatis.insa-lyon.fr>
* @date 23 Feb 2008 08:37:53
-------------------------------------------------------------------*/
#include "clitkImageResampleGenericFilter.h"
-------------------------------------------------------------------*/
#include "clitkImageResampleGenericFilter.h"
+// itk include
+#include "itkImage.h"
+#include "itkImageFileReader.h"
+#include "itkImageSeriesReader.h"
+#include "itkImageFileWriter.h"
+#include "itkRecursiveGaussianImageFilter.h"
+#include "itkResampleImageFilter.h"
+#include "itkAffineTransform.h"
+#include "itkNearestNeighborInterpolateImageFunction.h"
+#include "itkLinearInterpolateImageFunction.h"
+#include "itkBSplineInterpolateImageFunction.h"
+#include "itkBSplineInterpolateImageFunctionWithLUT.h"
+#include "itkCommand.h"
+
//--------------------------------------------------------------------
clitk::ImageResampleGenericFilter::ImageResampleGenericFilter():
//--------------------------------------------------------------------
clitk::ImageResampleGenericFilter::ImageResampleGenericFilter():
mApplyGaussianFilterBefore = false;
mDefaultPixelValue = 0.0;
mInterpolatorName = "NN";
mApplyGaussianFilterBefore = false;
mDefaultPixelValue = 0.0;
mInterpolatorName = "NN";
-void clitk::ImageResampleGenericFilter::InitializeImageTypeWithDim() {
- ADD_IMAGE_TYPE(Dim, char);
- ADD_IMAGE_TYPE(Dim, short);
- ADD_IMAGE_TYPE(Dim, int);
- ADD_IMAGE_TYPE(Dim, float);
+void clitk::ImageResampleGenericFilter::InitializeImageTypeWithDim()
+{
+ ADD_DEFAULT_IMAGE_TYPES(Dim);
}
//--------------------------------------------------------------------
//--------------------------------------------------------------------
template<class InputImageType>
}
//--------------------------------------------------------------------
//--------------------------------------------------------------------
template<class InputImageType>
// Create Image Filter
typedef itk::ResampleImageFilter<InputImageType,InputImageType> FilterType;
typename FilterType::Pointer filter = FilterType::New();
// Create Image Filter
typedef itk::ResampleImageFilter<InputImageType,InputImageType> 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<double, InputImageType::ImageDimension> TransformType;
// Instance of the transform object to be passed to the resample
// filter. By default, identity transform is applied
typedef itk::AffineTransform<double, InputImageType::ImageDimension> TransformType;
typename InterpolatorType::Pointer interpolator = InterpolatorType::New();
filter->SetInterpolator(interpolator);
typename InterpolatorType::Pointer interpolator = InterpolatorType::New();
filter->SetInterpolator(interpolator);
typename InterpolatorType::Pointer interpolator = InterpolatorType::New();
filter->SetInterpolator(interpolator);
typename InterpolatorType::Pointer interpolator = InterpolatorType::New();
filter->SetInterpolator(interpolator);
- typedef itk::BSplineInterpolateImageFunction<InputImageType, double> InterpolatorType;
- typename InterpolatorType::Pointer interpolator = InterpolatorType::New();
- interpolator->SetSplineOrder(mBSplineOrder);
- filter->SetInterpolator(interpolator);
- }
- else {
- if (mInterpolatorName == "blut") {
- typedef itk::BSplineInterpolateImageFunctionWithLUT<InputImageType, double> InterpolatorType;
- typename InterpolatorType::Pointer interpolator = InterpolatorType::New();
- interpolator->SetSplineOrder(mBSplineOrder);
- interpolator->SetLUTSamplingFactor(mSamplingFactors[0]);
- filter->SetInterpolator(interpolator);
- }
- else {
- std::cerr << "Sorry, I do not know the interpolator '" << mInterpolatorName
- << "'. Known interpolators are : nn, linear, bspline, blut" << std::endl;
- exit(0);
- }
+ typedef itk::BSplineInterpolateImageFunction<InputImageType, double> InterpolatorType;
+ typename InterpolatorType::Pointer interpolator = InterpolatorType::New();
+ interpolator->SetSplineOrder(mBSplineOrder);
+ filter->SetInterpolator(interpolator);
+ } else {
+ if (mInterpolatorName == "blut") {
+ typedef itk::BSplineInterpolateImageFunctionWithLUT<InputImageType, double> InterpolatorType;
+ typename InterpolatorType::Pointer interpolator = InterpolatorType::New();
+ interpolator->SetSplineOrder(mBSplineOrder);
+ interpolator->SetLUTSamplingFactor(mSamplingFactors[0]);
+ filter->SetInterpolator(interpolator);
+ } else {
+ std::cerr << "Sorry, I do not know the interpolator '" << mInterpolatorName
+ << "'. Known interpolators are : nn, linear, bspline, blut" << std::endl;
+ exit(0);
+ }
else gaussianFilters[i]->SetInput(gaussianFilters[i-1]->GetOutput());
}
filter->SetInput(gaussianFilters[InputImageType::ImageDimension-1]->GetOutput());
else gaussianFilters[i]->SetInput(gaussianFilters[i-1]->GetOutput());
}
filter->SetInput(gaussianFilters[InputImageType::ImageDimension-1]->GetOutput());
- }
- 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 " << mInputFilenames[0].c_str()
+ << " " << err << std::endl;
mOutputSize.resize(size.size());
std::copy(size.begin(), size.end(), mOutputSize.begin());
}
//--------------------------------------------------------------------
//--------------------------------------------------------------------
mOutputSize.resize(size.size());
std::copy(size.begin(), size.end(), mOutputSize.begin());
}
//--------------------------------------------------------------------
//--------------------------------------------------------------------
mOutputSpacing.resize(spacing.size());
std::copy(spacing.begin(), spacing.end(), mOutputSpacing.begin());
}
//--------------------------------------------------------------------
//--------------------------------------------------------------------
mOutputSpacing.resize(spacing.size());
std::copy(spacing.begin(), spacing.end(), mOutputSpacing.begin());
}
//--------------------------------------------------------------------
//--------------------------------------------------------------------
mInterpolatorName = inter;
}
//--------------------------------------------------------------------
//--------------------------------------------------------------------
mInterpolatorName = inter;
}
//--------------------------------------------------------------------
//--------------------------------------------------------------------
mApplyGaussianFilterBefore = true;
mSigma.resize(sigma.size());
std::copy(sigma.begin(), sigma.end(), mSigma.begin());
mApplyGaussianFilterBefore = true;
mSigma.resize(sigma.size());
std::copy(sigma.begin(), sigma.end(), mSigma.begin());