#include <itkCenteredEuler3DTransform.h>
#include <itkRecursiveGaussianImageFilter.h>
#include "clitkElastix.h"
+#include "clitkResampleImageWithOptionsFilter.h"
namespace clitk
{
reader->Update();
typename InputImageType::Pointer input= reader->GetOutput();
+ //Adaptative size, spacing origin (use previous clitkResampleImage)
+ if (m_ArgsInfo.adaptive_given) {
+ // Filter
+ typedef clitk::ResampleImageWithOptionsFilter<InputImageType, OutputImageType> ResampleImageFilterType;
+ typename ResampleImageFilterType::Pointer filter = ResampleImageFilterType::New();
+ filter->SetInput(input);
+
+ // Set Verbose
+ filter->SetVerboseOptions(m_ArgsInfo.verbose_flag);
+
+ // Set size / spacing
+ static const unsigned int dim = OutputImageType::ImageDimension;
+ typename OutputImageType::SpacingType spacing;
+ typename OutputImageType::SizeType size;
+ typename OutputImageType::PointType origin;
+ typename OutputImageType::DirectionType direction;
+
+ if (m_ArgsInfo.like_given) {
+ itk::ImageIOBase::Pointer header = clitk::readImageHeader(m_ArgsInfo.like_arg);
+ if (header) {
+ for(unsigned int i=0; i<dim; i++){
+ spacing[i] = header->GetSpacing(i);
+ size[i] = header->GetDimensions(i);
+ origin[i] = header->GetOrigin(i);
+ }
+ for(unsigned int i=0; i<dim; i++) {
+ for(unsigned int j=0;j<dim;j++) {
+ direction(i,j) = header->GetDirection(i)[j];
+ }
+ }
+ filter->SetOutputSpacing(spacing);
+ filter->SetOutputSize(size);
+ filter->SetOutputOrigin(origin);
+ filter->SetOutputDirection(direction);
+ }
+ else {
+ std::cerr << "*** Warning : I could not read '" << m_ArgsInfo.like_arg << "' ***" << std::endl;
+ exit(0);
+ }
+ }
+ else {
+ if (m_ArgsInfo.spacing_given == 1) {
+ filter->SetOutputIsoSpacing(m_ArgsInfo.spacing_arg[0]);
+ }
+ else if ((m_ArgsInfo.spacing_given != 0) && (m_ArgsInfo.size_given != 0)) {
+ std::cerr << "Error: use spacing or size, not both." << std::endl;
+ exit(0);
+ }
+ else if (m_ArgsInfo.spacing_given) {
+ if ((m_ArgsInfo.spacing_given != 0) && (m_ArgsInfo.spacing_given != dim)) {
+ std::cerr << "Error: spacing should have one or " << dim << " values." << std::endl;
+ exit(0);
+ }
+ for(unsigned int i=0; i<dim; i++)
+ spacing[i] = m_ArgsInfo.spacing_arg[i];
+ filter->SetOutputSpacing(spacing);
+ }
+ else if (m_ArgsInfo.size_given) {
+ if ((m_ArgsInfo.size_given != 0) && (m_ArgsInfo.size_given != dim)) {
+ std::cerr << "Error: size should have " << dim << " values." << std::endl;
+ exit(0);
+ }
+ for(unsigned int i=0; i<dim; i++)
+ size[i] = m_ArgsInfo.size_arg[i];
+ filter->SetOutputSize(size);
+ }
+ for(unsigned int i=0; i<dim; i++){
+ origin[i] = input->GetOrigin()[i];
+ }
+ for(unsigned int i=0; i<dim; i++) {
+ for(unsigned int j=0;j<dim;j++) {
+ direction(i,j) = input->GetDirection()[i][j];
+ }
+ }
+ filter->SetOutputOrigin(origin);
+ filter->SetOutputDirection(direction);
+ }
+
+ // Set temporal dimension
+ //filter->SetLastDimensionIsTime(m_ArgsInfo.time_flag);
+
+ // Set Gauss
+ filter->SetGaussianFilteringEnabled(m_ArgsInfo.autogauss_flag);
+ if (m_ArgsInfo.gauss_given != 0) {
+ typename ResampleImageFilterType::GaussianSigmaType g;
+ for(unsigned int i=0; i<dim; i++) {
+ g[i] = m_ArgsInfo.gauss_arg[i];
+ }
+ filter->SetGaussianSigma(g);
+ }
+
+ // Set Interpolation
+ int interp = m_ArgsInfo.interp_arg;
+ if (interp == 0) {
+ filter->SetInterpolationType(ResampleImageFilterType::NearestNeighbor);
+ } else {
+ if (interp == 1) {
+ filter->SetInterpolationType(ResampleImageFilterType::Linear);
+ } else {
+ if (interp == 2) {
+ filter->SetInterpolationType(ResampleImageFilterType::BSpline);
+ } else {
+ if (interp == 3) {
+ filter->SetInterpolationType(ResampleImageFilterType::B_LUT);
+ } else {
+ std::cerr << "Error. I do not know interpolation '" << m_ArgsInfo.interp_arg
+ << "'. Choose among: nn, linear, bspline, blut, windowed sinc" << std::endl;
+ exit(0);
+ }
+ }
+ }
+ }
+
+ // Set default pixel value
+ filter->SetDefaultPixelValue(m_ArgsInfo.pad_arg);
+
+ // Set thread
+ //if (m_ArgsInfo.thread_given) {
+ // filter->SetNumberOfThreads(m_ArgsInfo.thread_arg);
+ //}
+
+ // Go !
+ filter->Update();
+ typename OutputImageType::Pointer output = filter->GetOutput();
+ //this->template SetNextOutput<OutputImageType>(outputImage);
+
+ // Output
+ typedef itk::ImageFileWriter<OutputImageType> WriterType;
+ typename WriterType::Pointer writer = WriterType::New();
+ writer->SetFileName(m_ArgsInfo.output_arg);
+ writer->SetInput(output);
+ writer->Update();
+
+ return;
+ }
+
//Gaussian pre-filtering
typename itk::Vector<double, Dimension> gaussianSigma;
gaussianSigma.Fill(0);