From 6cbf5222a1eec625da8f4633094bfa8e0d9da967 Mon Sep 17 00:00:00 2001 From: dsarrut Date: Thu, 22 Jul 2010 09:23:38 +0000 Subject: [PATCH] move into tools --- filters/clitkResampleImage.ggo | 28 --- filters/clitkResampleImageGenericFilter.h | 67 ------- filters/clitkResampleImageGenericFilter.txx | 185 -------------------- 3 files changed, 280 deletions(-) delete mode 100644 filters/clitkResampleImage.ggo delete mode 100644 filters/clitkResampleImageGenericFilter.h delete mode 100644 filters/clitkResampleImageGenericFilter.txx diff --git a/filters/clitkResampleImage.ggo b/filters/clitkResampleImage.ggo deleted file mode 100644 index 491f366..0000000 --- a/filters/clitkResampleImage.ggo +++ /dev/null @@ -1,28 +0,0 @@ -#File clitkImageResample.ggo -package "clitkImageResample" -version "2.0" -purpose "Resample an image. You can specify the interpolation, you can apply a Gaussian filter before (automated if downsample)." - -section "Common" -option "config" - "Config file" string no -option "verbose" v "Verbose" flag off -option "imagetypes" - "Verbose: allowed image types" flag off -option "thread" - "Nb of thread to use (default=max)" int no - -section "Input & Output options" -option "input" i "Input image filename" string yes -option "output" o "Output image filename" string yes -option "like" l "Resample like this image" string no -option "size" - "Number of pixels of each coordonate" int no multiple default="0" -option "spacing" - "Spacing in mm between pixels" float no multiple default="-1.0" -option "default" d "Default pixel value" float no default = "0.0" -option "time" t "Last Dimension Is Time -> do not resample it (auto on for 4D)" flag off - -section "Interpolation" -option "interp" - "Interpolation type: {nn, linear, bspline, blut}" string no default="nn" -option "order" b "BSpline ordre (range 0-5)" int no default="3" -option "sampling" s "BLUT sampling value" int no default="30" - -section "Gaussian filtering" -option "gauss" g "Apply Gaussian before (sigma in mm)" float no multiple default="0.0" -option "autogauss" a "Apply Gaussian with auto sigma when downsample" flag off diff --git a/filters/clitkResampleImageGenericFilter.h b/filters/clitkResampleImageGenericFilter.h deleted file mode 100644 index 34cd791..0000000 --- a/filters/clitkResampleImageGenericFilter.h +++ /dev/null @@ -1,67 +0,0 @@ -/*========================================================================= - 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 -======================================================================-====*/ - -#ifndef CLITKIRESAMPLEIMAGEGENERICFILTER_H -#define CLITKIRESAMPLEIMAGEGENERICFILTER_H - -// clitk include -#include "clitkImageToImageGenericFilter.h" - -namespace clitk { - - //-------------------------------------------------------------------- - template - class ITK_EXPORT ResampleImageGenericFilter: - public ImageToImageGenericFilter > { - - public: - // Constructor - ResampleImageGenericFilter(); - - // Types - typedef ResampleImageGenericFilter Self; - typedef itk::SmartPointer Pointer; - typedef itk::SmartPointer ConstPointer; - - // New - itkNewMacro(Self); - - // Args - void SetArgsInfo(const args_info_type & a); - - // Main function - template void UpdateWithInputImageType(); - - protected: - args_info_type mArgsInfo; - template void InitializeImageType(); - - }; // end class ResampleImageGenericFilter - //-------------------------------------------------------------------- - -} // end namespace clitk -//-------------------------------------------------------------------- - -//-------------------------------------------------------------------- -#ifndef ITK_MANUAL_INSTANTIATION -#include "clitkResampleImageGenericFilter.txx" -#endif -//-------------------------------------------------------------------- - -#endif /* end #define CLITKIRESAMPLEIMAGEGENERICFILTER_H */ - diff --git a/filters/clitkResampleImageGenericFilter.txx b/filters/clitkResampleImageGenericFilter.txx deleted file mode 100644 index 5e08d4a..0000000 --- a/filters/clitkResampleImageGenericFilter.txx +++ /dev/null @@ -1,185 +0,0 @@ -/*========================================================================= - 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 - ======================================================================-====*/ - -#ifndef CLITKRESAMPLEIMAGEGENERICFILTER_TXX -#define CLITKRESAMPLEIMAGEGENERICFILTER_TXX - -// clitk -#include "clitkResampleImageWithOptionsFilter.h" - -//-------------------------------------------------------------------- -template -clitk::ResampleImageGenericFilter::ResampleImageGenericFilter(): - ImageToImageGenericFilter("Resample") -{ - InitializeImageType<2>(); - InitializeImageType<3>(); - InitializeImageType<4>(); -} -//-------------------------------------------------------------------- - - -//-------------------------------------------------------------------- -template -template -void clitk::ResampleImageGenericFilter::InitializeImageType() -{ - ADD_DEFAULT_IMAGE_TYPES(Dim); - //ADD_IMAGE_TYPE(Dim, short); -} -//-------------------------------------------------------------------- - - -//-------------------------------------------------------------------- -template -void clitk::ResampleImageGenericFilter::SetArgsInfo(const args_info_type & a) -{ - mArgsInfo=a; - if (mArgsInfo.imagetypes_flag) this->PrintAvailableImageTypes(); - SetIOVerbose(mArgsInfo.verbose_flag); - if (mArgsInfo.input_given) { - SetInputFilename(mArgsInfo.input_arg); - } - if (mArgsInfo.output_given) { - SetOutputFilename(mArgsInfo.output_arg); - } -} -//-------------------------------------------------------------------- - - -//-------------------------------------------------------------------- -// Update with the number of dimensions and the pixeltype -//-------------------------------------------------------------------- -template -template -void -clitk::ResampleImageGenericFilter::UpdateWithInputImageType() -{ - - // Reading input - typename InputImageType::Pointer input = this->template GetInput(0); - - // Main filter - typedef typename InputImageType::PixelType PixelType; - typedef InputImageType OutputImageType; // to change to float is user ask it (?) - - // Filter - typedef clitk::ResampleImageWithOptionsFilter ResampleImageFilterType; - typename ResampleImageFilterType::Pointer filter = ResampleImageFilterType::New(); - filter->SetInput(input); - - // Set Verbose - filter->SetVerboseOptions(mArgsInfo.verbose_flag); - - // Set size / spacing - static const unsigned int dim = OutputImageType::ImageDimension; - typename OutputImageType::SpacingType spacing; - typename OutputImageType::SizeType size; - - if (mArgsInfo.like_given) { - DD("like"); - - } - else { - if (mArgsInfo.spacing_given == 1) { - filter->SetOutputIsoSpacing(mArgsInfo.spacing_arg[0]); - } else { - if ((mArgsInfo.spacing_given != 0) && (mArgsInfo.size_given != 0)) { - std::cerr << "Error: use spacing or size, not both." << std::endl; - exit(0); - } - - if (!((mArgsInfo.spacing_given == 0) && (mArgsInfo.size_given == 0))) { - - if ((mArgsInfo.spacing_given != 0) && (mArgsInfo.spacing_given != dim)) { - std::cerr << "Error: spacing should have one or " << dim << " values." << std::endl; - exit(0); - } - if ((mArgsInfo.size_given != 0) && (mArgsInfo.size_given != dim)) { - std::cerr << "Error: size should have " << dim << " values." << std::endl; - exit(0); - } - if (mArgsInfo.spacing_given) - for(unsigned int i=0; iSetOutputSpacing(spacing); - filter->SetOutputSize(size); - } - } - } - - // Set temporal dimension - filter->SetLastDimensionIsTime(mArgsInfo.time_flag); - - // Set Gauss - filter->SetGaussianFilteringEnabled(mArgsInfo.autogauss_flag); - if (mArgsInfo.gauss_given != 0) { - typename ResampleImageFilterType::GaussianSigmaType g; - for(unsigned int i=0; iSetGaussianSigma(g); - } - - // Set Interpolation - std::string interp = std::string(mArgsInfo.interp_arg); - if (interp == "nn") { - filter->SetInterpolationType(ResampleImageFilterType::NearestNeighbor); - } else { - if (interp == "linear") { - filter->SetInterpolationType(ResampleImageFilterType::Linear); - } else { - if (interp == "bspline") { - filter->SetInterpolationType(ResampleImageFilterType::BSpline); - } else { - if (interp == "blut") { - filter->SetInterpolationType(ResampleImageFilterType::B_LUT); - } else { - if (interp == "windowed sinc") { - filter->SetInterpolationType(ResampleImageFilterType::WSINC); - } else { - std::cerr << "Error. I do not know interpolation '" << mArgsInfo.interp_arg - << "'. Choose among: nn, linear, bspline, blut, windowed sinc" << std::endl; - exit(0); - } - } - } - } - } - - // Set default pixel value - filter->SetDefaultPixelValue(mArgsInfo.default_arg); - - // Set thread - if (mArgsInfo.thread_given) { - filter->SetNumberOfThreads(mArgsInfo.thread_arg); - } - - // Go ! - filter->Update(); - typename OutputImageType::Pointer outputImage = filter->GetOutput(); - this->template SetNextOutput(outputImage); -} -//-------------------------------------------------------------------- - - -#endif /* end #define CLITKRESAMPLEIMAGEGENERICFILTER_TXX */ - -- 2.47.1