+++ /dev/null
-#File clitkBinarizeImage.ggo
-package "clitkBinarizeImage"
-version "1.0"
-purpose ""
-
-option "config" - "Config file" string no
-option "verbose" v "Verbose" flag off
-option "imagetypes" - "Display allowed image types" flag off
-
-option "input" i "Input image filename" string yes
-option "output" o "Output image filename" string yes
-option "lower" l "Lower intensity (default=min), fg is greater than this value" double no
-option "upper" u "Upper intensity (default=max), fg is lower than this value" double no
-
-option "fg" - "Foreground (FG) or 'inside' value" double no default="1"
-option "bg" - "Background (BG) or 'ouside' value" double no default="0"
-option "mode" - "Use FG and/or BG values (if FG, the BG is replaced by the input image values)" values="FG","BG","both" default="both" required
-
+++ /dev/null
-/*=========================================================================
- 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 CLITKBINARIZEIMAGEGENERICFILTER_H
-#define CLITKBINARIZEIMAGEGENERICFILTER_H
-
-#include "clitkIO.h"
-#include "clitkImageToImageGenericFilter.h"
-
-//--------------------------------------------------------------------
-namespace clitk
-{
-
- template<class args_info_type>
- class ITK_EXPORT BinarizeImageGenericFilter:
- public ImageToImageGenericFilter<BinarizeImageGenericFilter<args_info_type> >
- {
-
- public:
-
- //--------------------------------------------------------------------
- BinarizeImageGenericFilter();
-
- //--------------------------------------------------------------------
- typedef BinarizeImageGenericFilter Self;
- typedef itk::SmartPointer<Self> Pointer;
- typedef itk::SmartPointer<const Self> ConstPointer;
-
- //--------------------------------------------------------------------
- // Method for creation through the object factory
- // and Run-time type information (and related methods)
- itkNewMacro(Self);
- itkTypeMacro(BinarizeImageGenericFilter, LightObject);
-
- //--------------------------------------------------------------------
- void SetArgsInfo(const args_info_type & a);
-
- //--------------------------------------------------------------------
- // Main function called each time the filter is updated
- template<class InputImageType>
- void UpdateWithInputImageType();
-
- protected:
- template<unsigned int Dim> void InitializeImageType();
- args_info_type mArgsInfo;
-
- }; // end class
- //--------------------------------------------------------------------
-
-} // end namespace clitk
-//--------------------------------------------------------------------
-
-//--------------------------------------------------------------------
-#ifndef ITK_MANUAL_INSTANTIATION
-#include "clitkBinarizeImageGenericFilter.txx"
-#endif
-//--------------------------------------------------------------------
-
-#endif // #define clitkBinarizeImageGenericFilter_h
+++ /dev/null
-/*=========================================================================
- 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 CLITKBINARIZEIMAGEGENERICFILTER_TXX
-#define CLITKBINARIZEIMAGEGENERICFILTER_TXX
-
-// itk include
-#include "itkBinaryThresholdImageFilter.h"
-#include "itkMaskImageFilter.h"
-#include "itkMaskNegatedImageFilter.h"
-
-#include <clitkCommon.h>
-// #include <tiff.h>
-
-namespace clitk
-{
-
-//--------------------------------------------------------------------
-template<class args_info_type>
-BinarizeImageGenericFilter<args_info_type>::BinarizeImageGenericFilter():
- ImageToImageGenericFilter<Self>("Binarize")
-{
- InitializeImageType<2>();
- InitializeImageType<3>();
- InitializeImageType<4>();
-}
-//--------------------------------------------------------------------
-
-
-//--------------------------------------------------------------------
-template<class args_info_type>
-template<unsigned int Dim>
-void BinarizeImageGenericFilter<args_info_type>::InitializeImageType()
-{
- ADD_DEFAULT_IMAGE_TYPES(Dim);
-}
-//--------------------------------------------------------------------
-
-
-//--------------------------------------------------------------------
-template<class args_info_type>
-void BinarizeImageGenericFilter<args_info_type>::SetArgsInfo(const args_info_type & a)
-{
- mArgsInfo=a;
- SetIOVerbose(mArgsInfo.verbose_flag);
- if (mArgsInfo.imagetypes_flag) this->PrintAvailableImageTypes();
-
- 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<class args_info_type>
-template<class InputImageType>
-void
-BinarizeImageGenericFilter<args_info_type>::UpdateWithInputImageType()
-{
-
- // Reading input
- typename InputImageType::Pointer input = this->template GetInput<InputImageType>(0);
-
- // Main filter
- typedef typename InputImageType::PixelType PixelType;
- typedef itk::Image<uchar, InputImageType::ImageDimension> OutputImageType;
-
- // Filter
- typedef itk::BinaryThresholdImageFilter<InputImageType, OutputImageType> BinaryThresholdImageFilterType;
- typename BinaryThresholdImageFilterType::Pointer thresholdFilter=BinaryThresholdImageFilterType::New();
- thresholdFilter->SetInput(input);
- thresholdFilter->SetInsideValue(mArgsInfo.fg_arg);
-
- if (mArgsInfo.lower_given) thresholdFilter->SetLowerThreshold(static_cast<PixelType>(mArgsInfo.lower_arg));
- if (mArgsInfo.upper_given) thresholdFilter->SetUpperThreshold(static_cast<PixelType>(mArgsInfo.upper_arg));
-
- // DD(mArgsInfo.lower_given);
- // DD(mArgsInfo.upper_given);
- // DD(mArgsInfo.lower_arg);
- // DD(mArgsInfo.upper_arg);
- // DD(mArgsInfo.fg_arg);
- // DD(mArgsInfo.bg_arg);
- // DD(mArgsInfo.fg_given);
- // DD(mArgsInfo.bg_given);
- // DD(mArgsInfo.mode_arg);
-
-// DD(mArgsInfo.useFG_flag);
-// DD(mArgsInfo.useBG_flag);
-
-// thresholdFilter->SetInsideValue(mArgsInfo.fg_arg);
-
-// // Keep BG value to 0 if maskFilterType is used after
-// if (mArgsInfo.useBG_flag && mArgsInfo.useFG_flag) {
-// thresholdFilter->SetOutsideValue(mArgsInfo.bg_arg);
-// }
-// else {
-// DD("0");
-// thresholdFilter->SetOutsideValue(0);
-// }
-
-// // thresholdFilter->Update();
-
-// // If no BG or no FG : new image, copy input with MaskImageFilter
-// // If setFG -> FG BG have been changed
-// if (mArgsInfo.useBG_flag && mArgsInfo.useFG_flag) {
-// =======
- /* Three modes :
- - FG -> only use FG value for pixel in the Foreground (or Inside), keep input values for outside
- - BG -> only use BG value for pixel in the Background (or Outside), keep input values for inside
- - both -> use FG and BG (real binary image)
- */
- if (mArgsInfo.mode_arg == std::string("both")) {
- thresholdFilter->SetOutsideValue(mArgsInfo.bg_arg);
- thresholdFilter->Update();
- //>>>>>>> 1.5
- typename OutputImageType::Pointer outputImage = thresholdFilter->GetOutput();
- this->template SetNextOutput<OutputImageType>(outputImage);
- } else {
- typename InputImageType::Pointer outputImage;
- thresholdFilter->SetOutsideValue(0);
- if (mArgsInfo.mode_arg == std::string("BG")) {
- typedef itk::MaskImageFilter<InputImageType,OutputImageType> maskFilterType;
- typename maskFilterType::Pointer maskFilter = maskFilterType::New();
- maskFilter->SetInput1(input);
- maskFilter->SetInput2(thresholdFilter->GetOutput());
- maskFilter->SetOutsideValue(mArgsInfo.bg_arg);
- maskFilter->Update();
- outputImage = maskFilter->GetOutput();
- } else {
- typedef itk::MaskNegatedImageFilter<InputImageType,OutputImageType> maskFilterType;
- typename maskFilterType::Pointer maskFilter = maskFilterType::New();
- maskFilter->SetInput1(input);
- maskFilter->SetInput2(thresholdFilter->GetOutput());
- maskFilter->SetOutsideValue(mArgsInfo.fg_arg);
- maskFilter->Update();
- outputImage = maskFilter->GetOutput();
- }
- // Write/Save results
- this->template SetNextOutput<InputImageType>(outputImage);
- }
-}
-//--------------------------------------------------------------------
-
-
-}//end clitk
-
-#endif //#define clitkBinarizeImageGenericFilter_txx
+++ /dev/null
-/*=========================================================================
- 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 CLITKIMAGEFILLREGIONGENERICFILTER_CXX
-#define CLITKIMAGEFILLREGIONGENERICFILTER_CXX
-/**
- -------------------------------------------------------------------
- * @file clitkImageFillRegionGenericFilter.cxx
- * @author David Sarrut <David.Sarrut@creatis.insa-lyon.fr>
- * @date 23 Feb 2008
-
- * @brief
- -------------------------------------------------------------------*/
-
-#include "clitkImageFillRegionGenericFilter.h"
-
-//--------------------------------------------------------------------
-clitk::ImageFillRegionGenericFilter::ImageFillRegionGenericFilter():
- clitk::ImageToImageGenericFilter<Self>("ImageFillRegion")
-{
- InitializeImageType<2>();
- InitializeImageType<3>();
- mPixelValue = 0;
- m_IsCentered=false;
- mSphericRegion=false;
-}
-//--------------------------------------------------------------------
-
-
-//--------------------------------------------------------------------
-template<unsigned int Dim>
-void clitk::ImageFillRegionGenericFilter::InitializeImageType()
-{
- // ADD_IMAGE_TYPE(Dim, char);
- ADD_IMAGE_TYPE(Dim, short);
- // ADD_IMAGE_TYPE(Dim, unsigned short);
-// ADD_IMAGE_TYPE(Dim, int);
- ADD_IMAGE_TYPE(Dim, float);
- // ADD_IMAGE_TYPE(Dim, double);
-}
-//--------------------------------------------------------------------
-
-
-
-//--------------------------------------------------------------------
-template<class ImageType>
-void clitk::ImageFillRegionGenericFilter::UpdateWithInputImageType()
-{
-
- // Typedef
- typedef typename ImageType::PixelType PixelType;
- static unsigned int Dim = ImageType::ImageDimension;
-
- // Spheric region
- if (mSphericRegion) return Update_WithDimAndPixelType_SphericRegion<ImageType::ImageDimension,PixelType>();
-
- // Read input
- typename ImageType::Pointer input = GetInput<ImageType>(0);
-
- // Get pixel value in correct type
- PixelType value = PixelTypeDownCast<double, PixelType>(mPixelValue);
-
- // Get region
- typedef typename ImageType::RegionType RegionType;
- typedef typename ImageType::SizeType SizeType;
- typedef typename ImageType::IndexType IndexType;
- RegionType region;
- SizeType size;
- IndexType start;
- for(unsigned int i=0; i<Dim; i++) {
- size[i] = mSize[i];
- start[i] = mStart[i];
- }
- region.SetSize(size);
- region.SetIndex(start);
-
- // Build iterator
- typedef itk::ImageRegionIterator<ImageType> IteratorType;
- IteratorType it(input, region);
- it.GoToBegin();
- while (!it.IsAtEnd()) {
- it.Set(value);
- ++it;
- }
-
- // Write results
- SetNextOutput<ImageType>(input);
-}
-//--------------------------------------------------------------------
-
-//--------------------------------------------------------------------
-template<unsigned int Dim, class PixelType>
-void clitk::ImageFillRegionGenericFilter::Update_WithDimAndPixelType_SphericRegion()
-{
-
- // Read input
- typedef itk::Image<PixelType,Dim> ImageType;
- //typename ImageType::Pointer input = clitk::readImage<ImageType>(mInputFilenames[0], mIOVerbose);
- typename ImageType::Pointer input = GetInput<ImageType>(0);
-
- // Get pixel value in correct type
- PixelType value = PixelTypeDownCast<double, PixelType>(mPixelValue);
-
- // Centered?
- if(m_IsCentered) {
- typename ImageType::SizeType size= input->GetLargestPossibleRegion().GetSize();
- typename ImageType::SpacingType spacing= input->GetSpacing();
- typename ImageType::PointType origin= input->GetOrigin();
- mCenter.resize(Dim);
- for (unsigned int i=0; i<Dim; i++)
- mCenter[i]=origin[i]+(double)size[i]/2*spacing[i];
- }
-
- // Build iterator
- typedef itk::ImageRegionIteratorWithIndex<ImageType> IteratorType;
- IteratorType it(input, input->GetLargestPossibleRegion());
- it.GoToBegin();
-
- typename ImageType::PointType point;
- //typename itk::Vector<double, Dim> distance;
- typename ImageType::IndexType index;
- //bool inside;
- double distance;
-
- while (!it.IsAtEnd()) {
- // inside=true;
- index=it.GetIndex();
- input->TransformIndexToPhysicalPoint(index, point);
- distance=0.0;
- for(unsigned int i=0; i<Dim; i++)
- distance+=powf( ( (mCenter[i]-point[i])/mRadius[i] ), 2);
-
- // inside= ( (fabs(distance[i])<fabs(mRadius[i])) && inside );
- // distance[i]=mCenter[i]-point[i];
- // inside= ( (fabs(distance[i])<fabs(mRadius[i])) && inside );
- // }
-
- if (distance<1)
- it.Set(value);
- ++it;
- }
-
- // Write results
- SetNextOutput<ImageType>(input);
-}
-
-//--------------------------------------------------------------------
-
-
-
-//--------------------------------------------------------------------
-void clitk::ImageFillRegionGenericFilter::SetSphericRegion(std::vector<double> & radius,
- std::vector<double> & center)
-{
- mRadius.clear();
- mRadius.resize(radius.size());
- std::copy(radius.begin(), radius.end(), mRadius.begin());
- mCenter.clear();
- mCenter.resize(center.size());
- std::copy(center.begin(), center.end(), mCenter.begin());
- mSphericRegion = true;
- m_IsCentered=false;
-}
-
-void clitk::ImageFillRegionGenericFilter::SetSphericRegion(std::vector<double> & radius)
-{
- mRadius.clear();
- mRadius.resize(radius.size());
- std::copy(radius.begin(), radius.end(), mRadius.begin());
- m_IsCentered=true;
- mSphericRegion = true;
-}
-//--------------------------------------------------------------------
-
-
-#endif //define CLITKIMAGEFILLREGIONGENERICFILTER_CXX
+++ /dev/null
-/*=========================================================================
- 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 CLITKIMAGEFILLREGIONGENERICFILTER_H
-#define CLITKIMAGEFILLREGIONGENERICFILTER_H
-/**
- -------------------------------------------------------------------
- * @file clitkImageFillRegionGenericFilter.h
- * @author David Sarrut <David.Sarrut@creatis.insa-lyon.fr>
- * @date 23 Feb 2008
- -------------------------------------------------------------------*/
-
-// clitk include
-#include "clitkCommon.h"
-#include "clitkImageCommon.h"
-#include "clitkImageToImageGenericFilter.h"
-
-// itk include
-#include "itkImage.h"
-#include "itkImageIOBase.h"
-#include "itkImageRegionIterator.h"
-#include "itkImageRegionConstIterator.h"
-#include "itkImageRegionIteratorWithIndex.h"
-
-namespace clitk {
-
- //--------------------------------------------------------------------
- class ImageFillRegionGenericFilter:
- public clitk::ImageToImageGenericFilter<ImageFillRegionGenericFilter> {
-
- public:
-
- // Constructor
- ImageFillRegionGenericFilter ();
- ~ImageFillRegionGenericFilter (){;}
-
- // Types
- typedef ImageFillRegionGenericFilter Self;
- typedef itk::SmartPointer<Self> Pointer;
- typedef itk::SmartPointer<const Self> ConstPointer;
-
- // New
- itkNewMacro(Self);
-
- // Set methods
- void SetFillPixelValue (double value) { mPixelValue = value; }
- void SetRegion(int * size, int * start) { mSize = size; mStart = start ; }
- void SetSphericRegion(std::vector<double> & radius, std::vector<double> & center);
- void SetSphericRegion(std::vector<double> & radius);
-
- //--------------------------------------------------------------------
- // Main function called each time the filter is updated
- template<class InputImageType>
- void UpdateWithInputImageType();
-
- protected:
- template<unsigned int Dim> void InitializeImageType();
- double mPixelValue;
- int * mSize;
- int * mStart;
- std::vector<double> mCenter;
- std::vector<double> mRadius;
- bool mSphericRegion;
- bool m_IsCentered;
-
- template<unsigned int Dim, class PixelType> void Update_WithDimAndPixelType_SphericRegion();
-
- }; // end class ImageFillRegionGenericFilter
-//--------------------------------------------------------------------
-
-#include "clitkImageFillRegionGenericFilter.txx"
-
-} // end namespace
-//--------------------------------------------------------------------
-
-#endif //#define CLITKIMAGEFILLREGIONGENERICFILTER_H
-
+++ /dev/null
-#File clitkImageResample.ggo
-package "clitkImageResample"
-version "1.0"
-purpose "Resample an image. You can specify the interpolation, you can apply a Gaussian filter before."
-
-option "config" - "Config file" string no
-option "input" i "Input image filename" string yes
-option "output" o "Output image filename" string yes
-option "verbose" v "Verbose" flag off
-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"
-option "size" - "Number of pixels of each coordonate" int no multiple default="0"
-option "spacing" - "Spacing in mm between pixels" float no multiple default="0.0"
-option "gauss" g "Apply Gaussian before (sigma in mm) ; no Gaussian if not given" float no multiple default="1.0"
-option "default" d "Default pixel value" float no default = "0.0"
-
--- /dev/null
+/*=========================================================================
+ 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 __clitkBackProjectImageFilter_h
+#define __clitkBackProjectImageFilter_h
+#include "clitkTransformUtilities.h"
+
+//itk include
+#include "itkInterpolateImageFunction.h"
+#include "itkImageToImageFilter.h"
+#include "itkTransform.h"
+#include "itkVector.h"
+
+
+namespace clitk
+{
+
+ template <class InputImageType, class OutputImageType>
+ class ITK_EXPORT BackProjectImageFilter :
+ public itk::ImageToImageFilter<InputImageType,OutputImageType>
+ {
+ public:
+ //------------------------------------
+ // Standard itk typedefs
+ //-----------------------------------
+ typedef BackProjectImageFilter Self;
+ typedef itk::ImageToImageFilter<InputImageType,OutputImageType> Superclass;
+ typedef itk::SmartPointer<Self> Pointer;
+ typedef itk::SmartPointer<const Self> ConstPointer;
+
+ /** Method for creation through the object factory. */
+ itkNewMacro(Self);
+
+ /** Run-time type information (and related methods). */
+ itkTypeMacro(BackProjectImageFilter, ImageToImageFilter);
+
+ /** Dimension of the domain space. */
+ itkStaticConstMacro(InputImageDimension, unsigned int, Superclass::InputImageDimension);
+ itkStaticConstMacro(OutputImageDimension, unsigned int, Superclass::OutputImageDimension);
+
+ //------------------------------------
+ // Typedefs
+ //------------------------------------
+ typedef typename InputImageType::Pointer InputImagePointer;
+ typedef typename InputImageType::ConstPointer InputImageConstPointer;
+ typedef typename InputImageType::PixelType InputPixelType;
+ typedef typename InputImageType::SizeType InputSizeType;
+ typedef typename InputImageType::SpacingType InputSpacingType;
+ typedef typename InputImageType::DirectionType InputDirectionType;
+ typedef typename InputImageType::IndexType InputIndexType;
+ typedef typename InputImageType::PointType InputPointType;
+ typedef typename itk::ContinuousIndex<double,InputImageDimension> ContinuousInputIndexType;
+ typedef typename InputImageType::RegionType InputImageRegionType;
+ typedef itk::Vector<double,InputImageDimension+1> HomogeneInputVectorType;
+ typedef itk::Vector<double,InputImageDimension> Homogene2DVectorType;
+ typedef itk::Point<double,InputImageDimension+1> HomogeneInputPointType;
+ typedef itk::Point<double,InputImageDimension> Homogene2DPointType;
+
+ typedef typename OutputImageType::Pointer OutputImagePointer;
+ typedef typename OutputImageType::ConstPointer OutputImageConstPointer;
+ typedef typename OutputImageType::PixelType OutputPixelType;
+ typedef typename OutputImageType::SizeType OutputSizeType;
+ typedef typename OutputImageType::SpacingType OutputSpacingType;
+ typedef typename OutputImageType::DirectionType OutputDirectionType;
+ typedef typename OutputImageType::IndexType OutputIndexType;
+ typedef typename OutputImageType::PointType OutputPointType;
+ typedef typename itk::ContinuousIndex<double,OutputImageDimension> ContinuousOutputIndexType;
+ typedef typename OutputImageType::RegionType OutputImageRegionType;
+ typedef itk::Vector<double,OutputImageDimension+1> HomogeneOutputVectorType;
+ typedef itk::Point<double,OutputImageDimension+1> HomogeneOutputPointType;
+
+ typedef itk::Matrix<double,4,4> MatrixType;
+
+ //------------------------------------
+ // Projection geometry
+ //-----------------------------------
+ void SetIsoCenter( const OutputPointType& i )
+ {
+ if( m_IsoCenter!=i)
+ {
+ m_IsoCenter=i;
+ m_IsInitialized=false;
+ this->Modified();
+ }
+ }
+
+ void SetSourceToScreen(const double &s)
+ {
+ if( m_SourceToScreen!=s)
+ {
+ m_SourceToScreen=s;
+ m_IsInitialized=false;
+ this->Modified();
+ }
+ }
+
+ void SetSourceToAxis( const double& s)
+ {
+ if( m_SourceToAxis!=s)
+ {
+ m_SourceToAxis=s;
+ m_IsInitialized=false;
+ this->Modified();
+ }
+ }
+
+ void SetProjectionAngle(const double& s)
+ {
+ if( m_SourceToScreen!=s)
+ {
+ m_ProjectionAngle=s;
+ m_IsInitialized=false;
+ this->Modified();
+ }
+ }
+
+ void SetRigidTransformMatrix(const MatrixType& m)
+ {
+ if(m_RigidTransformMatrix != m)
+ {
+ m_RigidTransformMatrix=m;
+ m_IsInitialized=false;
+ this->Modified();
+ }
+ }
+
+ void SetEdgePaddingValue(const OutputPixelType& p)
+ {
+ if (m_EdgePaddingValue!=p)
+ {
+ m_EdgePaddingValue=p;
+ m_IsInitialized=false;
+ this->Modified();
+ }
+ }
+
+ // itkSetMacro(IsoCenter, OutputPointType);
+ // itkGetConstReferenceMacro(IsoCenter, OutputPointType)
+ // itkSetMacro( SourceToScreen, double );
+ // itkGetMacro( SourceToScreen, double );
+ // itkSetMacro( SourceToAxis, double );
+ // itkGetMacro( SourceToAxis, double );
+ // itkSetMacro(RigidTransformMatrix, itk::Matrix<double,4,4>));
+ // itkGetConstReferenceMacro(RigidTransformMatrix, itk::Matrix<double,4,4>);
+ // void SetRigidTransformMatrix(const itk::Matrix<double,4,4> & m);
+ // itk::Matrix<double,4,4> GetRigidTransformMatrix( void ){return m_RigidTransformMatrix;}
+ // itkSetMacro( EdgePaddingValue, OutputPixelType );
+ // itkGetMacro( EdgePaddingValue, OutputPixelType );
+ // itkSetMacro( ProjectionAngle, double );
+ // itkGetMacro( ProjectionAngle, double );
+
+ //-----------------------------------
+ //Output image properties
+ //-----------------------------------
+ void SetOutputSize(const OutputSizeType& p)
+ {
+ if (m_OutputSize!=p)
+ {
+ m_OutputSize=p;
+ m_IsInitialized=false;
+ this->Modified();
+ }
+ }
+
+ /** Set the output image spacing. */
+ void SetOutputSpacing(const OutputSpacingType & p)
+ {
+ if (m_OutputSpacing!=p)
+ {
+ m_OutputSpacing=p;
+ m_IsInitialized=false;
+ this->Modified();
+ }
+ }
+
+ /** Set the output image origin. */
+ void SetOutputOrigin(const OutputPointType& p)
+ {
+ if (m_OutputOrigin!=p)
+ {
+ m_OutputOrigin=p;
+ m_IsInitialized=false;
+ this->Modified();
+ }
+ }
+
+ /** Helper method to set the output parameters based on this image */
+ void SetOutputParametersFromImage( const OutputImagePointer image );
+
+ /** Helper method to set the output parameters based on this image */
+ void SetOutputParametersFromImage( const OutputImageConstPointer image );
+
+
+ void Initialize(void) throw (itk::ExceptionObject);
+
+ protected:
+
+ // Constructor
+ BackProjectImageFilter();
+
+ // Destructor
+ ~BackProjectImageFilter(){};
+
+ // Print the object
+ void PrintSelf(std::ostream& os, itk::Indent indent) const;
+
+ // Calculate the projection matrix
+ void CalculateProjectionMatrix(void);
+
+ // Calculate the coordinate increments
+ void CalculateCoordinateIncrements( void );
+
+ /** Overrides GenerateInputRequestedRegion() in order to inform
+ * the pipeline execution model of different input requested regions
+ * than the output requested region.
+ * \sa ImageToImageFilter::GenerateInputRequestedRegion() */
+ virtual void GenerateInputRequestedRegion();
+
+ // Generate Output Information
+ virtual void GenerateOutputInformation (void);
+
+ // Threaded Generate Data
+ void BeforeThreadedGenerateData(void );
+
+ // Threaded Generate Data
+ void ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread, int threadId );
+
+
+ //------------------------------------------------
+ //Member data
+ //------------------------------------------------
+ bool m_IsInitialized;
+
+ // Input
+ InputImagePointer m_ModifiedInput;
+
+ // Projection geometry
+ OutputPointType m_IsoCenter;
+ itk::Matrix<double,3,4> m_ProjectionMatrix;
+ HomogeneInputVectorType m_LineInc, m_ColInc, m_PlaneInc;
+ // Homogene2DVectorType m_LineInc, m_ColInc, m_PlaneInc;
+ MatrixType m_RigidTransformMatrix;
+ double m_SourceToScreen;
+ double m_SourceToAxis;
+ OutputPixelType m_EdgePaddingValue;
+ double m_ProjectionAngle;
+
+ // Output image info
+ OutputSizeType m_OutputSize; // Size of the output image
+ OutputSpacingType m_OutputSpacing; // output image spacing
+ OutputPointType m_OutputOrigin; // output image origin
+
+ private:
+ BackProjectImageFilter( const Self& ); //purposely not implemented
+ void operator=( const Self& ); //purposely not implemented
+
+
+ };
+
+} // namespace clitk
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#include "clitkBackProjectImageFilter.txx"
+#endif
+
+#endif
--- /dev/null
+/*=========================================================================
+ 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 __clitkBackProjectImageFilter_txx
+#define __clitkBackProjectImageFilter_txx
+#include "clitkBackProjectImageFilter.h"
+#include "itkContinuousIndex.h"
+#include "vnl/vnl_math.h"
+
+namespace clitk
+{
+
+ //-----------------------------------------------------------------------
+ // Constructor
+ //-----------------------------------------------------------------------
+
+ template<class InputImageType, class OutputImageType>
+ BackProjectImageFilter< InputImageType, OutputImageType >
+ ::BackProjectImageFilter()
+ {
+
+ //Parameters for backprojection
+ this->m_IsoCenter.Fill(0.0);
+ this->m_SourceToScreen = 1536.0;
+ this->m_SourceToAxis = 1000.0;
+ this->m_EdgePaddingValue = itk::NumericTraits<OutputPixelType>::Zero;//density images
+ this->m_RigidTransformMatrix.SetIdentity();
+
+ //Parameters for output
+ this->m_OutputSpacing.Fill(1);
+ this->m_OutputOrigin.Fill(0.0);
+ this->m_OutputSize.Fill( 512 );
+
+ this->m_IsInitialized=false;
+ }
+
+
+ //-----------------------------------------------------------------------
+ // PrintSelf
+ //-----------------------------------------------------------------------
+ template<class InputImageType, class OutputImageType>
+ void
+ BackProjectImageFilter< InputImageType, OutputImageType >
+ ::PrintSelf(std::ostream& os, itk::Indent indent) const
+ {
+ this->Superclass::PrintSelf(os,indent);
+
+ os << indent << "IsoCenter: " << m_IsoCenter << std::endl;
+ os << indent << "SourceToScreen: " << m_SourceToScreen << std::endl;
+ os << indent << "SourceToAxis: " << m_SourceToAxis << std::endl;
+ os << indent << "Edge Padding Value: " << m_EdgePaddingValue << std::endl;
+ os << indent << "Rigid Transform matrix: " << m_EdgePaddingValue << std::endl;
+ }
+
+
+ //-----------------------------------------------------------------------
+ // Set output info from image
+ //-----------------------------------------------------------------------
+ template <class InputImageType, class OutputImageType>
+ void
+ BackProjectImageFilter<InputImageType, OutputImageType>
+ ::SetOutputParametersFromImage ( const OutputImagePointer image )
+ {
+ this->SetOutputOrigin( image->GetOrigin() );
+ this->SetOutputSpacing( image->GetSpacing() );
+ this->SetOutputSize( image->GetLargestPossibleRegion().GetSize() );
+ }
+
+
+ //-----------------------------------------------------------------------
+ // Set output info from image
+ //-----------------------------------------------------------------------
+ template <class InputImageType, class OutputImageType>
+ void
+ BackProjectImageFilter<InputImageType, OutputImageType>
+ ::SetOutputParametersFromImage (const OutputImageConstPointer image )
+ {
+ this->SetOutputOrigin( image->GetOrigin() );
+ this->SetOutputSpacing( image->GetSpacing() );
+ this->SetOutputSize( image->GetLargestPossibleRegion().GetSize() );
+ }
+
+
+ //-----------------------------------------------------------------------
+ // Generate output information
+ //-----------------------------------------------------------------------
+ template<class InputImageType, class OutputImageType>
+ void
+ BackProjectImageFilter< InputImageType, OutputImageType >
+ ::GenerateOutputInformation( void )
+ {
+ // Don not call the superclass' implementation of this method (!=Dimensions)
+ // Superclass::GenerateOutputInformation();
+
+ // get pointer to the output
+ OutputImagePointer outputPtr = this->GetOutput();
+ InputImageConstPointer inputPtr = this->GetInput();
+
+ if ( !outputPtr || ! inputPtr)
+ {
+ return;
+ }
+
+ // Set the output image largest possible region. Use a RegionCopier
+ // so that the input and output images can be different dimensions.
+ OutputImageRegionType outputLargestPossibleRegion;
+ this->CallCopyInputRegionToOutputRegion(outputLargestPossibleRegion,
+ inputPtr->GetLargestPossibleRegion());
+
+
+ //OutputImageRegionType region;
+ outputLargestPossibleRegion.SetSize( m_OutputSize );
+ outputPtr->SetLargestPossibleRegion( outputLargestPossibleRegion );
+ outputPtr->SetSpacing( m_OutputSpacing );
+ outputPtr->SetOrigin( m_OutputOrigin );
+
+ }
+
+
+ //-----------------------------------------------------------------------
+ // Generate input Requested region
+ //-----------------------------------------------------------------------
+ template <class InputImageType, class OutputImageType>
+ void
+ BackProjectImageFilter<InputImageType,OutputImageType>
+ ::GenerateInputRequestedRegion()
+ {
+ //Call superclass
+ Superclass::GenerateInputRequestedRegion();
+
+ if (!this->GetOutput())
+ {
+ return;
+ }
+ OutputImageRegionType outputRegion = this->GetOutput()->GetRequestedRegion();
+ InputImagePointer inputPtr = const_cast<InputImageType *>(this->GetInput());
+
+ if ( !inputPtr )
+ {
+ // Because DataObject::PropagateRequestedRegion() allows only
+ // InvalidRequestedRegionError, it's impossible to write simply:
+ // itkExceptionMacro(<< "Missing input " << idx);
+ itk::InvalidRequestedRegionError e(__FILE__, __LINE__);
+ e.SetLocation(ITK_LOCATION);
+ e.SetDescription("Missing input.");
+ e.SetDataObject(this->GetOutput());
+ throw e;
+ }
+
+ InputImageRegionType inputRegion;
+ inputRegion=inputPtr->GetLargestPossibleRegion();
+ inputPtr->SetRequestedRegion(inputRegion);
+
+ }
+
+
+
+ //-----------------------------------------------------------------------
+ // Before threaded data
+ //-----------------------------------------------------------------------
+ template <class InputImageType, class OutputImageType>
+ void
+ BackProjectImageFilter<InputImageType, OutputImageType>
+ ::BeforeThreadedGenerateData( void )
+ {
+ if (!m_IsInitialized) this->Initialize();
+ }
+
+
+ //-----------------------------------------------------------------------
+ // Initialize
+ //-----------------------------------------------------------------------
+ template <class InputImageType, class OutputImageType>
+ void
+ BackProjectImageFilter<InputImageType, OutputImageType>
+ ::Initialize( void ) throw (itk::ExceptionObject)
+ {
+ //Change the origin of the 2D input
+ typename InputImageType::ConstPointer inputPtr=this->GetInput();
+ m_ModifiedInput=InputImageType::New();
+ m_ModifiedInput->CopyInformation(inputPtr);
+ InputSizeType size=inputPtr->GetLargestPossibleRegion().GetSize();
+ InputSpacingType spacing=inputPtr->GetSpacing();
+
+ //Change the origin
+ InputPointType newOrigin;
+ newOrigin[0] =-static_cast<double>(size[0]-1)*spacing[0]/2.0;//-static_cast<double>(size[0]-1)*spacing[0]/2.0;
+ newOrigin[1] =-static_cast<double>(size[1]-1)*spacing[1]/2.0;//-static_cast<double>(size[1]-1)*spacing[1]/2.0;
+ m_ModifiedInput->SetOrigin(newOrigin);
+
+ // Calculate the projection matrix
+ this->CalculateProjectionMatrix();
+
+ // Calculate the coordinate increments
+ this->CalculateCoordinateIncrements();
+
+ m_IsInitialized=true;
+ }
+
+
+ //-----------------------------------------------------------------------
+ // Calculate Projection Matrix
+ //-----------------------------------------------------------------------
+ template <class InputImageType, class OutputImageType>
+ void
+ BackProjectImageFilter<InputImageType, OutputImageType>
+ ::CalculateProjectionMatrix( void )
+ {
+ InputSpacingType inputSpacing=this->GetInput()->GetSpacing();
+
+ // Projection on YZ plane+pixelTrans
+ itk::Matrix<double,3,4> temp;
+ temp.Fill(itk::NumericTraits<double>::Zero);
+ // temp(0,0)=-0.5*inputSpacing[0];
+ // temp(1,0)=-0.5*inputSpacing[1];
+ temp(2,0)=1;
+ temp(0,1)=m_SourceToScreen;//Invert Y/X? for correspondence to real projections
+ temp(1,2)=m_SourceToScreen;
+ // temp(0,3)=m_SourceToAxis*0.5*inputSpacing[0];
+ // temp(1,3)=m_SourceToAxis*0.5*inputSpacing[1];
+ temp(2,3)=-m_SourceToAxis;//-m_IsoCenter[0]-m_SourceToAxis;
+
+ // Get the rotation parameter array
+ itk::Array<double> rotationParameters(3);
+ const double dtr = ( atan(1.0) * 4.0 ) / 180.0; //constant for converting degrees into radians
+ rotationParameters[0]= 0.;
+ rotationParameters[1]= 0.;
+ rotationParameters[2]= -dtr*(double) m_ProjectionAngle;
+
+ // We first perform rigid transform (of source and panel), then a centered rotation around the transformed center
+ itk::Matrix<double,3,3> rigidRotation = GetRotationalPartMatrix3D(m_RigidTransformMatrix);
+ itk::Vector<double,3> rigidTranslation = GetTranslationPartMatrix3D(m_RigidTransformMatrix);
+ OutputPointType transformedIsoCenter = rigidRotation * m_IsoCenter + rigidTranslation;
+
+ // Calculate the centered rotation matrix
+ itk::Matrix<double,4,4> centeredRotationMatrix=GetCenteredRotationMatrix3D(rotationParameters,transformedIsoCenter);
+
+ // Define the voxel pixel transforms (shift half a pixel/voxel)
+ itk::Matrix<double,4,4> voxelTrans; voxelTrans.SetIdentity();
+ for (unsigned int i=0;i<3;i++)voxelTrans(i,3)=0.5*m_OutputSpacing[i];
+
+ // Compose the rotation with the rigid transform matrix and the voxel transform
+ itk::Matrix<double,4,4> finalTransform = centeredRotationMatrix * m_RigidTransformMatrix;
+ itk::Matrix<double,4,4> invFinalTransform ( finalTransform.GetInverse());
+ invFinalTransform=invFinalTransform*voxelTrans;
+
+ // Apply rigid transform to the projection matrix
+ for (unsigned int i=0; i<3;i++)
+ for (unsigned int j=0; j<4;j++)
+ {
+ m_ProjectionMatrix(i,j)=itk::NumericTraits<double>::Zero;
+ for (unsigned int k=0; k<4;k++)
+ m_ProjectionMatrix(i,j)+=temp(i,k)*invFinalTransform(k,j);
+ }
+ }
+
+
+ //-----------------------------------------------------------------------
+ // Calculate the coordinate increments
+ //-----------------------------------------------------------------------
+ template <class InputImageType, class OutputImageType>
+ void
+ BackProjectImageFilter<InputImageType, OutputImageType>
+ ::CalculateCoordinateIncrements( void )
+ {
+ //Compute Line increment
+ m_LineInc[0]=m_ProjectionMatrix[0][0]*m_OutputSpacing[0];
+ m_LineInc[1]=m_ProjectionMatrix[1][0]*m_OutputSpacing[0];
+ m_LineInc[2]=m_ProjectionMatrix[2][0]*m_OutputSpacing[0];
+
+ //Compute column increment (and restart at the beginning of the line)
+ m_ColInc[0]=m_ProjectionMatrix[0][1]*m_OutputSpacing[1]-m_OutputSize[0]*m_LineInc[0];
+ m_ColInc[1]=m_ProjectionMatrix[1][1]*m_OutputSpacing[1]-m_OutputSize[0]*m_LineInc[1];
+ m_ColInc[2]=m_ProjectionMatrix[2][1]*m_OutputSpacing[1]-m_OutputSize[0]*m_LineInc[2];
+
+ //Compute plane increment (and restart at the beginning of the columns)
+ m_PlaneInc[0]=m_ProjectionMatrix[0][2]*m_OutputSpacing[2]-m_ProjectionMatrix[0][1]*m_OutputSpacing[1]*m_OutputSize[1];
+ m_PlaneInc[1]=m_ProjectionMatrix[1][2]*m_OutputSpacing[2]-m_ProjectionMatrix[1][1]*m_OutputSpacing[1]*m_OutputSize[1];
+ m_PlaneInc[2]=m_ProjectionMatrix[2][2]*m_OutputSpacing[2]-m_ProjectionMatrix[2][1]*m_OutputSpacing[1]*m_OutputSize[1];
+ }
+
+
+ //-----------------------------------------------------------------------
+ // Threaded generate data
+ //-----------------------------------------------------------------------
+ template <class InputImageType, class OutputImageType>
+ void
+ BackProjectImageFilter<InputImageType, OutputImageType>
+ ::ThreadedGenerateData( const OutputImageRegionType & outputRegionForThread, int threadId )
+ {
+ //Projection pointer
+ InputImageConstPointer inputPtr=this->GetInput();
+ InputPixelType * beginPtr=const_cast<InputPixelType *>(this->GetInput()->GetBufferPointer());
+ InputPixelType * pp;
+
+ //Volume pointer
+ OutputImagePointer outputPTr= this->GetOutput();
+
+ //Iterator for the thread region
+ typedef itk::ImageRegionIterator<OutputImageType> OutputIteratorType;
+ OutputIteratorType iterator(outputPTr, outputRegionForThread);
+ OutputSizeType outputSizeForThread=outputRegionForThread.GetSize();
+
+ //Some temp variables
+ OutputPixelType value;
+ HomogeneOutputPointType homOutputPoint;
+ HomogeneInputPointType homInputPoint;
+ OutputPointType oPoint;
+ InputPointType iPoint;
+ iPoint.Fill(itk::NumericTraits<double>::Zero);
+ OutputIndexType oIndex;
+ ContinuousInputIndexType iIndex;
+ InputSizeType inputSize=inputPtr->GetLargestPossibleRegion().GetSize();
+ double dx,dy,dxm,dym;
+ int lx, ly;
+
+ //Get the first output coordinate
+ oIndex=iterator.GetIndex();//costly but only once a thread
+ outputPTr->TransformIndexToPhysicalPoint(oIndex,oPoint);
+
+ for (unsigned int i=0;i<OutputImageDimension;i++) homOutputPoint[i]=oPoint[i];
+ homOutputPoint[3]=1;
+
+ //Compute the first input coordinate (invert Y/X)
+ homInputPoint= (m_ProjectionMatrix * homOutputPoint);
+ iPoint[0]=-homInputPoint[0]/homInputPoint[2];
+ iPoint[1]=homInputPoint[1]/homInputPoint[2];
+
+ //Run over all output voxels
+ for (unsigned int i=0; i<outputSizeForThread[2]; i++)
+ {
+ for (unsigned int j=0; j<outputSizeForThread[1]; j++)
+ {
+ for (unsigned int k=0; k<outputSizeForThread[0]; k++)
+ {
+ iPoint[0]=homInputPoint[0]/homInputPoint[2];
+ iPoint[1]=homInputPoint[1]/homInputPoint[2];
+
+ //Check wether inside, convert to index (use modified with correct origin)
+ if( m_ModifiedInput->TransformPhysicalPointToContinuousIndex(iPoint, iIndex) )
+ {
+ //Own (fast bilinear) interpolation
+ lx = (int)floor(iIndex[0]); dx = iIndex[0]-lx; dxm = 1.-dx;
+ ly = (int)floor(iIndex[1]); dy = iIndex[1]-ly; dym = 1.-dy;
+ pp = beginPtr + ly*inputSize[0]+lx;
+ value =static_cast<OutputPixelType>( ( dxm * dym*(double)(*pp)
+ + dx * dym*(double)(*(pp+1))
+ + dxm* dy *(double)(*(pp + inputSize[0]))
+ + dx * dy *(double)(*(pp + inputSize[0]+1))) );
+
+ }
+ //Outside: padding value
+ else value=m_EdgePaddingValue;
+
+ //Set it
+ iterator.Set(value);
+
+ //Advance one step in the line
+ homInputPoint+=m_LineInc;
+ ++iterator;
+ }
+
+ //Advance one line
+ homInputPoint+=m_ColInc;
+ }
+
+ //Advance one plane
+ homInputPoint+=m_PlaneInc;
+ }
+ }
+
+
+} // namespace clitk
+
+
+#endif
--- /dev/null
+/*=========================================================================
+ 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 __clitkComposeVFFilter_h
+#define __clitkComposeVFFilter_h
+#include "clitkImageCommon.h"
+
+#include "itkImageToImageFilter.h"
+#include "itkImage.h"
+#include "itkImageRegionIterator.h"
+#include "itkImageRegionIteratorWithIndex.h"
+#include "itkNumericTraits.h"
+
+namespace clitk
+{
+
+ template <class InputImageType, class OutputImageType>
+ class ITK_EXPORT ComposeVFFilter : public itk::ImageToImageFilter<InputImageType, OutputImageType>
+
+ {
+ public:
+ typedef ComposeVFFilter Self;
+ typedef itk::ImageToImageFilter<InputImageType, OutputImageType> Superclass;
+ typedef itk::SmartPointer<Self> Pointer;
+ typedef itk::SmartPointer<const Self> ConstPointer;
+
+ /** Method for creation through the object factory. */
+ itkNewMacro(Self);
+
+ /** Run-time type information (and related methods) */
+ itkTypeMacro( ComposeVFFilter, ImageToImageFilter );
+
+ /** Determine the image dimension. */
+ itkStaticConstMacro(ImageDimension, unsigned int,
+ InputImageType::ImageDimension );
+
+ /** Typedef to describe the output image region type. */
+ typedef typename OutputImageType::RegionType OutputImageRegionType;
+
+ //========================================================================================
+ //typedefs
+ typedef double CoordRepType;
+ typedef typename OutputImageType::PixelType PixelType;
+ typedef itk::Point<CoordRepType, ImageDimension> PointType;
+
+ //Set Methods(inline)
+ void SetEdgePaddingValue(PixelType m);
+ void SetVerbose(bool m){m_Verbose=m;}
+ void SetInput1(typename InputImageType::Pointer m)
+ {
+ //call the superclass method (at least one input required!)
+ this->SetInput(m);
+ m_Input1=m;
+ }
+ void SetInput2(typename InputImageType::Pointer m){m_Input2=m;}
+
+ protected:
+ ComposeVFFilter();
+ ~ComposeVFFilter() {};
+
+
+ //========================================================================================
+ //Threaded execution should implement generate threaded data
+ void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, int threadId );
+
+ bool m_Verbose;
+ PixelType m_EdgePaddingValue;
+ typename InputImageType::Pointer m_Input1;
+ typename InputImageType::Pointer m_Input2;
+ };
+
+
+} // end namespace clitk
+#ifndef ITK_MANUAL_INSTANTIATION
+#include "clitkComposeVFFilter.txx"
+#endif
+
+#endif // #define __clitkComposeVFFilter_h
--- /dev/null
+/*=========================================================================
+ 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 __clitkComposeVFFilter_txx
+#define __clitkComposeVFFilter_txx
+#include "clitkComposeVFFilter.h"
+
+
+namespace clitk
+{
+
+ //=========================================================================================================================
+ //constructor
+ template <class InputImageType, class OutputImageType>
+ ComposeVFFilter<InputImageType, OutputImageType>::ComposeVFFilter()
+ {
+ for (unsigned int i=0; i<ImageDimension; i++) m_EdgePaddingValue[i]=0.0; //no other reasonable value?
+ m_Verbose=false;
+ }
+
+
+ //=========================================================================================================================
+ //update the output for the outputRegionForThread
+ template<class InputImageType, class OutputImageType>
+ void ComposeVFFilter<InputImageType, OutputImageType>::ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, int threadId )
+ {
+
+ //Get pointer to the output
+ typename OutputImageType::Pointer outputPtr = this->GetOutput();
+
+ //Iterator over output
+ typedef itk::ImageRegionConstIteratorWithIndex<InputImageType> Input1ImageIteratorType;
+ typedef itk::ImageRegionIterator<OutputImageType> OutputImageIteratorType;
+
+ //define the output and input1 iterator over the outputRegionForThread
+ OutputImageIteratorType outputIt(outputPtr, outputRegionForThread);
+ Input1ImageIteratorType input1It(m_Input1, outputRegionForThread);
+
+ //Initialize
+ typename InputImageType::IndexType index;
+ itk::ContinuousIndex<double,ImageDimension> contIndex;
+ typename InputImageType::PointType point1;
+ typename InputImageType::PointType point2;
+ typedef typename OutputImageType::PixelType DisplacementType;
+ DisplacementType displacement;
+ DisplacementType totalDisplacement;
+ input1It.GoToBegin();
+
+ //define some temp variables outside the loop
+ signed long baseIndex[ImageDimension];
+ // long tIndex;
+ double distance[ImageDimension];
+ unsigned int dim;
+ double totalOverlap;
+ double overlap;
+ unsigned int upper;
+ unsigned int counter;
+ typename OutputImageType::IndexType neighIndex;
+
+
+ //Find the number of neighbors
+ unsigned int neighbors = 1 << ImageDimension;
+
+ //==================================================================================================
+ //1. loop over the region of the deformationfield and compose the displacements
+ while( !input1It.IsAtEnd() )
+ {
+ // get the input image index
+ index = input1It.GetIndex();
+ m_Input1->TransformIndexToPhysicalPoint( index, point1 );
+
+ // get the displacement of input 1
+ displacement = input1It.Get();
+
+ // compute the required image point in input2
+ for(unsigned int j = 0; j < ImageDimension; j++ ) point2[j] = point1[j] + (double)displacement[j];
+
+ //JV TODO add something for the borders
+ //true if inside image
+ if(m_Input2->TransformPhysicalPointToContinuousIndex(point2, contIndex ) )
+ {
+
+ for(dim = 0; dim < ImageDimension; dim++)
+ {
+ // The following block is equivalent to the following line without
+ // having to call floor. (Only for positive inputs, we already now that is in the image)
+ // baseIndex[dim] = (long) vcl_floor(contIndex[dim] );
+
+ baseIndex[dim] = (long) contIndex[dim];
+ distance[dim] = contIndex[dim] - double( baseIndex[dim] );
+
+ //Reset the accumulator
+ totalDisplacement[dim]=0.0;
+ }
+
+ //Add contribution for each neighbor
+ totalOverlap = itk::NumericTraits<double>::Zero;
+ for( counter = 0; counter < neighbors ; counter++ )
+ {
+ overlap = 1.0; // fraction overlap
+ upper = counter; // each bit indicates upper/lower neighbour
+
+
+ // get neighbor index and overlap fraction
+ for( dim = 0; dim < 3; dim++ )
+ {
+ if ( upper & 1 )
+ {
+ neighIndex[dim] = baseIndex[dim] + 1;
+ overlap *= distance[dim];
+ }
+ else
+ {
+ neighIndex[dim] = baseIndex[dim];
+ overlap *= 1.0 - distance[dim];
+ }
+ upper >>= 1;
+ }
+
+ //JV shouldn't we verify that the index is not over the upper border instead of zero?
+ // Set neighbor value only if overlap is not zero and index is still in image
+ if( overlap>0.0 && neighIndex[0]>=0 && neighIndex[1]>=0 && neighIndex[2]>=0 )
+ {
+ //what to store? the weighted displacement vector of Input2?
+ totalDisplacement+=m_Input2->GetPixel(neighIndex)*overlap;
+ //JV don't we loose more by adding and verifyning each time, it will never be 1.0 before the end no?
+ totalOverlap += overlap;
+ }
+
+ if( totalOverlap == 1.0 )
+ {
+ // finished
+ break;
+ }
+ }
+ //add the displacement of input1 and the interpolated displacement of input2 to the output
+ outputIt.Set(static_cast<PixelType>(input1It.Get())+totalDisplacement);
+ }
+ //displacement from input1 goes outside input2
+ else outputIt.Set(m_EdgePaddingValue);
+
+ ++input1It;
+ ++outputIt;
+ }
+ }
+
+}
+
+#endif
--- /dev/null
+
+/*=========================================================================
+ 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 __clitkExtractImageFilter_h
+#define __clitkExtractImageFilter_h
+
+#include "itkImageToImageFilter.h"
+#include "itkSmartPointer.h"
+#include "itkExtractImageFilterRegionCopier.h"
+
+namespace clitk
+{
+
+template <class TInputImage, class TOutputImage>
+class ITK_EXPORT ExtractImageFilter:
+ public itk::ImageToImageFilter<TInputImage,TOutputImage>
+{
+public:
+ /** Standard class typedefs. */
+ typedef ExtractImageFilter Self;
+ typedef itk::ImageToImageFilter<TInputImage,TOutputImage> Superclass;
+ typedef itk::SmartPointer<Self> Pointer;
+ typedef itk::SmartPointer<const Self> ConstPointer;
+
+ /** Method for creation through the object factory. */
+ itkNewMacro(Self);
+
+ /** Run-time type information (and related methods). */
+ itkTypeMacro(ExtractImageFilter, ImageToImageFilter);
+
+ /** Image type information. */
+ typedef TInputImage InputImageType;
+ typedef TOutputImage OutputImageType;
+
+ /** Typedef to describe the output and input image region types. */
+ typedef typename TOutputImage::RegionType OutputImageRegionType;
+ typedef typename TInputImage::RegionType InputImageRegionType;
+
+ /** Typedef to describe the type of pixel. */
+ typedef typename TOutputImage::PixelType OutputImagePixelType;
+ typedef typename TInputImage::PixelType InputImagePixelType;
+
+ /** Typedef to describe the output and input image index and size types. */
+ typedef typename TOutputImage::IndexType OutputImageIndexType;
+ typedef typename TInputImage::IndexType InputImageIndexType;
+ typedef typename TOutputImage::SizeType OutputImageSizeType;
+ typedef typename TInputImage::SizeType InputImageSizeType;
+
+ /** ImageDimension enumeration */
+ itkStaticConstMacro(InputImageDimension, unsigned int,
+ TInputImage::ImageDimension);
+ itkStaticConstMacro(OutputImageDimension, unsigned int,
+ TOutputImage::ImageDimension);
+
+ typedef itk::ImageToImageFilterDetail::ExtractImageFilterRegionCopier<
+ itkGetStaticConstMacro(InputImageDimension),
+ itkGetStaticConstMacro(OutputImageDimension)> ExtractImageFilterRegionCopierType;
+
+ void SetExtractionRegion(InputImageRegionType extractRegion);
+ itkGetMacro(ExtractionRegion, InputImageRegionType);
+
+#ifdef ITK_USE_CONCEPT_CHECKING
+ /** Begin concept checking */
+ itkConceptMacro(InputCovertibleToOutputCheck,
+ (itk::Concept::Convertible<InputImagePixelType, OutputImagePixelType>));
+ /** End concept checking */
+#endif
+
+protected:
+ ExtractImageFilter();
+ ~ExtractImageFilter() {};
+ void PrintSelf(std::ostream& os, itk::Indent indent) const;
+
+
+ virtual void GenerateOutputInformation();
+
+
+ virtual void CallCopyOutputRegionToInputRegion(InputImageRegionType &destRegion,
+ const OutputImageRegionType &srcRegion);
+
+
+ void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread,
+ int threadId );
+ InputImageRegionType m_ExtractionRegion;
+ OutputImageRegionType m_OutputImageRegion;
+
+private:
+ ExtractImageFilter(const Self&); //purposely not implemented
+ void operator=(const Self&); //purposely not implemented
+
+};
+
+
+} // end namespace itk
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#include "clitkExtractImageFilter.txx"
+#endif
+
+#endif
--- /dev/null
+/*=========================================================================
+ 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 _clitkExtractImageFilter_txx
+#define _clitkExtractImageFilter_txx
+
+#include "clitkExtractImageFilter.h"
+#include "itkImageRegionIterator.h"
+#include "itkImageRegionConstIterator.h"
+#include "itkObjectFactory.h"
+#include "itkExtractImageFilterRegionCopier.h"
+#include "itkProgressReporter.h"
+
+
+namespace clitk
+{
+
+/**
+ *
+ */
+template <class TInputImage, class TOutputImage>
+ExtractImageFilter<TInputImage,TOutputImage>
+::ExtractImageFilter()
+{
+}
+
+
+/**
+ *
+ */
+template <class TInputImage, class TOutputImage>
+void
+ExtractImageFilter<TInputImage,TOutputImage>
+::PrintSelf(std::ostream& os, itk::Indent indent) const
+{
+ Superclass::PrintSelf(os,indent);
+
+ os << indent << "ExtractionRegion: " << m_ExtractionRegion << std::endl;
+ os << indent << "OutputImageRegion: " << m_OutputImageRegion << std::endl;
+}
+
+
+template<class TInputImage, class TOutputImage>
+void
+ExtractImageFilter<TInputImage,TOutputImage>
+::CallCopyOutputRegionToInputRegion(InputImageRegionType &destRegion,
+ const OutputImageRegionType &srcRegion)
+{
+ ExtractImageFilterRegionCopierType extractImageRegionCopier;
+ extractImageRegionCopier(destRegion, srcRegion, m_ExtractionRegion);
+}
+
+
+template <class TInputImage, class TOutputImage>
+void
+ExtractImageFilter<TInputImage,TOutputImage>
+::SetExtractionRegion(InputImageRegionType extractRegion)
+{
+ m_ExtractionRegion = extractRegion;
+
+ unsigned int nonzeroSizeCount = 0;
+ InputImageSizeType inputSize = extractRegion.GetSize();
+ OutputImageSizeType outputSize;
+ OutputImageIndexType outputIndex;
+
+ /**
+ * check to see if the number of non-zero entries in the extraction region
+ * matches the number of dimensions in the output image.
+ **/
+ for (unsigned int i = 0; i < InputImageDimension; ++i)
+ {
+ if (inputSize[i])
+ {
+ outputSize[nonzeroSizeCount] = inputSize[i];
+ outputIndex[nonzeroSizeCount] = extractRegion.GetIndex()[i];
+ nonzeroSizeCount++;
+ }
+ }
+
+ if (nonzeroSizeCount != OutputImageDimension)
+ {
+ itkExceptionMacro("Extraction Region not consistent with output image");
+ }
+
+ m_OutputImageRegion.SetSize(outputSize);
+ m_OutputImageRegion.SetIndex(outputIndex);
+ this->Modified();
+}
+
+
+
+/**
+ * ExtractImageFilter can produce an image which is a different resolution
+ * than its input image. As such, ExtractImageFilter needs to provide an
+ * implementation for GenerateOutputInformation() in order to inform
+ * the pipeline execution model. The original documentation of this
+ * method is below.
+ *
+ * \sa ProcessObject::GenerateOutputInformaton()
+ */
+template <class TInputImage, class TOutputImage>
+void
+ExtractImageFilter<TInputImage,TOutputImage>
+::GenerateOutputInformation()
+{
+ // do not call the superclass' implementation of this method since
+ // this filter allows the input and the output to be of different dimensions
+
+ // get pointers to the input and output
+ typename Superclass::OutputImagePointer outputPtr = this->GetOutput();
+ typename Superclass::InputImageConstPointer inputPtr = this->GetInput();
+
+ if ( !outputPtr || !inputPtr)
+ {
+ return;
+ }
+
+ // Set the output image size to the same value as the extraction region.
+ outputPtr->SetLargestPossibleRegion( m_OutputImageRegion );
+
+ // Set the output spacing and origin
+ const itk::ImageBase<InputImageDimension> *phyData;
+
+ phyData
+ = dynamic_cast<const itk::ImageBase<InputImageDimension>*>(this->GetInput());
+
+ if (phyData)
+ {
+ // Copy what we can from the image from spacing and origin of the input
+ // This logic needs to be augmented with logic that select which
+ // dimensions to copy
+
+ unsigned int i;
+ const typename InputImageType::SpacingType&
+ inputSpacing = inputPtr->GetSpacing();
+ const typename InputImageType::DirectionType&
+ inputDirection = inputPtr->GetDirection();
+ const typename InputImageType::PointType&
+ inputOrigin = inputPtr->GetOrigin();
+
+ typename OutputImageType::SpacingType outputSpacing;
+ typename OutputImageType::DirectionType outputDirection;
+ typename OutputImageType::PointType outputOrigin;
+
+ if ( static_cast<unsigned int>(OutputImageDimension) >
+ static_cast<unsigned int>(InputImageDimension ) )
+ {
+ // copy the input to the output and fill the rest of the
+ // output with zeros.
+ for (i=0; i < InputImageDimension; ++i)
+ {
+ outputSpacing[i] = inputSpacing[i];
+ outputOrigin[i] = inputOrigin[i];
+ for (unsigned int dim = 0; dim < InputImageDimension; ++dim)
+ {
+ outputDirection[i][dim] = inputDirection[i][dim];
+ }
+ }
+ for (; i < OutputImageDimension; ++i)
+ {
+ outputSpacing[i] = 1.0;
+ outputOrigin[i] = 0.0;
+ for (unsigned int dim = 0; dim < InputImageDimension; ++dim)
+ {
+ outputDirection[i][dim] = 0.0;
+ }
+ outputDirection[i][i] = 1.0;
+ }
+ }
+ else
+ {
+ // copy the non-collapsed part of the input spacing and origing to the output
+ int nonZeroCount = 0;
+ for (i=0; i < InputImageDimension; ++i)
+ {
+ if (m_ExtractionRegion.GetSize()[i])
+ {
+ outputSpacing[nonZeroCount] = inputSpacing[i];
+ outputOrigin[nonZeroCount] = inputOrigin[i];
+ int nonZeroCount2 = 0;
+ for (unsigned int dim = 0; dim < InputImageDimension; ++dim)
+ {
+ if (m_ExtractionRegion.GetSize()[dim])
+ {
+ outputDirection[nonZeroCount][nonZeroCount2] =
+ inputDirection[i][dim];
+ ++nonZeroCount2;
+ }
+ }
+ nonZeroCount++;
+ }
+ }
+ }
+
+ // set the spacing and origin
+ outputPtr->SetSpacing( outputSpacing );
+ outputPtr->SetDirection( outputDirection );
+ outputPtr->SetOrigin( outputOrigin );
+ outputPtr->SetNumberOfComponentsPerPixel(inputPtr->GetNumberOfComponentsPerPixel() );
+ }
+ else
+ {
+ // pointer could not be cast back down
+ itkExceptionMacro(<< "itk::ExtractImageFilter::GenerateOutputInformation "
+ << "cannot cast input to "
+ << typeid(itk::ImageBase<InputImageDimension>*).name() );
+ }
+}
+
+/**
+ * ExtractImageFilter can be implemented as a multithreaded filter.
+ * Therefore, this implementation provides a ThreadedGenerateData()
+ * routine which is called for each processing thread. The output
+ * image data is allocated automatically by the superclass prior to
+ * calling ThreadedGenerateData(). ThreadedGenerateData can only
+ * write to the portion of the output image specified by the
+ * parameter "outputRegionForThread"
+ *
+ * \sa ImageToImageFilter::ThreadedGenerateData(),
+ * ImageToImageFilter::GenerateData()
+ */
+template <class TInputImage, class TOutputImage>
+void
+ExtractImageFilter<TInputImage,TOutputImage>
+::ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread,
+ int threadId)
+{
+ itkDebugMacro(<<"Actually executing");
+
+ // Get the input and output pointers
+ typename Superclass::InputImageConstPointer inputPtr = this->GetInput();
+ typename Superclass::OutputImagePointer outputPtr = this->GetOutput();
+
+ // support progress methods/callbacks
+ itk::ProgressReporter progress(this, threadId, outputRegionForThread.GetNumberOfPixels());
+
+ // Define the portion of the input to walk for this thread
+ InputImageRegionType inputRegionForThread;
+ this->CallCopyOutputRegionToInputRegion(inputRegionForThread, outputRegionForThread);
+
+ // Define the iterators.
+ typedef itk::ImageRegionIterator<TOutputImage> OutputIterator;
+ typedef itk::ImageRegionConstIterator<TInputImage> InputIterator;
+
+ OutputIterator outIt(outputPtr, outputRegionForThread);
+ InputIterator inIt(inputPtr, inputRegionForThread);
+
+ // walk the output region, and sample the input image
+ while( !outIt.IsAtEnd() )
+ {
+ // copy the input pixel to the output
+ outIt.Set( static_cast<OutputImagePixelType>(inIt.Get()));
+ ++outIt;
+ ++inIt;
+ progress.CompletedPixel();
+ }
+}
+
+} // end namespace clitk
+
+#endif
+++ /dev/null
-/*=========================================================================
- 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 __clitkGenericInterpolator_h
-#define __clitkGenericInterpolator_h
-#include "clitkImageCommon.h"
-
-//itk include
-#include "itkNearestNeighborInterpolateImageFunction.h"
-#include "itkLinearInterpolateImageFunction.h"
-#include "itkBSplineInterpolateImageFunction.h"
-#include "itkBSplineInterpolateImageFunctionWithLUT.h"
-
-
-/*
-
-Requires at least the following section is the .ggo file
-
-option "interp" - "Interpolation: 0=NN, 1=Linear, 2=BSpline, 3=BLUT" int no default="1"
-option "interpOrder" - "Order if BLUT or BSpline (0-5)" int no default="3"
-option "interpSF" - "Sampling factor if BLUT" int no default="20"
-
-The use will something like
-
-typedef clitk::GenericVectorInterpolator<InputImageType, double> GenericVectorInterpolatorType;
-typename GenericVectorInterpolatorType::Pointer genericInterpolator=GenericVectorInterpolatorType::New();
-genericInterpolator->SetArgsInfo(m_ArgsInfo);
-typedef itk::VectorInterpolateImageFunction<InputImageType, double> InterpolatorType;
-typename InterpolatorType::Pointer interpolator=genericInterpolator->GetInterpolatorPointer();
-
-*/
-
-namespace clitk
-{
-
- template <class args_info_type, class ImageType, class TCoordRep >
- class GenericInterpolator : public itk::LightObject
- {
- public:
- //==============================================
- typedef GenericInterpolator Self;
- typedef itk::LightObject Superclass;
- typedef itk::SmartPointer<Self> Pointer;
- typedef itk::SmartPointer<const Self> ConstPointer;
-
- typedef itk::InterpolateImageFunction<ImageType, TCoordRep> InterpolatorType;
- typedef typename InterpolatorType::Pointer InterpolatorPointer;
-
- /** Method for creation through the object factory. */
- itkNewMacro(Self);
-
- //==============================================
- //Set members
- void SetArgsInfo(args_info_type args_info)
- {
- m_ArgsInfo= args_info;
- m_Verbose=m_ArgsInfo.verbose_flag;
- }
-
- //==============================================
- //Get members
- InterpolatorPointer GetInterpolatorPointer(void);
-
- //==============================================
- protected:
- GenericInterpolator();
- ~GenericInterpolator() {};
-
- private:
- args_info_type m_ArgsInfo;
- InterpolatorPointer m_Interpolator;
- bool m_Verbose;
- };
-
-} // end namespace clitk
-#ifndef ITK_MANUAL_INSTANTIATION
-#include "clitkGenericInterpolator.txx"
-#endif
-
-#endif // #define __clitkGenericInterpolator_h
+++ /dev/null
-/*=========================================================================
- 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 __clitkGenericInterpolator_txx
-#define __clitkGenericInterpolator_txx
-#include "clitkGenericInterpolator.h"
-
-
-namespace clitk
-{
-
-//=========================================================================================================================
-//constructor
-template <class args_info_type, class ImageType, class TCoordRep>
-GenericInterpolator<args_info_type, ImageType, TCoordRep>::GenericInterpolator()
-{
- m_Interpolator=NULL;
- m_Verbose=false;
-}
-
-
-//=========================================================================================================================
-//Get the pointer
-template <class args_info_type, class ImageType, class TCoordRep>
-typename GenericInterpolator<args_info_type, ImageType, TCoordRep>::InterpolatorPointer
-GenericInterpolator<args_info_type, ImageType, TCoordRep>::GetInterpolatorPointer()
-{
- //============================================================================
- // We retrieve the type of interpolation from the command line
- //============================================================================
- typename InterpolatorType::Pointer interpolator;
-
- switch ( m_ArgsInfo.interp_arg ) {
- case 0:
-
- interpolator= itk::NearestNeighborInterpolateImageFunction< ImageType,TCoordRep >::New();
- if (m_Verbose) std::cout<<"Using nearestneighbor interpolation..."<<std::endl;
- break;
-
- case 1:
-
- interpolator = itk::LinearInterpolateImageFunction< ImageType,TCoordRep >::New();
- if (m_Verbose) std::cout<<"Using linear interpolation..."<<std::endl;
- break;
-
- case 2: {
- typename itk::BSplineInterpolateImageFunction< ImageType,TCoordRep >::Pointer m =itk::BSplineInterpolateImageFunction< ImageType,TCoordRep >::New();
- m->SetSplineOrder(m_ArgsInfo.interpOrder_arg);
- interpolator=m;
- if (m_Verbose) std::cout<<"Using Bspline interpolation..."<<std::endl;
- break;
- }
-
- case 3: {
- typename itk::BSplineInterpolateImageFunctionWithLUT< ImageType,TCoordRep >::Pointer m =itk::BSplineInterpolateImageFunctionWithLUT< ImageType,TCoordRep >::New();
- m->SetSplineOrder(m_ArgsInfo.interpOrder_arg);
- m->SetLUTSamplingFactor(m_ArgsInfo.interpSF_arg);
- interpolator=m;
- if (m_Verbose) std::cout<<"Using BLUT interpolation..."<<std::endl;
- break;
- }
-
-
- }//end of switch
-
-
- //============================================================================
- //return the pointer
- return interpolator;
-}
-
-}
-
-#endif
+++ /dev/null
-/*=========================================================================
- 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 __clitkGenericVectorInterpolator_h
-#define __clitkGenericVectorInterpolator_h
-#include "clitkImageCommon.h"
-
-//itk include
-#include "itkVectorNearestNeighborInterpolateImageFunction.h"
-#include "itkVectorLinearInterpolateImageFunction.h"
-#include "clitkVectorBSplineInterpolateImageFunction.h"
-#include "clitkVectorBSplineInterpolateImageFunctionWithLUT.h"
-
-/*
-
-Requires at least the following section is the .ggo file
-
-option "interpVF" - "Interpolation: 0=NN, 1=Linear, 2=BSpline, 3=BLUT" int no default="1"
-option "interpVFOrder" - "Order if BLUT or BSpline (0-5)" int no default="3"
-option "interpVFSF" - "Sampling factor if BLUT" int no default="20"
-
-*/
-
-namespace clitk
-{
-
- template <class args_info_type, class ImageType, class TCoordRep >
- class GenericVectorInterpolator : public itk::LightObject
- {
- public:
- //==============================================
- typedef GenericVectorInterpolator Self;
- typedef itk::LightObject Superclass;
- typedef itk::SmartPointer<Self> Pointer;
- typedef itk::SmartPointer<const Self> ConstPointer;
-
- typedef itk::VectorInterpolateImageFunction<ImageType, TCoordRep> InterpolatorType;
- typedef typename InterpolatorType::Pointer InterpolatorPointer;
-
- /** Method for creation through the object factory. */
- itkNewMacro(Self);
-
- //==============================================
- //Set members
- void SetArgsInfo(args_info_type args_info)
- {
- m_ArgsInfo= args_info;
- m_Verbose=m_ArgsInfo.verbose_flag;
- }
-
- //==============================================
- //Get members
- InterpolatorPointer GetInterpolatorPointer(void);
-
- //==============================================
- protected:
- GenericVectorInterpolator();
- ~GenericVectorInterpolator() {};
-
- private:
- args_info_type m_ArgsInfo;
- InterpolatorPointer m_Interpolator;
- bool m_Verbose;
- };
-
-} // end namespace clitk
-#ifndef ITK_MANUAL_INSTANTIATION
-#include "clitkGenericVectorInterpolator.txx"
-#endif
-
-#endif // #define __clitkGenericVectorInterpolator_h
+++ /dev/null
-/*=========================================================================
- 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 __clitkGenericVectorInterpolator_txx
-#define __clitkGenericVectorInterpolator_txx
-#include "clitkGenericVectorInterpolator.h"
-
-
-namespace clitk
-{
-
-//=========================================================================================================================
-//constructor
-template <class args_info_type, class ImageType, class TCoordRep>
-GenericVectorInterpolator<args_info_type, ImageType, TCoordRep>::GenericVectorInterpolator()
-{
- m_Interpolator=NULL;
- m_Verbose=false;
-}
-
-
-//=========================================================================================================================
-//Get the pointer
-template <class args_info_type, class ImageType, class TCoordRep>
-typename GenericVectorInterpolator<args_info_type, ImageType, TCoordRep>::InterpolatorPointer
-GenericVectorInterpolator<args_info_type, ImageType, TCoordRep>::GetInterpolatorPointer()
-{
- //============================================================================
- // We retrieve the type of interpolation from the command line
- //============================================================================
- typename InterpolatorType::Pointer interpolator;
-
- switch ( m_ArgsInfo.interpVF_arg ) {
- case 0:
-
- interpolator= itk::VectorNearestNeighborInterpolateImageFunction< ImageType,TCoordRep >::New();
- if (m_Verbose) std::cout<<"Using nearestneighbor interpolation..."<<std::endl;
- break;
-
- case 1:
-
- interpolator = itk::VectorLinearInterpolateImageFunction< ImageType,TCoordRep >::New();
- if (m_Verbose) std::cout<<"Using linear interpolation..."<<std::endl;
- break;
-
- case 2: {
- typename clitk::VectorBSplineInterpolateImageFunction< ImageType,TCoordRep >::Pointer m =clitk::VectorBSplineInterpolateImageFunction< ImageType,TCoordRep >::New();
- m->SetSplineOrder(m_ArgsInfo.interpVFOrder_arg);
- interpolator=m;
- if (m_Verbose) std::cout<<"Using Bspline interpolation..."<<std::endl;
- break;
- }
-
- case 3: {
- typename clitk::VectorBSplineInterpolateImageFunctionWithLUT< ImageType,TCoordRep >::Pointer m =clitk::VectorBSplineInterpolateImageFunctionWithLUT< ImageType,TCoordRep >::New();
- m->SetSplineOrder(m_ArgsInfo.interpVFOrder_arg);
- m->SetLUTSamplingFactor(m_ArgsInfo.interpVFSF_arg);
- interpolator=m;
- if (m_Verbose) std::cout<<"Using BLUT interpolation..."<<std::endl;
- break;
- }
-
- }//end of switch
-
-
- //============================================================================
- //return the pointer
- return interpolator;
-}
-
-}
-
-#endif
--- /dev/null
+/*=========================================================================
+ 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 __clitkRayCastInterpolateImageFunctionWithOrigin_h
+#define __clitkRayCastInterpolateImageFunctionWithOrigin_h
+#include "clitkBSplineDeformableTransform.h"
+
+#include "itkInterpolateImageFunction.h"
+#include "itkTransform.h"
+#include "itkVector.h"
+
+namespace clitk
+{
+
+
+template <class TInputImage, class TCoordRep = float>
+class ITK_EXPORT RayCastInterpolateImageFunctionWithOrigin :
+ public itk::InterpolateImageFunction<TInputImage,TCoordRep>
+{
+public:
+ /** Standard class typedefs. */
+ typedef RayCastInterpolateImageFunctionWithOrigin Self;
+ typedef itk::InterpolateImageFunction<TInputImage,TCoordRep> Superclass;
+ typedef itk::SmartPointer<Self> Pointer;
+ typedef itk::SmartPointer<const Self> ConstPointer;
+
+ /** Constants for the image dimensions */
+ itkStaticConstMacro(InputImageDimension, unsigned int,
+ TInputImage::ImageDimension);
+
+ /**
+ * Type of the Transform Base class
+ * The fixed image should be a 3D image
+ */
+ typedef itk::Transform<TCoordRep,3,3> TransformType;
+
+ typedef typename TransformType::Pointer TransformPointer;
+ typedef typename TransformType::InputPointType InputPointType;
+ typedef typename TransformType::OutputPointType OutputPointType;
+ typedef typename TransformType::ParametersType TransformParametersType;
+ typedef typename TransformType::JacobianType TransformJacobianType;
+
+ typedef typename Superclass::InputPixelType PixelType;
+
+ typedef typename TInputImage::SizeType SizeType;
+
+ typedef itk::Vector<TCoordRep, 3> DirectionType;
+
+ /** Type of the Interpolator Base class */
+ typedef itk::InterpolateImageFunction<TInputImage,TCoordRep> InterpolatorType;
+
+ typedef typename InterpolatorType::Pointer InterpolatorPointer;
+
+ //JV Type of the Interpolator for the transform
+ typedef itk::InterpolateImageFunction<TInputImage,TCoordRep> DeformableTransformInterpolatorType;
+ typedef typename DeformableTransformInterpolatorType::Pointer DeformableTransformInterpolatorPointer;
+
+
+ /** Run-time type information (and related methods). */
+ itkTypeMacro(RayCastInterpolateImageFunctionWithOrigin, InterpolateImageFunction);
+
+ /** Method for creation through the object factory. */
+ itkNewMacro(Self);
+
+ /** OutputType typedef support. */
+ typedef typename Superclass::OutputType OutputType;
+
+ /** InputImageType typedef support. */
+ typedef typename Superclass::InputImageType InputImageType;
+
+ /** RealType typedef support. */
+ typedef typename Superclass::RealType RealType;
+
+ /** Dimension underlying input image. */
+ itkStaticConstMacro(ImageDimension, unsigned int,Superclass::ImageDimension);
+
+ /** Point typedef support. */
+ typedef typename Superclass::PointType PointType;
+
+ /** Index typedef support. */
+ typedef typename Superclass::IndexType IndexType;
+
+ /** ContinuousIndex typedef support. */
+ typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
+
+ /** \brief
+ * Interpolate the image at a point position.
+ *
+ * Returns the interpolated image intensity at a
+ * specified point position. No bounds checking is done.
+ * The point is assume to lie within the image buffer.
+ *
+ * ImageFunction::IsInsideBuffer() can be used to check bounds before
+ * calling the method.
+ */
+ virtual OutputType Evaluate( const PointType& point ) const;
+
+ /** Interpolate the image at a continuous index position
+ *
+ * Returns the interpolated image intensity at a
+ * specified index position. No bounds checking is done.
+ * The point is assume to lie within the image buffer.
+ *
+ * Subclasses must override this method.
+ *
+ * ImageFunction::IsInsideBuffer() can be used to check bounds before
+ * calling the method.
+ */
+ virtual OutputType EvaluateAtContinuousIndex(
+ const ContinuousIndexType &index ) const;
+
+
+ /** Connect the Transform. */
+ itkSetObjectMacro( Transform, TransformType );
+ /** Get a pointer to the Transform. */
+ itkGetObjectMacro( Transform, TransformType );
+
+ /** Connect the Interpolator. */
+ itkSetObjectMacro( Interpolator, InterpolatorType );
+ /** Get a pointer to the Interpolator. */
+ itkGetObjectMacro( Interpolator, InterpolatorType );
+
+ /** Connect the focalPoint. */
+ itkSetMacro( FocalPoint, InputPointType );
+ /** Get a pointer to the focalpoint. */
+ itkGetMacro( FocalPoint, InputPointType );
+
+ /** Connect the threshold. */
+ itkSetMacro( Threshold, double );
+ /** Get a pointer to the threshhold. */
+ itkGetMacro( Threshold, double );
+
+ /** Check if a point is inside the image buffer.
+ * \warning For efficiency, no validity checking of
+ * the input image pointer is done. */
+ inline bool IsInsideBuffer( const PointType & ) const
+ {
+ return true;
+ }
+ bool IsInsideBuffer( const ContinuousIndexType & ) const
+ {
+ return true;
+ }
+ bool IsInsideBuffer( const IndexType & ) const
+ {
+ return true;
+ }
+
+ //JV transform is deformable
+ itkSetMacro( TransformIsDeformable, bool );
+ itkGetMacro( TransformIsDeformable, bool );
+
+ //JV interpolator for deformable transform
+ itkSetObjectMacro( DeformableTransformInterpolator, DeformableTransformInterpolatorType );
+ itkGetObjectMacro( DeformableTransformInterpolator, DeformableTransformInterpolatorType );
+
+protected:
+
+ /// Constructor
+ RayCastInterpolateImageFunctionWithOrigin();
+
+ /// Destructor
+ ~RayCastInterpolateImageFunctionWithOrigin(){};
+
+ /// Print the object
+ void PrintSelf(std::ostream& os, itk::Indent indent) const;
+
+ /// Transformation used to calculate the new focal point position
+ TransformPointer m_Transform;
+
+ /// The focal point or position of the ray source
+ InputPointType m_FocalPoint;
+
+ /// The threshold above which voxels along the ray path are integrated.
+ double m_Threshold;
+
+ /// Pointer to the interpolator
+ InterpolatorPointer m_Interpolator;
+
+ //JV Pointer to the deformable transform interpolator
+ DeformableTransformInterpolatorPointer m_DeformableTransformInterpolator;
+
+
+ //JV Transform is deformable: fetch interpolated value at transformed intersect
+ bool m_TransformIsDeformable;
+
+
+private:
+ RayCastInterpolateImageFunctionWithOrigin( const Self& ); //purposely not implemented
+ void operator=( const Self& ); //purposely not implemented
+
+
+};
+
+} // namespace clitk
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#include "clitkRayCastInterpolateImageFunctionWithOrigin.txx"
+#endif
+
+#endif
--- /dev/null
+/*=========================================================================
+ 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 __clitkRayCastInterpolateImageFunctionWithOrigin_txx
+#define __clitkRayCastInterpolateImageFunctionWithOrigin_txx
+#include "clitkRayCastInterpolateImageFunctionWithOrigin.h"
+#include "itkContinuousIndex.h"
+#include "vnl/vnl_math.h"
+
+
+// Put the helper class in an anonymous namespace so that it is not
+// exposed to the user
+namespace {
+
+ /** \class Helper class to maintain state when casting a ray.
+ * This helper class keeps the RayCastInterpolateImageFunctionWithOrigin thread safe.
+ */
+ template <class TInputImage, class TCoordRep = float>
+ class RayCastHelper
+ {
+ public:
+ /** Constants for the image dimensions */
+ itkStaticConstMacro(InputImageDimension, unsigned int,
+ TInputImage::ImageDimension);
+
+ /**
+ * Type of the Transform Base class
+ * The fixed image should be a 3D image
+ */
+ typedef itk::Transform<TCoordRep,3,3> TransformType;
+
+ typedef typename TransformType::Pointer TransformPointer;
+ typedef typename TransformType::InputPointType InputPointType;
+ typedef typename TransformType::OutputPointType OutputPointType;
+ typedef typename TransformType::ParametersType TransformParametersType;
+ typedef typename TransformType::JacobianType TransformJacobianType;
+
+ typedef typename TInputImage::SizeType SizeType;
+ typedef itk::Vector<TCoordRep, 3> DirectionType;
+ typedef itk::Point<TCoordRep, 3> PointType;
+
+ typedef TInputImage InputImageType;
+ typedef typename InputImageType::PixelType PixelType;
+ typedef typename InputImageType::IndexType IndexType;
+ typedef itk::ContinuousIndex<TCoordRep, 3> ContinuousIndexType;
+
+
+ //JV Add an interpolator for the deformable transform
+ typedef itk::InterpolateImageFunction<InputImageType, double> InterpolatorType;
+ typedef typename InterpolatorType::Pointer InterpolatorPointer;
+
+
+ /**
+ * Set the image class
+ */
+ void SetImage(const InputImageType *input)
+ {
+ m_Image = input;
+ }
+
+ /**
+ * Initialise the ray using the position and direction of a line.
+ *
+ * \param RayPosn The position of the ray in 3D (mm).
+ * \param RayDirn The direction of the ray in 3D (mm).
+ *
+ * \return True if this is a valid ray.
+ */
+ bool SetRay(OutputPointType RayPosn, DirectionType RayDirn);
+
+
+ /** \brief
+ * Integrate the interpolated intensities along the ray and
+ * return the result.
+ *
+ * This routine can be called after instantiating the ray and
+ * calling SetProjectionCoord2D() or Reset(). It may then be called
+ * as many times thereafter for different 2D projection
+ * coordinates.
+ *
+ * \param integral The integrated intensities along the ray.
+ *
+ * \return True if a valid ray was specified.
+ */
+ bool Integrate(double &integral)
+ {
+ return IntegrateAboveThreshold(integral, 0);
+ };
+
+
+ /** \brief
+ * Integrate the interpolated intensities above a given threshold,
+ * along the ray and return the result.
+ *
+ * This routine can be called after instantiating the ray and
+ * calling SetProjectionCoord2D() or Reset(). It may then be called
+ * as many times thereafter for different 2D projection
+ * coordinates.
+ *
+ * \param integral The integrated intensities along the ray.
+ * \param threshold The integration threshold [default value: 0]
+ *
+ * \return True if a valid ray was specified.
+ */
+ bool IntegrateAboveThreshold(double &integral, double threshold);
+
+ /** \brief
+ * Increment each of the intensities of the 4 planar voxels
+ * surrounding the current ray point.
+ *
+ * \parameter increment Intensity increment for each of the current 4 voxels
+ */
+ void IncrementIntensities(double increment=1);
+
+ /// Reset the iterator to the start of the ray.
+ void Reset(void);
+
+ /// Return the interpolated intensity of the current ray point.
+ double GetCurrentIntensity(void) const;
+
+ /// Return the ray point spacing in mm
+ double GetRayPointSpacing(void) const {
+ typename InputImageType::SpacingType spacing=this->m_Image->GetSpacing();
+
+ if (m_ValidRay)
+ return vcl_sqrt(m_VoxelIncrement[0]*spacing[0]*m_VoxelIncrement[0]*spacing[0]
+ + m_VoxelIncrement[1]*spacing[1]*m_VoxelIncrement[1]*spacing[1]
+ + m_VoxelIncrement[2]*spacing[2]*m_VoxelIncrement[2]*spacing[2] );
+ else
+ return 0.;
+ };
+
+ /// Set the initial zero state of the object
+ void ZeroState();
+
+ /// Initialise the object
+ void Initialise(void);
+
+ //JV set transform and interpolator
+ void SetTransformIsDeformable(bool m){m_TransformIsDeformable=m;}
+ void SetTransform (TransformType* m){m_Transform=m;}
+ void SetDeformableTransformInterpolator(InterpolatorType* m){m_DeformableTransformInterpolator=m;}
+
+ protected:
+ /// Calculate the endpoint coordinats of the ray in voxels.
+ void EndPointsInVoxels(void);
+
+ /**
+ * Calculate the incremental direction vector in voxels, 'dVoxel',
+ * required to traverse the ray.
+ */
+ void CalcDirnVector(void);
+
+ /**
+ * Reduce the length of the ray until both start and end
+ * coordinates lie inside the volume.
+ *
+ * \return True if a valid ray has been, false otherwise.
+ */
+ bool AdjustRayLength(void);
+
+ /**
+ * Obtain pointers to the four voxels surrounding the point where the ray
+ * enters the volume.
+ */
+ void InitialiseVoxelPointers(void);
+
+ /// Increment the voxel pointers surrounding the current point on the ray.
+ void IncrementVoxelPointers(void);
+
+ /// Record volume dimensions and resolution
+ void RecordVolumeDimensions(void);
+
+ /// Define the corners of the volume
+ void DefineCorners(void);
+
+ /** \brief
+ * Calculate the planes which define the volume.
+ *
+ * Member function to calculate the equations of the planes of 4 of
+ * the sides of the volume, calculate the positions of the 8 corners
+ * of the volume in mm in World, also calculate the values of the
+ * slopes of the lines which go to make up the volume( defined as
+ * lines in cube x,y,z dirn and then each of these lines has a slope
+ * in the world x,y,z dirn [3]) and finally also to return the length
+ * of the sides of the lines in mm.
+ */
+ void CalcPlanesAndCorners(void);
+
+ /** \brief
+ * Calculate the ray intercepts with the volume.
+ *
+ * See where the ray cuts the volume, check that truncation does not occur,
+ * if not, then start ray where it first intercepts the volume and set
+ * x_max to be where it leaves the volume.
+ *
+ * \return True if a valid ray has been specified, false otherwise.
+ */
+ bool CalcRayIntercepts(void);
+
+ /**
+ * The ray is traversed by stepping in the axial direction
+ * that enables the greatest number of planes in the volume to be
+ * intercepted.
+ */
+ typedef enum {
+ UNDEFINED_DIRECTION=0, //!< Undefined
+ TRANSVERSE_IN_X, //!< x
+ TRANSVERSE_IN_Y, //!< y
+ TRANSVERSE_IN_Z, //!< z
+ LAST_DIRECTION
+ } TraversalDirection;
+
+ // Cache the image in the structure. Skip the smart pointer for
+ // efficiency. This inner class will go in/out of scope with every
+ // call to Evaluate()
+ const InputImageType *m_Image;
+
+ /// Flag indicating whether the current ray is valid
+ bool m_ValidRay;
+
+ /** \brief
+ * The start position of the ray in voxels.
+ *
+ * NB. Two of the components of this coordinate (i.e. those lying within
+ * the planes of voxels being traversed) will be shifted by half a
+ * voxel. This enables indices of the neighbouring voxels within the plane
+ * to be determined by simply casting to 'int' and optionally adding 1.
+ */
+ double m_RayVoxelStartPosition[3];
+
+ /** \brief
+ * The end coordinate of the ray in voxels.
+ *
+ * NB. Two of the components of this coordinate (i.e. those lying within
+ * the planes of voxels being traversed) will be shifted by half a
+ * voxel. This enables indices of the neighbouring voxels within the plane
+ * to be determined by simply casting to 'int' and optionally adding 1.
+ */
+ double m_RayVoxelEndPosition[3];
+
+
+ /** \brief
+ * The current coordinate on the ray in voxels.
+ *
+ * NB. Two of the components of this coordinate (i.e. those lying within
+ * the planes of voxels being traversed) will be shifted by half a
+ * voxel. This enables indices of the neighbouring voxels within the plane
+ * to be determined by simply casting to 'int' and optionally adding 1.
+ */
+ double m_Position3Dvox[3];
+
+ /** The incremental direction vector of the ray in voxels. */
+ double m_VoxelIncrement[3];
+
+ /// The direction in which the ray is incremented thorough the volume (x, y or z).
+ TraversalDirection m_TraversalDirection;
+
+ /// The total number of planes of voxels traversed by the ray.
+ int m_TotalRayVoxelPlanes;
+
+ /// The current number of planes of voxels traversed by the ray.
+ int m_NumVoxelPlanesTraversed;
+
+ /// Pointers to the current four voxels surrounding the ray's trajectory.
+ const PixelType *m_RayIntersectionVoxels[4];
+
+ /**
+ * The voxel coordinate of the bottom-left voxel of the current
+ * four voxels surrounding the ray's trajectory.
+ */
+ int m_RayIntersectionVoxelIndex[3];
+
+ /// The dimension in voxels of the 3D volume in along the x axis
+ int m_NumberOfVoxelsInX;
+ /// The dimension in voxels of the 3D volume in along the y axis
+ int m_NumberOfVoxelsInY;
+ /// The dimension in voxels of the 3D volume in along the z axis
+ int m_NumberOfVoxelsInZ;
+
+ /// Voxel dimension in x
+ double m_VoxelDimensionInX;
+ /// Voxel dimension in y
+ double m_VoxelDimensionInY;
+ /// Voxel dimension in z
+ double m_VoxelDimensionInZ;
+
+ /// The coordinate of the point at which the ray enters the volume in mm.
+ double m_RayStartCoordInMM[3];
+ /// The coordinate of the point at which the ray exits the volume in mm.
+ double m_RayEndCoordInMM[3];
+
+
+ /** \brief
+ Planes which define the boundary of the volume in mm
+ (six planes and four parameters: Ax+By+Cz+D). */
+ double m_BoundingPlane[6][4];
+ /// The eight corners of the volume (x,y,z coordinates for each).
+ double m_BoundingCorner[8][3];
+
+ /// The position of the ray
+ double m_CurrentRayPositionInMM[3];
+
+ /// The direction of the ray
+ double m_RayDirectionInMM[3];
+
+ //JV transform is deformable
+ bool m_TransformIsDeformable;
+ TransformType* m_Transform;
+ InterpolatorType* m_DeformableTransformInterpolator;
+
+ };
+
+ /* -----------------------------------------------------------------------
+ Initialise() - Initialise the object
+ ----------------------------------------------------------------------- */
+
+ template<class TInputImage, class TCoordRep>
+ void
+ RayCastHelper<TInputImage, TCoordRep>
+ ::Initialise(void)
+ {
+ // Save the dimensions of the volume and calculate the bounding box
+ this->RecordVolumeDimensions();
+
+ // Calculate the planes and corners which define the volume.
+ this->DefineCorners();
+ this->CalcPlanesAndCorners();
+ }
+
+
+ /* -----------------------------------------------------------------------
+ RecordVolumeDimensions() - Record volume dimensions and resolution
+ ----------------------------------------------------------------------- */
+
+ template<class TInputImage, class TCoordRep>
+ void
+ RayCastHelper<TInputImage, TCoordRep>
+ ::RecordVolumeDimensions(void)
+ {
+ typename InputImageType::SpacingType spacing=this->m_Image->GetSpacing();
+ SizeType dim=this->m_Image->GetLargestPossibleRegion().GetSize();
+
+ m_NumberOfVoxelsInX = dim[0];
+ m_NumberOfVoxelsInY = dim[1];
+ m_NumberOfVoxelsInZ = dim[2];
+
+ m_VoxelDimensionInX = spacing[0];
+ m_VoxelDimensionInY = spacing[1];
+ m_VoxelDimensionInZ = spacing[2];
+ }
+
+
+ /* -----------------------------------------------------------------------
+ DefineCorners() - Define the corners of the volume
+ ----------------------------------------------------------------------- */
+
+ template<class TInputImage, class TCoordRep>
+ void
+ RayCastHelper<TInputImage, TCoordRep>
+ ::DefineCorners(void)
+ {
+ // Define corner positions as if at the origin
+
+ m_BoundingCorner[0][0] =
+ m_BoundingCorner[1][0] =
+ m_BoundingCorner[2][0] =
+ m_BoundingCorner[3][0] = 0;
+
+ m_BoundingCorner[4][0] =
+ m_BoundingCorner[5][0] =
+ m_BoundingCorner[6][0] =
+ m_BoundingCorner[7][0] = m_VoxelDimensionInX*m_NumberOfVoxelsInX;
+
+ m_BoundingCorner[1][1] =
+ m_BoundingCorner[3][1] =
+ m_BoundingCorner[5][1] =
+ m_BoundingCorner[7][1] = m_VoxelDimensionInY*m_NumberOfVoxelsInY;
+
+ m_BoundingCorner[0][1] =
+ m_BoundingCorner[2][1] =
+ m_BoundingCorner[4][1] =
+ m_BoundingCorner[6][1] = 0;
+
+ m_BoundingCorner[0][2] =
+ m_BoundingCorner[1][2] =
+ m_BoundingCorner[4][2] =
+ m_BoundingCorner[5][2] =
+ m_VoxelDimensionInZ*m_NumberOfVoxelsInZ;
+
+ m_BoundingCorner[2][2] =
+ m_BoundingCorner[3][2] =
+ m_BoundingCorner[6][2] =
+ m_BoundingCorner[7][2] = 0;
+
+ }
+
+ /* -----------------------------------------------------------------------
+ CalcPlanesAndCorners() - Calculate the planes and corners of the volume.
+ ----------------------------------------------------------------------- */
+
+ template<class TInputImage, class TCoordRep>
+ void
+ RayCastHelper<TInputImage, TCoordRep>
+ ::CalcPlanesAndCorners(void)
+ {
+ int j;
+
+
+ // find the equations of the planes
+
+ int c1=0, c2=0, c3=0;
+
+ for (j=0; j<6; j++)
+ { // loop around for planes
+ switch (j)
+ { // which corners to take
+ case 0:
+ c1=1; c2=2; c3=3;
+ break;
+ case 1:
+ c1=4; c2=5; c3=6;
+ break;
+ case 2:
+ c1=5; c2=3; c3=7;
+ break;
+ case 3:
+ c1=2; c2=4; c3=6;
+ break;
+ case 4:
+ c1=1; c2=5; c3=0;
+ break;
+ case 5:
+ c1=3; c2=7; c3=2;
+ break;
+ }
+
+
+ double line1x, line1y, line1z;
+ double line2x, line2y, line2z;
+
+ // lines from one corner to another in x,y,z dirns
+ line1x = m_BoundingCorner[c1][0] - m_BoundingCorner[c2][0];
+ line2x = m_BoundingCorner[c1][0] - m_BoundingCorner[c3][0];
+
+ line1y = m_BoundingCorner[c1][1] - m_BoundingCorner[c2][1];
+ line2y = m_BoundingCorner[c1][1] - m_BoundingCorner[c3][1];
+
+ line1z = m_BoundingCorner[c1][2] - m_BoundingCorner[c2][2];
+ line2z = m_BoundingCorner[c1][2] - m_BoundingCorner[c3][2];
+
+ double A, B, C, D;
+
+ // take cross product
+ A = line1y*line2z - line2y*line1z;
+ B = line2x*line1z - line1x*line2z;
+ C = line1x*line2y - line2x*line1y;
+
+ // find constant
+ D = -( A*m_BoundingCorner[c1][0]
+ + B*m_BoundingCorner[c1][1]
+ + C*m_BoundingCorner[c1][2] );
+
+ // initialise plane value and normalise
+ m_BoundingPlane[j][0] = A/vcl_sqrt(A*A + B*B + C*C);
+ m_BoundingPlane[j][1] = B/vcl_sqrt(A*A + B*B + C*C);
+ m_BoundingPlane[j][2] = C/vcl_sqrt(A*A + B*B + C*C);
+ m_BoundingPlane[j][3] = D/vcl_sqrt(A*A + B*B + C*C);
+
+ if ( (A*A + B*B + C*C) == 0 )
+ {
+ itk::ExceptionObject err(__FILE__, __LINE__);
+ err.SetLocation( ITK_LOCATION );
+ err.SetDescription( "Division by zero (planes) "
+ "- CalcPlanesAndCorners().");
+ throw err;
+ }
+ }
+
+ }
+
+
+ /* -----------------------------------------------------------------------
+ CalcRayIntercepts() - Calculate the ray intercepts with the volume.
+ ----------------------------------------------------------------------- */
+
+ template<class TInputImage, class TCoordRep>
+ bool
+ RayCastHelper<TInputImage, TCoordRep>
+ ::CalcRayIntercepts()
+ {
+ double maxInterDist, interDist;
+ double cornerVect[4][3];
+ int cross[4][3], noInterFlag[6];
+ int nSidesCrossed, crossFlag, c[4];
+ double ax, ay, az, bx, by, bz;
+ double cubeInter[6][3];
+ double denom;
+
+ int i,j, k;
+ int NoSides = 6; // =6 to allow truncation: =4 to remove truncated rays
+
+ // Calculate intercept of ray with planes
+
+ double interceptx[6], intercepty[6], interceptz[6];
+ double d[6];
+
+ for( j=0; j<NoSides; j++)
+ {
+
+ denom = ( m_BoundingPlane[j][0]*m_RayDirectionInMM[0]
+ + m_BoundingPlane[j][1]*m_RayDirectionInMM[1]
+ + m_BoundingPlane[j][2]*m_RayDirectionInMM[2]);
+
+ if( (long)(denom*100) != 0 )
+ {
+ d[j] = -( m_BoundingPlane[j][3]
+ + m_BoundingPlane[j][0]*m_CurrentRayPositionInMM[0]
+ + m_BoundingPlane[j][1]*m_CurrentRayPositionInMM[1]
+ + m_BoundingPlane[j][2]*m_CurrentRayPositionInMM[2] ) / denom;
+
+ interceptx[j] = m_CurrentRayPositionInMM[0] + d[j]*m_RayDirectionInMM[0];
+ intercepty[j] = m_CurrentRayPositionInMM[1] + d[j]*m_RayDirectionInMM[1];
+ interceptz[j] = m_CurrentRayPositionInMM[2] + d[j]*m_RayDirectionInMM[2];
+
+ noInterFlag[j] = 1; //OK
+ }
+ else
+ {
+ noInterFlag[j] = 0; //NOT OK
+ }
+ }
+
+
+ nSidesCrossed = 0;
+ for( j=0; j<NoSides; j++ )
+ {
+
+ // Work out which corners to use
+
+ if( j==0 )
+ {
+ c[0] = 0; c[1] = 1; c[2] = 3; c[3] = 2;
+ }
+ else if( j==1 )
+ {
+ c[0] = 4; c[1] = 5; c[2] = 7; c[3] = 6;
+ }
+ else if( j==2 )
+ {
+ c[0] = 1; c[1] = 5; c[2] = 7; c[3] = 3;
+ }
+ else if( j==3 )
+ {
+ c[0] = 0; c[1] = 2; c[2] = 6; c[3] = 4;
+ }
+ else if( j==4 )
+ { //TOP
+ c[0] = 0; c[1] = 1; c[2] = 5; c[3] = 4;
+ }
+ else if( j==5 )
+ { //BOTTOM
+ c[0] = 2; c[1] = 3; c[2] = 7; c[3] = 6;
+ }
+
+ // Calculate vectors from corner of ct volume to intercept.
+ for( i=0; i<4; i++ )
+ {
+ if( noInterFlag[j]==1 )
+ {
+ cornerVect[i][0] = m_BoundingCorner[c[i]][0] - interceptx[j];
+ cornerVect[i][1] = m_BoundingCorner[c[i]][1] - intercepty[j];
+ cornerVect[i][2] = m_BoundingCorner[c[i]][2] - interceptz[j];
+ }
+ else if( noInterFlag[j]==0 )
+ {
+ cornerVect[i][0] = 0;
+ cornerVect[i][1] = 0;
+ cornerVect[i][2] = 0;
+ }
+
+ }
+
+ // Do cross product with these vectors
+ for( i=0; i<4; i++ )
+ {
+ if( i==3 )
+ {
+ k = 0;
+ }
+ else
+ {
+ k = i+1;
+ }
+ ax = cornerVect[i][0];
+ ay = cornerVect[i][1];
+ az = cornerVect[i][2];
+ bx = cornerVect[k][0];
+ by = cornerVect[k][1];
+ bz = cornerVect[k][2];
+
+ // The int and divide by 100 are to avoid rounding errors. If
+ // these are not included then you get values fluctuating around
+ // zero and so in the subsequent check, all the values are not
+ // above or below zero. NB. If you "INT" by too much here though
+ // you can get problems in the corners of your volume when rays
+ // are allowed to go through more than one plane.
+ cross[i][0] = (int)((ay*bz - az*by)/100);
+ cross[i][1] = (int)((az*bx - ax*bz)/100);
+ cross[i][2] = (int)((ax*by - ay*bx)/100);
+ }
+
+ // See if a sign change occured between all these cross products
+ // if not, then the ray went through this plane
+
+ crossFlag=0;
+ for( i=0; i<3; i++ )
+ {
+ if( ( cross[0][i]<=0
+ && cross[1][i]<=0
+ && cross[2][i]<=0
+ && cross[3][i]<=0)
+
+ || ( cross[0][i]>=0
+ && cross[1][i]>=0
+ && cross[2][i]>=0
+ && cross[3][i]>=0) )
+ {
+ crossFlag++;
+ }
+ }
+
+
+ if( crossFlag==3 && noInterFlag[j]==1 )
+ {
+ cubeInter[nSidesCrossed][0] = interceptx[j];
+ cubeInter[nSidesCrossed][1] = intercepty[j];
+ cubeInter[nSidesCrossed][2] = interceptz[j];
+ nSidesCrossed++;
+ }
+
+ } // End of loop over all four planes
+
+ m_RayStartCoordInMM[0] = cubeInter[0][0];
+ m_RayStartCoordInMM[1] = cubeInter[0][1];
+ m_RayStartCoordInMM[2] = cubeInter[0][2];
+
+ m_RayEndCoordInMM[0] = cubeInter[1][0];
+ m_RayEndCoordInMM[1] = cubeInter[1][1];
+ m_RayEndCoordInMM[2] = cubeInter[1][2];
+
+ if( nSidesCrossed >= 5 )
+ {
+ std::cerr << "WARNING: No. of sides crossed equals: " << nSidesCrossed << std::endl;
+ }
+
+ // If 'nSidesCrossed' is larger than 2, this means that the ray goes through
+ // a corner of the volume and due to rounding errors, the ray is
+ // deemed to go through more than two planes. To obtain the correct
+ // start and end positions we choose the two intercept values which
+ // are furthest from each other.
+
+
+ if( nSidesCrossed >= 3 )
+ {
+ maxInterDist = 0;
+ for( j=0; j<nSidesCrossed-1; j++ )
+ {
+ for( k=j+1; k<nSidesCrossed; k++ )
+ {
+ interDist = 0;
+ for( i=0; i<3; i++ )
+ {
+ interDist += (cubeInter[j][i] - cubeInter[k][i])*
+ (cubeInter[j][i] - cubeInter[k][i]);
+ }
+ if( interDist > maxInterDist )
+ {
+ maxInterDist = interDist;
+
+ m_RayStartCoordInMM[0] = cubeInter[j][0];
+ m_RayStartCoordInMM[1] = cubeInter[j][1];
+ m_RayStartCoordInMM[2] = cubeInter[j][2];
+
+ m_RayEndCoordInMM[0] = cubeInter[k][0];
+ m_RayEndCoordInMM[1] = cubeInter[k][1];
+ m_RayEndCoordInMM[2] = cubeInter[k][2];
+ }
+ }
+ }
+ nSidesCrossed = 2;
+ }
+
+ if (nSidesCrossed == 2 )
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+
+ /* -----------------------------------------------------------------------
+ SetRay() - Set the position and direction of the ray
+ ----------------------------------------------------------------------- */
+
+ template<class TInputImage, class TCoordRep>
+ bool
+ RayCastHelper<TInputImage, TCoordRep>
+ ::SetRay(OutputPointType RayPosn, DirectionType RayDirn)
+ {
+
+ // Store the position and direction of the ray
+ typename TInputImage::SpacingType spacing=this->m_Image->GetSpacing();
+ SizeType dim=this->m_Image->GetLargestPossibleRegion().GetSize();
+
+ // we need to translate the _center_ of the volume to the origin
+ m_NumberOfVoxelsInX = dim[0];
+ m_NumberOfVoxelsInY = dim[1];
+ m_NumberOfVoxelsInZ = dim[2];
+
+ m_VoxelDimensionInX = spacing[0];
+ m_VoxelDimensionInY = spacing[1];
+ m_VoxelDimensionInZ = spacing[2];
+
+ // (Aviv) Incorporating a fix by Jian Wu
+ // http://public.kitware.com/pipermail/insight-users/2006-March/017265.html
+ m_CurrentRayPositionInMM[0] = RayPosn[0];
+ m_CurrentRayPositionInMM[1] = RayPosn[1];
+ m_CurrentRayPositionInMM[2] = RayPosn[2];
+
+ m_RayDirectionInMM[0] = RayDirn[0];
+ m_RayDirectionInMM[1] = RayDirn[1];
+ m_RayDirectionInMM[2] = RayDirn[2];
+
+ // Compute the ray path for this coordinate in mm
+
+ m_ValidRay = this->CalcRayIntercepts();
+
+ if (! m_ValidRay)
+ {
+ Reset();
+ return false;
+ }
+
+ // Convert the start and end coordinates of the ray to voxels
+
+ this->EndPointsInVoxels();
+
+ /* Calculate the ray direction vector in voxels and hence the voxel
+ increment required to traverse the ray, and the number of
+ interpolation points on the ray.
+
+ This routine also shifts the coordinate frame by half a voxel for
+ two of the directional components (i.e. those lying within the
+ planes of voxels being traversed). */
+
+ this->CalcDirnVector();
+
+
+ /* Reduce the length of the ray until both start and end
+ coordinates lie inside the volume. */
+
+ m_ValidRay = this->AdjustRayLength();
+
+ // Reset the iterator to the start of the ray.
+
+ Reset();
+
+ return m_ValidRay;
+ }
+
+
+ /* -----------------------------------------------------------------------
+ EndPointsInVoxels() - Convert the endpoints to voxels
+ ----------------------------------------------------------------------- */
+
+ template<class TInputImage, class TCoordRep>
+ void
+ RayCastHelper<TInputImage, TCoordRep>
+ ::EndPointsInVoxels(void)
+ {
+ m_RayVoxelStartPosition[0] = m_RayStartCoordInMM[0]/m_VoxelDimensionInX;
+ m_RayVoxelStartPosition[1] = m_RayStartCoordInMM[1]/m_VoxelDimensionInY;
+ m_RayVoxelStartPosition[2] = m_RayStartCoordInMM[2]/m_VoxelDimensionInZ;
+
+ m_RayVoxelEndPosition[0] = m_RayEndCoordInMM[0]/m_VoxelDimensionInX;
+ m_RayVoxelEndPosition[1] = m_RayEndCoordInMM[1]/m_VoxelDimensionInY;
+ m_RayVoxelEndPosition[2] = m_RayEndCoordInMM[2]/m_VoxelDimensionInZ;
+
+ }
+
+
+ /* -----------------------------------------------------------------------
+ CalcDirnVector() - Calculate the incremental direction vector in voxels.
+ ----------------------------------------------------------------------- */
+
+ template<class TInputImage, class TCoordRep>
+ void
+ RayCastHelper<TInputImage, TCoordRep>
+ ::CalcDirnVector(void)
+ {
+ double xNum, yNum, zNum;
+
+ // Calculate the number of voxels in each direction
+
+ xNum = vcl_fabs(m_RayVoxelStartPosition[0] - m_RayVoxelEndPosition[0]);
+ yNum = vcl_fabs(m_RayVoxelStartPosition[1] - m_RayVoxelEndPosition[1]);
+ zNum = vcl_fabs(m_RayVoxelStartPosition[2] - m_RayVoxelEndPosition[2]);
+
+ // The direction iterated in is that with the greatest number of voxels
+ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ // Iterate in X direction
+
+ if( (xNum >= yNum) && (xNum >= zNum) )
+ {
+ if( m_RayVoxelStartPosition[0] < m_RayVoxelEndPosition[0] )
+ {
+ m_VoxelIncrement[0] = 1;
+
+ m_VoxelIncrement[1]
+ = (m_RayVoxelStartPosition[1]
+ - m_RayVoxelEndPosition[1])/(m_RayVoxelStartPosition[0]
+ - m_RayVoxelEndPosition[0]);
+
+ m_VoxelIncrement[2]
+ = (m_RayVoxelStartPosition[2]
+ - m_RayVoxelEndPosition[2])/(m_RayVoxelStartPosition[0]
+ - m_RayVoxelEndPosition[0]);
+ }
+ else
+ {
+ m_VoxelIncrement[0] = -1;
+
+ m_VoxelIncrement[1]
+ = -(m_RayVoxelStartPosition[1]
+ - m_RayVoxelEndPosition[1])/(m_RayVoxelStartPosition[0]
+ - m_RayVoxelEndPosition[0]);
+
+ m_VoxelIncrement[2]
+ = -(m_RayVoxelStartPosition[2]
+ - m_RayVoxelEndPosition[2])/(m_RayVoxelStartPosition[0]
+ - m_RayVoxelEndPosition[0]);
+ }
+
+ // This section is to alter the start position in order to
+ // place the center of the voxels in there correct positions,
+ // rather than placing them at the corner of voxels which is
+ // what happens if this is not carried out. The reason why
+ // x has no -0.5 is because this is the direction we are going
+ // to iterate in and therefore we wish to go from center to
+ // center rather than finding the surrounding voxels.
+
+ m_RayVoxelStartPosition[1] += ( (int)m_RayVoxelStartPosition[0]
+ - m_RayVoxelStartPosition[0])*m_VoxelIncrement[1]*m_VoxelIncrement[0]
+ + 0.5*m_VoxelIncrement[1] - 0.5;
+
+ m_RayVoxelStartPosition[2] += ( (int)m_RayVoxelStartPosition[0]
+ - m_RayVoxelStartPosition[0])*m_VoxelIncrement[2]*m_VoxelIncrement[0]
+ + 0.5*m_VoxelIncrement[2] - 0.5;
+
+ m_RayVoxelStartPosition[0] = (int)m_RayVoxelStartPosition[0] + 0.5*m_VoxelIncrement[0];
+
+ m_TotalRayVoxelPlanes = (int)xNum;
+
+ m_TraversalDirection = TRANSVERSE_IN_X;
+ }
+
+ // Iterate in Y direction
+
+ else if( (yNum >= xNum) && (yNum >= zNum) )
+ {
+
+ if( m_RayVoxelStartPosition[1] < m_RayVoxelEndPosition[1] )
+ {
+ m_VoxelIncrement[1] = 1;
+
+ m_VoxelIncrement[0]
+ = (m_RayVoxelStartPosition[0]
+ - m_RayVoxelEndPosition[0])/(m_RayVoxelStartPosition[1]
+ - m_RayVoxelEndPosition[1]);
+
+ m_VoxelIncrement[2]
+ = (m_RayVoxelStartPosition[2]
+ - m_RayVoxelEndPosition[2])/(m_RayVoxelStartPosition[1]
+ - m_RayVoxelEndPosition[1]);
+ }
+ else
+ {
+ m_VoxelIncrement[1] = -1;
+
+ m_VoxelIncrement[0]
+ = -(m_RayVoxelStartPosition[0]
+ - m_RayVoxelEndPosition[0])/(m_RayVoxelStartPosition[1]
+ - m_RayVoxelEndPosition[1]);
+
+ m_VoxelIncrement[2]
+ = -(m_RayVoxelStartPosition[2]
+ - m_RayVoxelEndPosition[2])/(m_RayVoxelStartPosition[1]
+ - m_RayVoxelEndPosition[1]);
+ }
+
+
+ m_RayVoxelStartPosition[0] += ( (int)m_RayVoxelStartPosition[1]
+ - m_RayVoxelStartPosition[1])*m_VoxelIncrement[0]*m_VoxelIncrement[1]
+ + 0.5*m_VoxelIncrement[0] - 0.5;
+
+ m_RayVoxelStartPosition[2] += ( (int)m_RayVoxelStartPosition[1]
+ - m_RayVoxelStartPosition[1])*m_VoxelIncrement[2]*m_VoxelIncrement[1]
+ + 0.5*m_VoxelIncrement[2] - 0.5;
+
+ m_RayVoxelStartPosition[1] = (int)m_RayVoxelStartPosition[1] + 0.5*m_VoxelIncrement[1];
+
+ m_TotalRayVoxelPlanes = (int)yNum;
+
+ m_TraversalDirection = TRANSVERSE_IN_Y;
+ }
+
+ // Iterate in Z direction
+
+ else
+ {
+
+ if( m_RayVoxelStartPosition[2] < m_RayVoxelEndPosition[2] )
+ {
+ m_VoxelIncrement[2] = 1;
+
+ m_VoxelIncrement[0]
+ = (m_RayVoxelStartPosition[0]
+ - m_RayVoxelEndPosition[0])/(m_RayVoxelStartPosition[2]
+ - m_RayVoxelEndPosition[2]);
+
+ m_VoxelIncrement[1]
+ = (m_RayVoxelStartPosition[1]
+ - m_RayVoxelEndPosition[1])/(m_RayVoxelStartPosition[2]
+ - m_RayVoxelEndPosition[2]);
+ }
+ else
+ {
+ m_VoxelIncrement[2] = -1;
+
+ m_VoxelIncrement[0]
+ = -(m_RayVoxelStartPosition[0]
+ - m_RayVoxelEndPosition[0])/(m_RayVoxelStartPosition[2]
+ - m_RayVoxelEndPosition[2]);
+
+ m_VoxelIncrement[1]
+ = -(m_RayVoxelStartPosition[1]
+ - m_RayVoxelEndPosition[1])/(m_RayVoxelStartPosition[2]
+ - m_RayVoxelEndPosition[2]);
+ }
+
+ m_RayVoxelStartPosition[0] += ( (int)m_RayVoxelStartPosition[2]
+ - m_RayVoxelStartPosition[2])*m_VoxelIncrement[0]*m_VoxelIncrement[2]
+ + 0.5*m_VoxelIncrement[0] - 0.5;
+
+ m_RayVoxelStartPosition[1] += ( (int)m_RayVoxelStartPosition[2]
+ - m_RayVoxelStartPosition[2])*m_VoxelIncrement[1]*m_VoxelIncrement[2]
+ + 0.5*m_VoxelIncrement[1] - 0.5;
+
+ m_RayVoxelStartPosition[2] = (int)m_RayVoxelStartPosition[2] + 0.5*m_VoxelIncrement[2];
+
+ m_TotalRayVoxelPlanes = (int)zNum;
+
+ m_TraversalDirection = TRANSVERSE_IN_Z;
+ }
+ }
+
+
+ /* -----------------------------------------------------------------------
+ AdjustRayLength() - Ensure that the ray lies within the volume
+ ----------------------------------------------------------------------- */
+
+ template<class TInputImage, class TCoordRep>
+ bool
+ RayCastHelper<TInputImage, TCoordRep>
+ ::AdjustRayLength(void)
+ {
+ bool startOK, endOK;
+
+ int Istart[3];
+ int Idirn[3];
+
+ if (m_TraversalDirection == TRANSVERSE_IN_X)
+ {
+ Idirn[0] = 0;
+ Idirn[1] = 1;
+ Idirn[2] = 1;
+ }
+ else if (m_TraversalDirection == TRANSVERSE_IN_Y)
+ {
+ Idirn[0] = 1;
+ Idirn[1] = 0;
+ Idirn[2] = 1;
+ }
+ else if (m_TraversalDirection == TRANSVERSE_IN_Z)
+ {
+ Idirn[0] = 1;
+ Idirn[1] = 1;
+ Idirn[2] = 0;
+ }
+ else
+ {
+ itk::ExceptionObject err(__FILE__, __LINE__);
+ err.SetLocation( ITK_LOCATION );
+ err.SetDescription( "The ray traversal direction is unset "
+ "- AdjustRayLength().");
+ throw err;
+ return false;
+ }
+
+
+ do
+ {
+
+ startOK = false;
+ endOK = false;
+
+ Istart[0] = (int) vcl_floor(m_RayVoxelStartPosition[0]);
+ Istart[1] = (int) vcl_floor(m_RayVoxelStartPosition[1]);
+ Istart[2] = (int) vcl_floor(m_RayVoxelStartPosition[2]);
+
+ if( (Istart[0] >= 0) && (Istart[0] + Idirn[0] < m_NumberOfVoxelsInX) &&
+ (Istart[1] >= 0) && (Istart[1] + Idirn[1] < m_NumberOfVoxelsInY) &&
+ (Istart[2] >= 0) && (Istart[2] + Idirn[2] < m_NumberOfVoxelsInZ) )
+ {
+
+ startOK = true;
+ }
+ else
+ {
+ m_RayVoxelStartPosition[0] += m_VoxelIncrement[0];
+ m_RayVoxelStartPosition[1] += m_VoxelIncrement[1];
+ m_RayVoxelStartPosition[2] += m_VoxelIncrement[2];
+
+ m_TotalRayVoxelPlanes--;
+ }
+
+ Istart[0] = (int) vcl_floor(m_RayVoxelStartPosition[0]
+ + m_TotalRayVoxelPlanes*m_VoxelIncrement[0]);
+
+ Istart[1] = (int) vcl_floor(m_RayVoxelStartPosition[1]
+ + m_TotalRayVoxelPlanes*m_VoxelIncrement[1]);
+
+ Istart[2] = (int) vcl_floor(m_RayVoxelStartPosition[2]
+ + m_TotalRayVoxelPlanes*m_VoxelIncrement[2]);
+
+ if( (Istart[0] >= 0) && (Istart[0] + Idirn[0] < m_NumberOfVoxelsInX) &&
+ (Istart[1] >= 0) && (Istart[1] + Idirn[1] < m_NumberOfVoxelsInY) &&
+ (Istart[2] >= 0) && (Istart[2] + Idirn[2] < m_NumberOfVoxelsInZ) )
+ {
+
+ endOK = true;
+ }
+ else
+ {
+ m_TotalRayVoxelPlanes--;
+ }
+
+ } while ( (! (startOK && endOK)) && (m_TotalRayVoxelPlanes > 1) );
+
+
+ return (startOK && endOK);
+ }
+
+
+ /* -----------------------------------------------------------------------
+ Reset() - Reset the iterator to the start of the ray.
+ ----------------------------------------------------------------------- */
+
+ template<class TInputImage, class TCoordRep>
+ void
+ RayCastHelper<TInputImage, TCoordRep>
+ ::Reset(void)
+ {
+ int i;
+
+ m_NumVoxelPlanesTraversed = -1;
+
+ // If this is a valid ray...
+
+ if (m_ValidRay)
+ {
+ for (i=0; i<3; i++)
+ {
+ m_Position3Dvox[i] = m_RayVoxelStartPosition[i];
+ }
+ this->InitialiseVoxelPointers();
+ }
+
+ // otherwise set parameters to zero
+
+ else
+ {
+ for (i=0; i<3; i++)
+ {
+ m_RayVoxelStartPosition[i] = 0.;
+ }
+ for (i=0; i<3; i++)
+ {
+ m_RayVoxelEndPosition[i] = 0.;
+ }
+ for (i=0; i<3; i++)
+ {
+ m_VoxelIncrement[i] = 0.;
+ }
+ m_TraversalDirection = UNDEFINED_DIRECTION;
+
+ m_TotalRayVoxelPlanes = 0;
+
+ for (i=0; i<4; i++)
+ {
+ m_RayIntersectionVoxels[i] = 0;
+ }
+ for (i=0; i<3; i++)
+ {
+ m_RayIntersectionVoxelIndex[i] = 0;
+ }
+ }
+ }
+
+
+ /* -----------------------------------------------------------------------
+ InitialiseVoxelPointers() - Obtain pointers to the first four voxels
+ ----------------------------------------------------------------------- */
+
+ template<class TInputImage, class TCoordRep>
+ void
+ RayCastHelper<TInputImage, TCoordRep>
+ ::InitialiseVoxelPointers(void)
+ {
+
+ //JV don't do anything if deformable
+ if(!m_TransformIsDeformable)
+ {
+ IndexType index;
+
+ int Ix, Iy, Iz;
+
+ Ix = (int)(m_RayVoxelStartPosition[0]);
+ Iy = (int)(m_RayVoxelStartPosition[1]);
+ Iz = (int)(m_RayVoxelStartPosition[2]);
+
+ m_RayIntersectionVoxelIndex[0] = Ix;
+ m_RayIntersectionVoxelIndex[1] = Iy;
+ m_RayIntersectionVoxelIndex[2] = Iz;
+
+ switch( m_TraversalDirection )
+ {
+ case TRANSVERSE_IN_X:
+ {
+
+ if( (Ix >= 0) && (Ix < m_NumberOfVoxelsInX) &&
+ (Iy >= 0) && (Iy + 1 < m_NumberOfVoxelsInY) &&
+ (Iz >= 0) && (Iz + 1 < m_NumberOfVoxelsInZ))
+ {
+ index[0]=Ix; index[1]=Iy; index[2]=Iz;
+ m_RayIntersectionVoxels[0]
+ = this->m_Image->GetBufferPointer() + this->m_Image->ComputeOffset(index);
+
+ index[0]=Ix; index[1]=Iy+1; index[2]=Iz;
+ m_RayIntersectionVoxels[1]
+ = ( this->m_Image->GetBufferPointer() + this->m_Image->ComputeOffset(index) );
+
+ index[0]=Ix; index[1]=Iy; index[2]=Iz+1;
+ m_RayIntersectionVoxels[2]
+ = ( this->m_Image->GetBufferPointer() + this->m_Image->ComputeOffset(index) );
+
+ index[0]=Ix; index[1]=Iy+1; index[2]=Iz+1;
+ m_RayIntersectionVoxels[3]
+ = ( this->m_Image->GetBufferPointer() + this->m_Image->ComputeOffset(index) );
+ }
+ else
+ {
+ m_RayIntersectionVoxels[0] =
+ m_RayIntersectionVoxels[1] =
+ m_RayIntersectionVoxels[2] =
+ m_RayIntersectionVoxels[3] = NULL;
+ }
+ break;
+ }
+
+ case TRANSVERSE_IN_Y:
+ {
+
+ if( (Ix >= 0) && (Ix + 1 < m_NumberOfVoxelsInX) &&
+ (Iy >= 0) && (Iy < m_NumberOfVoxelsInY) &&
+ (Iz >= 0) && (Iz + 1 < m_NumberOfVoxelsInZ))
+ {
+
+ index[0]=Ix; index[1]=Iy; index[2]=Iz;
+ m_RayIntersectionVoxels[0] = ( this->m_Image->GetBufferPointer()
+ + this->m_Image->ComputeOffset(index) );
+
+ index[0]=Ix+1; index[1]=Iy; index[2]=Iz;
+ m_RayIntersectionVoxels[1] = ( this->m_Image->GetBufferPointer()
+ + this->m_Image->ComputeOffset(index) );
+
+ index[0]=Ix; index[1]=Iy; index[2]=Iz+1;
+ m_RayIntersectionVoxels[2] = ( this->m_Image->GetBufferPointer()
+ + this->m_Image->ComputeOffset(index) );
+
+ index[0]=Ix+1; index[1]=Iy; index[2]=Iz+1;
+ m_RayIntersectionVoxels[3] = ( this->m_Image->GetBufferPointer()
+ + this->m_Image->ComputeOffset(index) );
+ }
+ else
+ {
+ m_RayIntersectionVoxels[0]
+ = m_RayIntersectionVoxels[1]
+ = m_RayIntersectionVoxels[2]
+ = m_RayIntersectionVoxels[3] = NULL;
+ }
+ break;
+ }
+
+ case TRANSVERSE_IN_Z:
+ {
+
+ if( (Ix >= 0) && (Ix + 1 < m_NumberOfVoxelsInX) &&
+ (Iy >= 0) && (Iy + 1 < m_NumberOfVoxelsInY) &&
+ (Iz >= 0) && (Iz < m_NumberOfVoxelsInZ))
+ {
+
+ index[0]=Ix; index[1]=Iy; index[2]=Iz;
+ m_RayIntersectionVoxels[0] = ( this->m_Image->GetBufferPointer()
+ + this->m_Image->ComputeOffset(index) );
+
+ index[0]=Ix+1; index[1]=Iy; index[2]=Iz;
+ m_RayIntersectionVoxels[1] = ( this->m_Image->GetBufferPointer()
+ + this->m_Image->ComputeOffset(index) );
+
+ index[0]=Ix; index[1]=Iy+1; index[2]=Iz;
+ m_RayIntersectionVoxels[2] = ( this->m_Image->GetBufferPointer()
+ + this->m_Image->ComputeOffset(index) );
+
+ index[0]=Ix+1; index[1]=Iy+1; index[2]=Iz;
+ m_RayIntersectionVoxels[3] = ( this->m_Image->GetBufferPointer()
+ + this->m_Image->ComputeOffset(index) );
+
+ }
+ else
+ {
+ m_RayIntersectionVoxels[0]
+ = m_RayIntersectionVoxels[1]
+ = m_RayIntersectionVoxels[2]
+ = m_RayIntersectionVoxels[3] = NULL;
+ }
+ break;
+ }
+
+ default:
+ {
+ itk::ExceptionObject err(__FILE__, __LINE__);
+ err.SetLocation( ITK_LOCATION );
+ err.SetDescription( "The ray traversal direction is unset "
+ "- InitialiseVoxelPointers().");
+ throw err;
+ return;
+ }
+ }
+
+ }//JV end if deformable
+ }
+
+ /* -----------------------------------------------------------------------
+ IncrementVoxelPointers() - Increment the voxel pointers
+ ----------------------------------------------------------------------- */
+
+ template<class TInputImage, class TCoordRep>
+ void
+ RayCastHelper<TInputImage, TCoordRep>
+ ::IncrementVoxelPointers(void)
+ {
+
+
+ double xBefore = m_Position3Dvox[0];
+ double yBefore = m_Position3Dvox[1];
+ double zBefore = m_Position3Dvox[2];
+
+ m_Position3Dvox[0] += m_VoxelIncrement[0];
+ m_Position3Dvox[1] += m_VoxelIncrement[1];
+ m_Position3Dvox[2] += m_VoxelIncrement[2];
+
+
+ //JV don't do anything to pointers if deformable
+ if(!m_TransformIsDeformable)
+ {
+ int dx = ((int) m_Position3Dvox[0]) - ((int) xBefore);
+ int dy = ((int) m_Position3Dvox[1]) - ((int) yBefore);
+ int dz = ((int) m_Position3Dvox[2]) - ((int) zBefore);
+
+ m_RayIntersectionVoxelIndex[0] += dx;
+ m_RayIntersectionVoxelIndex[1] += dy;
+ m_RayIntersectionVoxelIndex[2] += dz;
+
+ int totalRayVoxelPlanes
+ = dx + dy*m_NumberOfVoxelsInX + dz*m_NumberOfVoxelsInX*m_NumberOfVoxelsInY;
+
+ m_RayIntersectionVoxels[0] += totalRayVoxelPlanes;
+ m_RayIntersectionVoxels[1] += totalRayVoxelPlanes;
+ m_RayIntersectionVoxels[2] += totalRayVoxelPlanes;
+ m_RayIntersectionVoxels[3] += totalRayVoxelPlanes;
+ }//JV end if deformable
+ }
+
+
+ /* -----------------------------------------------------------------------
+ GetCurrentIntensity() - Get the intensity of the current ray point.
+ ----------------------------------------------------------------------- */
+
+ template<class TInputImage, class TCoordRep>
+ double
+ RayCastHelper<TInputImage, TCoordRep>
+ ::GetCurrentIntensity(void) const
+ {
+
+ //DD("In get current intensity");
+ //JV fetch the interpolated value by applying the deformable transform
+ if(m_TransformIsDeformable)
+ {
+ //3DPositionVox is in voxels AND shifted half a voxel in plane
+ typename InputImageType::PointType inputPoint;
+ // switch( m_TraversalDirection )
+ // {
+ // case TRANSVERSE_IN_X:
+ // {
+ // double x = (int)m_Position3Dvox[0] - 0.5*m_VoxelIncrement[0];
+ // inputPoint[0]=x*m_VoxelDimensionInX;
+
+ // inputPoint[1] -= ( (int(x)-x)*m_VoxelIncrement[1]*m_VoxelIncrement[0]
+ // + 0.5*m_VoxelIncrement[1] - 0.5)*m_VoxelDimensionInY;
+
+ // inputPoint[2] -= ( (int(x)-x)*m_VoxelIncrement[2]*m_VoxelIncrement[0]
+ // + 0.5*m_VoxelIncrement[2] - 0.5)*m_VoxelDimensionInZ;
+
+ // // inputPoint[0]=m_Position3Dvox[0]*m_VoxelDimensionInX;
+ // // inputPoint[1]=(m_Position3Dvox[1]+0.5)*m_VoxelDimensionInY;
+ // // inputPoint[2]=(m_Position3Dvox[2]+0.5)*m_VoxelDimensionInZ;
+ // // DD("X");
+ // break;
+ // }
+ // case TRANSVERSE_IN_Y:
+ // {
+ // double y = (int)m_Position3Dvox[1] - 0.5*m_VoxelIncrement[1];
+ // double y=m_Position3Dvox[1];
+ // inputPoint[1]=y*m_VoxelDimensionInY;
+
+ // inputPoint[0] = (m_Position3Dvox[0]- ((int)y-y)*m_VoxelIncrement[0]*m_VoxelIncrement[1]
+ // + 0.5*m_VoxelIncrement[0] - 0.5) * m_VoxelDimensionInX;
+
+ // inputPoint[2] = (m_Position3Dvox[2]- ((int)y-y)*m_VoxelIncrement[2]*m_VoxelIncrement[1]
+ // + 0.5*m_VoxelIncrement[2] - 0.5) * m_VoxelDimensionInZ;
+
+ // // inputPoint[0]=(m_Position3Dvox[0]+0)*m_VoxelDimensionInX;
+ // // inputPoint[1]=m_Position3Dvox[1]*m_VoxelDimensionInY;
+ // // inputPoint[2]=(m_Position3Dvox[2]+0.5)*m_VoxelDimensionInZ;
+
+ // break;
+ // }
+ // case TRANSVERSE_IN_Z:
+ // {
+ // double z = (int)m_Position3Dvox[2] - 0.5*m_VoxelIncrement[2];
+ // inputPoint[2]=z*m_VoxelDimensionInZ;
+
+ // inputPoint[0] += -( z*m_VoxelIncrement[1]*m_VoxelIncrement[0]
+ // - 0.5*m_VoxelIncrement[2] + 0.5)*m_VoxelDimensionInZ;
+
+ // inputPoint[1] += -( z*m_VoxelIncrement[1]*m_VoxelIncrement[0]
+ // - 0.5*m_VoxelIncrement[2] + 0.5)*m_VoxelDimensionInZ;
+
+ // // inputPoint[0]=(m_Position3Dvox[0]+0.5)*m_VoxelDimensionInX;
+ // // inputPoint[1]=(m_Position3Dvox[1]+0.5)*m_VoxelDimensionInY;
+ // // inputPoint[2]=m_Position3Dvox[2]*m_VoxelDimensionInZ;
+ // // DD("Z");
+ // break;
+ // }
+
+ // default:
+ // {
+ // itk::ExceptionObject err(__FILE__, __LINE__);
+ // err.SetLocation( ITK_LOCATION );
+ // err.SetDescription( "The ray traversal direction is unset "
+ // "- GetCurrentIntensity().");
+ // throw err;
+ // return 0;
+ // }
+ // }
+
+
+ //JV there seems to remain an small offset
+ inputPoint[0]=(m_Position3Dvox[0])*m_VoxelDimensionInX;
+ inputPoint[1]=(m_Position3Dvox[1])*m_VoxelDimensionInY;
+ inputPoint[2]=m_Position3Dvox[2]*m_VoxelDimensionInZ;
+ //JV work around, call Deformably transform point (no bulk)
+ typedef clitk::BSplineDeformableTransform<double,3,3> DeformableTransformType;
+ DeformableTransformType* bsplineTransform=dynamic_cast<DeformableTransformType*>(m_Transform);
+ typename DeformableTransformType::OutputPointType transformedPoint=bsplineTransform->DeformablyTransformPoint(inputPoint);
+
+ //check wether inside
+ ContinuousIndexType contIndex;
+ if (m_Image->TransformPhysicalPointToContinuousIndex(transformedPoint, contIndex))
+ //interpolate this position in the input image
+ return this->m_DeformableTransformInterpolator->EvaluateAtContinuousIndex(contIndex);
+ else return 0;//m_EdgePaddingValue;
+
+ }//JV end if deformable
+
+ else
+ {
+ double a, b, c, d;
+ double y, z;
+
+ if (! m_ValidRay)
+ {
+ return 0;
+ }
+ a = (double) (*m_RayIntersectionVoxels[0]);
+ b = (double) (*m_RayIntersectionVoxels[1] - a);
+ c = (double) (*m_RayIntersectionVoxels[2] - a);
+ d = (double) (*m_RayIntersectionVoxels[3] - a - b - c);
+
+ switch( m_TraversalDirection )
+ {
+ case TRANSVERSE_IN_X:
+ {
+ y = m_Position3Dvox[1] - vcl_floor(m_Position3Dvox[1]);
+ z = m_Position3Dvox[2] - vcl_floor(m_Position3Dvox[2]);
+ break;
+ }
+ case TRANSVERSE_IN_Y:
+ {
+ y = m_Position3Dvox[0] - vcl_floor(m_Position3Dvox[0]);
+ z = m_Position3Dvox[2] - vcl_floor(m_Position3Dvox[2]);
+ break;
+ }
+ case TRANSVERSE_IN_Z:
+ {
+ y = m_Position3Dvox[0] - vcl_floor(m_Position3Dvox[0]);
+ z = m_Position3Dvox[1] - vcl_floor(m_Position3Dvox[1]);
+ break;
+ }
+ default:
+ {
+ itk::ExceptionObject err(__FILE__, __LINE__);
+ err.SetLocation( ITK_LOCATION );
+ err.SetDescription( "The ray traversal direction is unset "
+ "- GetCurrentIntensity().");
+ throw err;
+ return 0;
+ }
+ }
+
+ return a + b*y + c*z + d*y*z;
+ }
+ }
+
+ /* -----------------------------------------------------------------------
+ IncrementIntensities() - Increment the intensities of the current ray point
+ ----------------------------------------------------------------------- */
+
+ template<class TInputImage, class TCoordRep>
+ void
+ RayCastHelper<TInputImage, TCoordRep>
+ ::IncrementIntensities(double increment)
+ {
+ short inc = (short) vcl_floor(increment + 0.5);
+
+ if (! m_ValidRay)
+ {
+ return;
+ }
+ *m_RayIntersectionVoxels[0] += inc;
+ *m_RayIntersectionVoxels[1] += inc;
+ *m_RayIntersectionVoxels[2] += inc;
+ *m_RayIntersectionVoxels[3] += inc;
+
+ return;
+ }
+
+
+ /* -----------------------------------------------------------------------
+ IntegrateAboveThreshold() - Integrate intensities above a threshold.
+ ----------------------------------------------------------------------- */
+
+ template<class TInputImage, class TCoordRep>
+ bool
+ RayCastHelper<TInputImage, TCoordRep>
+ ::IntegrateAboveThreshold(double &integral, double threshold)
+ {
+ double intensity;
+ // double posn3D_x, posn3D_y, posn3D_z;
+
+ integral = 0.;
+
+ // Check if this is a valid ray
+
+ if (! m_ValidRay)
+ {
+ return false;
+ }
+ /* Step along the ray as quickly as possible
+ integrating the interpolated intensities. */
+
+ for (m_NumVoxelPlanesTraversed=0;
+ m_NumVoxelPlanesTraversed<m_TotalRayVoxelPlanes;
+ m_NumVoxelPlanesTraversed++)
+ {
+ intensity = this->GetCurrentIntensity();
+
+ if (intensity > threshold)
+ {
+ integral += intensity - threshold;
+ }
+ this->IncrementVoxelPointers();
+ }
+
+ /* The ray passes through the volume one plane of voxels at a time,
+ however, if its moving diagonally the ray points will be further
+ apart so account for this by scaling by the distance moved. */
+
+ integral *= this->GetRayPointSpacing();
+
+ return true;
+ }
+
+ /* -----------------------------------------------------------------------
+ ZeroState() - Set the default (zero) state of the object
+ ----------------------------------------------------------------------- */
+
+ template<class TInputImage, class TCoordRep>
+ void
+ RayCastHelper<TInputImage, TCoordRep>
+ ::ZeroState()
+ {
+ int i;
+
+ m_ValidRay = false;
+
+ m_NumberOfVoxelsInX = 0;
+ m_NumberOfVoxelsInY = 0;
+ m_NumberOfVoxelsInZ = 0;
+
+ m_VoxelDimensionInX = 0;
+ m_VoxelDimensionInY = 0;
+ m_VoxelDimensionInZ = 0;
+
+ for (i=0; i<3; i++)
+ {
+ m_CurrentRayPositionInMM[i] = 0.;
+ }
+ for (i=0; i<3; i++)
+ {
+ m_RayDirectionInMM[i] = 0.;
+ }
+ for (i=0; i<3; i++)
+ {
+ m_RayVoxelStartPosition[i] = 0.;
+ }
+ for (i=0; i<3; i++)
+ {
+ m_RayVoxelEndPosition[i] = 0.;
+ }
+ for (i=0; i<3; i++)
+ {
+ m_VoxelIncrement[i] = 0.;
+ }
+ m_TraversalDirection = UNDEFINED_DIRECTION;
+
+ m_TotalRayVoxelPlanes = 0;
+ m_NumVoxelPlanesTraversed = -1;
+
+ for (i=0; i<4; i++)
+ {
+ m_RayIntersectionVoxels[i] = 0;
+ }
+ for (i=0; i<3; i++)
+ {
+ m_RayIntersectionVoxelIndex[i] = 0;
+ }
+ }
+}; // end of anonymous namespace
+
+
+namespace clitk
+{
+
+ /**************************************************************************
+ *
+ *
+ * Rest of this code is the actual RayCastInterpolateImageFunctionWithOrigin
+ * class
+ *
+ *
+ **************************************************************************/
+
+ /* -----------------------------------------------------------------------
+ Constructor
+ ----------------------------------------------------------------------- */
+
+ template<class TInputImage, class TCoordRep>
+ RayCastInterpolateImageFunctionWithOrigin< TInputImage, TCoordRep >
+ ::RayCastInterpolateImageFunctionWithOrigin()
+ {
+ m_Threshold = 0.;
+
+ m_FocalPoint[0] = 0.;
+ m_FocalPoint[1] = 0.;
+ m_FocalPoint[2] = 0.;
+
+ //JV
+ m_TransformIsDeformable=false;
+ }
+
+
+ /* -----------------------------------------------------------------------
+ PrintSelf
+ ----------------------------------------------------------------------- */
+
+ template<class TInputImage, class TCoordRep>
+ void
+ RayCastInterpolateImageFunctionWithOrigin< TInputImage, TCoordRep >
+ ::PrintSelf(std::ostream& os, itk::Indent indent) const
+ {
+ this->Superclass::PrintSelf(os,indent);
+
+ os << indent << "Threshold: " << m_Threshold << std::endl;
+ os << indent << "FocalPoint: " << m_FocalPoint << std::endl;
+ os << indent << "Transform: " << m_Transform.GetPointer() << std::endl;
+ os << indent << "Interpolator: " << m_Interpolator.GetPointer() << std::endl;
+
+ }
+
+ /* -----------------------------------------------------------------------
+ Evaluate at image index position
+ ----------------------------------------------------------------------- */
+
+ template<class TInputImage, class TCoordRep>
+ typename RayCastInterpolateImageFunctionWithOrigin< TInputImage, TCoordRep >
+ ::OutputType
+ RayCastInterpolateImageFunctionWithOrigin< TInputImage, TCoordRep >
+ ::Evaluate( const PointType& point ) const
+ {
+ double integral = 0;
+
+ OutputPointType transformedFocalPoint
+ = m_Transform->TransformPoint( m_FocalPoint );
+
+ DirectionType direction = transformedFocalPoint - point;
+
+ RayCastHelper<TInputImage, TCoordRep> ray;
+
+ //JV
+ ray.SetTransformIsDeformable(m_TransformIsDeformable);
+ if (m_TransformIsDeformable)
+ {
+ ray.SetTransform(m_Transform);
+ ray.SetDeformableTransformInterpolator(m_DeformableTransformInterpolator);
+ }
+ //JV
+
+ ray.SetImage( this->m_Image );
+ ray.ZeroState();
+
+ ray.Initialise();
+ // (Aviv) Added support for images with non-zero origin
+ // ray.SetRay(point, direction);
+ ray.SetRay(point - this->m_Image->GetOrigin().GetVectorFromOrigin(), direction);
+ ray.IntegrateAboveThreshold(integral, m_Threshold);
+
+ return ( static_cast<OutputType>( integral ));
+ }
+
+ template<class TInputImage, class TCoordRep>
+ typename RayCastInterpolateImageFunctionWithOrigin< TInputImage, TCoordRep >
+ ::OutputType
+ RayCastInterpolateImageFunctionWithOrigin< TInputImage, TCoordRep >
+ ::EvaluateAtContinuousIndex( const ContinuousIndexType& index ) const
+ {
+ OutputPointType point;
+ this->m_Image->TransformContinuousIndexToPhysicalPoint(index, point);
+
+ return this->Evaluate( point );
+ }
+
+} // namespace clitk
+
+
+#endif
TARGET_LINK_LIBRARIES(clitkImageInfo clitkCommon ITKIO)
WRAP_GGO(clitkImageConvert_GGO_C clitkImageConvert.ggo)
-ADD_EXECUTABLE(clitkImageConvert clitkImageConvert.cxx ${clitkImageConvert_GGO_C})
-TARGET_LINK_LIBRARIES(clitkImageConvert clitkCommon ITKIO clitkFilters)
+ADD_EXECUTABLE(clitkImageConvert clitkImageConvert.cxx clitkImageConvertGenericFilter.cxx ${clitkImageConvert_GGO_C})
+TARGET_LINK_LIBRARIES(clitkImageConvert clitkCommon ITKIO)
# WRAP_GGO(clitkImageResample_GGO_C clitkImageResample.ggo)
# ADD_EXECUTABLE(clitkImageResample clitkImageResample.cxx ${clitkImageResample_GGO_C})
-# TARGET_LINK_LIBRARIES(clitkImageResample clitkCommon ITKIO clitkFilters)
+# TARGET_LINK_LIBRARIES(clitkImageResample clitkCommon ITKIO )
-WRAP_GGO(clitkVFResample_GGO_C clitkVFResample.ggo)
-ADD_EXECUTABLE(clitkVFResample clitkVFResample.cxx ${clitkImageResample_GGO_C})
-TARGET_LINK_LIBRARIES(clitkVFResample clitkCommon ITKIO clitkFilters)
+WRAP_GGO(clitkVFResample_GGO_C clitkImageResample.ggo)
+ADD_EXECUTABLE(clitkVFResample clitkVFResample.cxx clitkVFResampleGenericFilter.cxx ${clitkVFResample_GGO_C})
+TARGET_LINK_LIBRARIES(clitkVFResample clitkCommon ITKIO)
WRAP_GGO(clitkImageCreate_GGO_C clitkImageCreate.ggo)
ADD_EXECUTABLE(clitkImageCreate clitkImageCreate.cxx ${clitkImageCreate_GGO_C})
-TARGET_LINK_LIBRARIES(clitkImageCreate clitkCommon ITKStatistics ITKIO)
-
-WRAP_GGO(clitkImageFillRegion_GGO_C clitkImageFillRegion.ggo)
-ADD_EXECUTABLE(clitkImageFillRegion clitkImageFillRegion.cxx ${clitkImageFillRegion_GGO_C})
-TARGET_LINK_LIBRARIES(clitkImageFillRegion clitkCommon ITKIO ITKStatistics clitkFilters)
+TARGET_LINK_LIBRARIES(clitkImageCreate clitkCommon ITKIO)
WRAP_GGO(clitkZeroVF_GGO_C clitkZeroVF.ggo)
ADD_EXECUTABLE(clitkZeroVF clitkZeroVF.cxx ${clitkZeroVF_GGO_C} clitkZeroVFGenericFilter.cxx)
-TARGET_LINK_LIBRARIES(clitkZeroVF clitkCommon ITKStatistics ITKIO)
+TARGET_LINK_LIBRARIES(clitkZeroVF clitkCommon ITKIO)
WRAP_GGO(clitkImageExtractLine_GGO_C clitkImageExtractLine.ggo)
ADD_EXECUTABLE(clitkImageExtractLine clitkImageExtractLine.cxx ${clitkImageExtractLine_GGO_C})
-TARGET_LINK_LIBRARIES(clitkImageExtractLine clitkCommon ITKStatistics ITKIO)
+TARGET_LINK_LIBRARIES(clitkImageExtractLine clitkCommon ITKIO)
WRAP_GGO(clitkSplitImage_GGO_C clitkSplitImage.ggo)
-ADD_EXECUTABLE(clitkSplitImage clitkSplitImage.cxx ${clitkSplitImage_GGO_C})
-TARGET_LINK_LIBRARIES(clitkSplitImage ITKBasicFilters clitkCommon ITKIO clitkFilters)
+ADD_EXECUTABLE(clitkSplitImage clitkSplitImage.cxx clitkSplitImageGenericFilter.cxx ${clitkSplitImage_GGO_C})
+TARGET_LINK_LIBRARIES(clitkSplitImage clitkCommon ITKIO )
WRAP_GGO(clitkVFMerge_GGO_C clitkVFMerge.ggo)
ADD_EXECUTABLE(clitkVFMerge clitkVFMerge.cxx ${clitkVFMerge_GGO_C})
WRAP_GGO(clitkWriteDicomSeries_GGO_C clitkWriteDicomSeries.ggo)
ADD_EXECUTABLE(clitkWriteDicomSeries clitkWriteDicomSeries.cxx ${clitkWriteDicomSeries_GGO_C})
-TARGET_LINK_LIBRARIES(clitkWriteDicomSeries clitkCommon ITKIO clitkFilters)
+TARGET_LINK_LIBRARIES(clitkWriteDicomSeries clitkCommon ITKIO )
WRAP_GGO(clitkAverageTemporalDimension_GGO_C clitkAverageTemporalDimension.ggo)
ADD_EXECUTABLE(clitkAverageTemporalDimension clitkAverageTemporalDimension.cxx ${clitkAverageTemporalDimension_GGO_C})
-TARGET_LINK_LIBRARIES(clitkAverageTemporalDimension clitkCommon ITKIO clitkFilters)
+TARGET_LINK_LIBRARIES(clitkAverageTemporalDimension clitkCommon ITKIO )
WRAP_GGO(clitkWarpImage_GGO_C clitkWarpImage.ggo)
ADD_EXECUTABLE(clitkWarpImage clitkWarpImage.cxx ${clitkWarpImage_GGO_C} clitkWarpImageGenericFilter.cxx)
WRAP_GGO(clitkInvertVF_GGO_C clitkInvertVF.ggo)
ADD_EXECUTABLE(clitkInvertVF clitkInvertVF.cxx ${clitkInvertVF_GGO_C})
-TARGET_LINK_LIBRARIES(clitkInvertVF clitkCommon ITKIO clitkFilters)
+TARGET_LINK_LIBRARIES(clitkInvertVF clitkCommon ITKIO )
WRAP_GGO(clitkAffineTransform_GGO_C clitkAffineTransform.ggo)
ADD_EXECUTABLE(clitkAffineTransform clitkAffineTransform.cxx ${clitkAffineTransform_GGO_C})
-TARGET_LINK_LIBRARIES(clitkAffineTransform clitkCommon ITKIO clitkFilters)
+TARGET_LINK_LIBRARIES(clitkAffineTransform clitkCommon ITKIO )
WRAP_GGO(clitkSetBackground_GGO_C clitkSetBackground.ggo)
ADD_EXECUTABLE(clitkSetBackground clitkSetBackground.cxx clitkSetBackgroundGenericFilter.cxx ${clitkSetBackground_GGO_C})
TARGET_LINK_LIBRARIES(clitkSetBackground clitkCommon ITKIO)
WRAP_GGO(clitkGuerreroVentilation_GGO_C clitkGuerreroVentilation.ggo)
-ADD_EXECUTABLE(clitkGuerreroVentilation clitkGuerreroVentilation.cxx ${clitkGuerreroVentilation_GGO_C})
-TARGET_LINK_LIBRARIES(clitkGuerreroVentilation clitkCommon ITKIO ITKBasicFilters clitkFilters)
-
-ADD_EXECUTABLE(clitkImageArithm clitkImageArithm.cxx)
-TARGET_LINK_LIBRARIES(clitkImageArithm clitkCommon ITKIO ITKStatistics clitkFilters)
+ADD_EXECUTABLE(clitkGuerreroVentilation clitkGuerreroVentilation.cxx clitkGuerreroVentilationGenericFilter.cxx ${clitkGuerreroVentilation_GGO_C})
+TARGET_LINK_LIBRARIES(clitkGuerreroVentilation clitkCommon ITKIO)
-ADD_EXECUTABLE(clitkUnsharpMask clitkUnsharpMask.cxx)
-TARGET_LINK_LIBRARIES(clitkUnsharpMask clitkCommon ITKIO clitkFilters)
+WRAP_GGO(clitkImageArithm_GGO_C clitkImageArithm.ggo)
+ADD_EXECUTABLE(clitkImageArithm clitkImageArithm.cxx ${clitkImageArithm_GGO_C})
+TARGET_LINK_LIBRARIES(clitkImageArithm clitkCommon ITKIO )
-ADD_EXECUTABLE(clitkFooImage clitkFooImage.cxx)
-TARGET_LINK_LIBRARIES(clitkFooImage clitkCommon ITKIO clitkFilters)
+WRAP_GGO(clitkUnsharpMask_GGO_C clitkUnsharpMask.ggo)
+ADD_EXECUTABLE(clitkUnsharpMask clitkUnsharpMask.cxx ${clitkUnsharpMask_GGO_C})
+TARGET_LINK_LIBRARIES(clitkUnsharpMask clitkCommon ITKIO )
-ADD_EXECUTABLE(clitkBinarizeImage clitkBinarizeImage.cxx)
-TARGET_LINK_LIBRARIES(clitkBinarizeImage clitkCommon ITKIO clitkFilters)
+WRAP_GGO(clitkFooImage_GGO_C clitkFooImage.ggo)
+ADD_EXECUTABLE(clitkFooImage clitkFooImage.cxx ${clitkFooImage_GGO_C})
+TARGET_LINK_LIBRARIES(clitkFooImage clitkCommon ITKIO )
-ADD_EXECUTABLE(clitkMedianImageFilter clitkMedianImageFilter.cxx)
-TARGET_LINK_LIBRARIES(clitkMedianImageFilter clitkCommon ITKIO ITKBasicFilters clitkFilters)
+WRAP_GGO(clitkMedianImageFilter_GGO_C clitkMedianImageFilter.ggo)
+ADD_EXECUTABLE(clitkMedianImageFilter clitkMedianImageFilter.cxx ${clitkMedianImageFilter_GGO_C})
+TARGET_LINK_LIBRARIES(clitkMedianImageFilter clitkCommon ITKIO ITKBasicFilters )
WRAP_GGO(clitkResampleImage_GGO_C clitkResampleImage.ggo)
ADD_EXECUTABLE(clitkResampleImage clitkResampleImage.cxx clitkResampleImageGenericFilter.cxx ${clitkResampleImage_GGO_C})
WRAP_GGO(clitkMinMaxMask_GGO_C clitkMinMaxMask.ggo)
ADD_EXECUTABLE(clitkMinMaxMask clitkMinMaxMask.cxx ${clitkMinMaxMask_GGO_C})
-TARGET_LINK_LIBRARIES(clitkMinMaxMask clitkCommon ITKIO ITKStatistics clitkFilters)
+TARGET_LINK_LIBRARIES(clitkMinMaxMask clitkCommon ITKIO )
-ADD_EXECUTABLE(clitkAutoCrop clitkAutoCrop.cxx)
-TARGET_LINK_LIBRARIES(clitkAutoCrop clitkCommon ITKIO ITKStatistics clitkFilters)
+WRAP_GGO(clitkAutoCrop_GGO_C clitkAutoCrop.ggo)
+ADD_EXECUTABLE(clitkAutoCrop clitkAutoCrop.cxx ${clitkAutoCrop_GGO_C})
+TARGET_LINK_LIBRARIES(clitkAutoCrop clitkCommon ITKIO )
WRAP_GGO(clitkDicomRTStruct2BinaryImage_GGO_C clitkDicomRTStruct2BinaryImage.ggo)
ADD_EXECUTABLE(clitkDicomRTStruct2BinaryImage clitkDicomRT_ROI_ConvertToImageFilter.cxx clitkDicomRTStruct2BinaryImage.cxx ${clitkDicomRTStruct2BinaryImage_GGO_C})
TARGET_LINK_LIBRARIES(clitkDicomRTStruct2BinaryImage ITKCommon clitkDicomRTStruct clitkCommon ITKIO QVTK)
-ADD_EXECUTABLE(clitkImageLog clitkImageLog.cxx clitkImageLog_ggo.c)
-TARGET_LINK_LIBRARIES(clitkImageLog clitkJef ITKIO clitkCommon fftw3)
+WRAP_GGO(clitkImageLog_GGO_C clitkImageLog.ggo)
+ADD_EXECUTABLE(clitkImageLog clitkImageLog.cxx ${clitkImageLog_GGO_C})
+TARGET_LINK_LIBRARIES(clitkImageLog ITKIO clitkCommon)
-ADD_EXECUTABLE(clitkFilter clitkFilter.cxx clitkFilterGenericFilter.cxx clitkFilter_ggo.c)
+WRAP_GGO(clitkFilter_GGO_C clitkFilter.ggo)
+ADD_EXECUTABLE(clitkFilter clitkFilter.cxx clitkFilterGenericFilter.cxx ${clitkFilter_GGO_C})
TARGET_LINK_LIBRARIES(clitkFilter ITKIO clitkCommon)
-ADD_EXECUTABLE(clitkConeBeamProjectImage clitkConeBeamProjectImage.cxx clitkConeBeamProjectImageGenericFilter.cxx clitkConeBeamProjectImage_ggo.c)
-TARGET_LINK_LIBRARIES(clitkConeBeamProjectImage ITKIO clitkCommon clitkJef)
+WRAP_GGO(clitkConeBeamProjectImage_GGO_C clitkConeBeamProjectImage.ggo)
+ADD_EXECUTABLE(clitkConeBeamProjectImage clitkConeBeamProjectImage.cxx clitkConeBeamProjectImageGenericFilter.cxx ${clitkConeBeamProjectImage_GGO_C})
+TARGET_LINK_LIBRARIES(clitkConeBeamProjectImage ITKIO clitkCommon )
-ADD_EXECUTABLE(clitkComposeVF clitkComposeVFGenericFilter.cxx clitkComposeVF.cxx clitkComposeVF_ggo.c)
+WRAP_GGO(clitkComposeVF_GGO_C clitkComposeVF.ggo)
+ADD_EXECUTABLE(clitkComposeVF clitkComposeVFGenericFilter.cxx clitkComposeVF.cxx ${clitkComposeVF_GGO_C})
TARGET_LINK_LIBRARIES(clitkComposeVF ITKBasicFilters ITKIO clitkCommon)
-ADD_EXECUTABLE(clitkShroud clitkShroudGenericFilter.cxx clitkShroud.cxx clitkShroud_ggo.c)
-TARGET_LINK_LIBRARIES(clitkShroud ITKIO clitkCommon clitkJef fftw3)
-
-ADD_EXECUTABLE(clitkMergeSequence clitkMergeSequence.cxx clitkMergeSequenceGenericFilter.cxx clitkMergeSequence_ggo.c)
+WRAP_GGO(clitkMergeSequence_GGO_C clitkMergeSequence.ggo)
+ADD_EXECUTABLE(clitkMergeSequence clitkMergeSequence.cxx clitkMergeSequenceGenericFilter.cxx ${clitkMergeSequence_GGO_C})
TARGET_LINK_LIBRARIES(clitkMergeSequence ITKIO clitkCommon)
-ADD_EXECUTABLE(clitkBackProjectImage clitkBackProjectImage.cxx clitkBackProjectImageGenericFilter.cxx clitkBackProjectImage_ggo.c)
-TARGET_LINK_LIBRARIES(clitkBackProjectImage ITKIO clitkCommon clitkJef)
+WRAP_GGO(clitkBackProjectImage_GGO_C clitkBackProjectImage.ggo)
+ADD_EXECUTABLE(clitkBackProjectImage clitkBackProjectImage.cxx clitkBackProjectImageGenericFilter.cxx ${clitkBackProjectImage_GGO_C})
+TARGET_LINK_LIBRARIES(clitkBackProjectImage ITKIO clitkCommon )
-ADD_EXECUTABLE(clitkCropImage clitkCropImage.cxx clitkCropImageGenericFilter.cxx clitkCropImage_ggo.c)
+WRAP_GGO(clitkCropImage_GGO_C clitkCropImage.ggo)
+ADD_EXECUTABLE(clitkCropImage clitkCropImage.cxx clitkCropImageGenericFilter.cxx ${clitkCropImage_GGO_C})
TARGET_LINK_LIBRARIES(clitkCropImage clitkCommon ITKIO)
-ADD_EXECUTABLE(clitkExtractSlice clitkExtractSlice.cxx clitkExtractSliceGenericFilter.cxx clitkExtractSlice_ggo.c)
-TARGET_LINK_LIBRARIES(clitkExtractSlice clitkCommon ITKIO)
+# WRAP_GGO(clitkExtractSlice_GGO_C clitkExtractSlice.ggo)
+# ADD_EXECUTABLE(clitkExtractSlice clitkExtractSlice.cxx clitkExtractSliceGenericFilter.cxx ${clitkExtractSlice_GGO_C})
+# TARGET_LINK_LIBRARIES(clitkExtractSlice clitkCommon ITKIO)
-ADD_EXECUTABLE(clitkFlipImage clitkFlipImage.cxx clitkFlipImageGenericFilter.cxx clitkFlipImage_ggo.c)
+WRAP_GGO(clitkFlipImage_GGO_C clitkFlipImage.ggo)
+ADD_EXECUTABLE(clitkFlipImage clitkFlipImage.cxx clitkFlipImageGenericFilter.cxx ${clitkFlipImage_GGO_C})
TARGET_LINK_LIBRARIES(clitkFlipImage clitkCommon ITKIO)
-ADD_EXECUTABLE(clitkMirrorPadImage clitkMirrorPadImage.cxx clitkMirrorPadImageGenericFilter.cxx clitkMirrorPadImage_ggo.c)
+WRAP_GGO(clitkMirrorPadImage_GGO_C clitkMirrorPadImage.ggo)
+ADD_EXECUTABLE(clitkMirrorPadImage clitkMirrorPadImage.cxx clitkMirrorPadImageGenericFilter.cxx ${clitkMirrorPadImage_GGO_C})
TARGET_LINK_LIBRARIES(clitkMirrorPadImage clitkCommon ITKIO)
-ADD_EXECUTABLE(clitkImageMoment clitkImageMoment.cxx clitkImageMomentGenericFilter.cxx clitkImageMoment_ggo.c)
-TARGET_LINK_LIBRARIES(clitkImageMoment clitkCommon ITKI)
+WRAP_GGO(clitkImageMoment_GGO_C clitkImageMoment.ggo)
+ADD_EXECUTABLE(clitkImageMoment clitkImageMoment.cxx clitkImageMomentGenericFilter.cxx ${clitkImageMoment_GGO_C})
+TARGET_LINK_LIBRARIES(clitkImageMoment clitkCommon ITKIO)
-ADD_EXECUTABLE(clitkImageStatistics clitkImageStatistics.cxx clitkImageStatisticsGenericFilter.cxx clitkImageStatistics_ggo.c)
+WRAP_GGO(clitkImageStatistics_GGO_C clitkImageStatistics.ggo)
+ADD_EXECUTABLE(clitkImageStatistics clitkImageStatistics.cxx clitkImageStatisticsGenericFilter.cxx ${clitkImageStatistics_GGO_C})
TARGET_LINK_LIBRARIES(clitkImageStatistics clitkCommon ITKIO ITKStatistics)
-ADD_EXECUTABLE(clitkSetOrigin clitkSetOrigin.cxx clitkSetOriginGenericFilter.cxx clitkSetOrigin_ggo.c)
-TARGET_LINK_LIBRARIES(clitkSetOrigin clitkCommon ITKIO ITKStatistics)
-
-ADD_EXECUTABLE(clitkGetOrigin clitkGetOrigin.cxx clitkGetOriginGenericFilter.cxx clitkGetOrigin_ggo.c)
+WRAP_GGO(clitkSetOrigin_GGO_C clitkSetOrigin.ggo)
+ADD_EXECUTABLE(clitkSetOrigin clitkSetOrigin.cxx clitkSetOriginGenericFilter.cxx ${clitkSetOrigin_GGO_C})
+TARGET_LINK_LIBRARIES(clitkSetOrigin clitkCommon ITKIO )
+
+WRAP_GGO(clitkGetOrigin_GGO_C clitkGetOrigin.ggo)
+ADD_EXECUTABLE(clitkGetOrigin clitkGetOrigin.cxx clitkGetOriginGenericFilter.cxx ${clitkGetOrigin_GGO_C})
TARGET_LINK_LIBRARIES(clitkGetOrigin clitkCommon ITKIO )
-ADD_EXECUTABLE(clitkGetDirection clitkGetDirection.cxx clitkGetDirectionGenericFilter.cxx clitkGetDirection_ggo.c)
+WRAP_GGO(clitkGetDirection_GGO_C clitkGetDirection.ggo)
+ADD_EXECUTABLE(clitkGetDirection clitkGetDirection.cxx clitkGetDirectionGenericFilter.cxx ${clitkGetDirection_GGO_C})
TARGET_LINK_LIBRARIES(clitkGetDirection clitkCommon ITKIO)
-ADD_EXECUTABLE(clitkSetDirection clitkSetDirection.cxx clitkSetDirectionGenericFilter.cxx clitkSetDirection_ggo.c)
+WRAP_GGO(clitkSetDirection_GGO_C clitkSetDirection.ggo)
+ADD_EXECUTABLE(clitkSetDirection clitkSetDirection.cxx clitkSetDirectionGenericFilter.cxx ${clitkSetDirection_GGO_C})
TARGET_LINK_LIBRARIES(clitkSetDirection clitkCommon ITKIO)
-ADD_EXECUTABLE(clitkGetSize clitkGetSize.cxx clitkGetSizeGenericFilter.cxx clitkGetSize_ggo.c)
-TARGET_LINK_LIBRARIES(clitkGetSize clitkJef clitkCommon ITKNumerics ITKStatistics ITKIO)
+WRAP_GGO(clitkGetSize_GGO_C clitkGetSize.ggo)
+ADD_EXECUTABLE(clitkGetSize clitkGetSize.cxx clitkGetSizeGenericFilter.cxx ${clitkGetSize_GGO_C})
+TARGET_LINK_LIBRARIES(clitkGetSize clitkCommon ITKIO)
-ADD_EXECUTABLE(clitkGetSpacing clitkGetSpacing.cxx clitkGetSpacingGenericFilter.cxx clitkGetSpacing_ggo.c)
-TARGET_LINK_LIBRARIES(clitkGetSpacing clitkJef clitkCommon ITKNumerics ITKStatistics ITKIO)
+WRAP_GGO(clitkGetSpacing_GGO_C clitkGetSpacing.ggo)
+ADD_EXECUTABLE(clitkGetSpacing clitkGetSpacing.cxx clitkGetSpacingGenericFilter.cxx ${clitkGetSpacing_GGO_C})
+TARGET_LINK_LIBRARIES(clitkGetSpacing clitkCommon ITKIO)
-ADD_EXECUTABLE(clitkSetSpacing clitkSetSpacing.cxx clitkSetSpacingGenericFilter.cxx clitkSetSpacing_ggo.c)
-TARGET_LINK_LIBRARIES(clitkSetSpacing clitkJef clitkCommon ITKNumerics ITKStatistics ITKIO)
+WRAP_GGO(clitkSetSpacing_GGO_C clitkSetSpacing.ggo)
+ADD_EXECUTABLE(clitkSetSpacing clitkSetSpacing.cxx clitkSetSpacingGenericFilter.cxx ${clitkSetSpacing_GGO_C})
+TARGET_LINK_LIBRARIES(clitkSetSpacing clitkCommon ITKIO)
-ADD_EXECUTABLE(clitkCombineImage clitkCombineImage.cxx clitkCombineImageGenericFilter.cxx clitkCombineImage_ggo.c)
+WRAP_GGO(clitkCombineImage_GGO_C clitkCombineImage.ggo)
+ADD_EXECUTABLE(clitkCombineImage clitkCombineImage.cxx clitkCombineImageGenericFilter.cxx ${clitkCombineImage_GGO_C})
TARGET_LINK_LIBRARIES(clitkCombineImage clitkCommon ITKIO)
-ADD_EXECUTABLE(clitkPermuteAxes clitkPermuteAxes.cxx clitkPermuteAxesGenericFilter.cxx clitkPermuteAxes_ggo.c)
+WRAP_GGO(clitkPermuteAxes_GGO_C clitkPermuteAxes.ggo)
+ADD_EXECUTABLE(clitkPermuteAxes clitkPermuteAxes.cxx clitkPermuteAxesGenericFilter.cxx ${clitkPermuteAxes_GGO_C})
TARGET_LINK_LIBRARIES(clitkPermuteAxes clitkCommon ITKIO)
-ADD_EXECUTABLE(clitkChangeImageOrientation clitkChangeImageOrientation.cxx clitkChangeImageOrientationGenericFilter.cxx clitkChangeImageOrientation_ggo.c)
+WRAP_GGO(clitkChangeImageOrientation_GGO_C clitkChangeImageOrientation.ggo)
+ADD_EXECUTABLE(clitkChangeImageOrientation clitkChangeImageOrientation.cxx clitkChangeImageOrientationGenericFilter.cxx ${clitkChangeImageOrientation_GGO_C})
TARGET_LINK_LIBRARIES(clitkChangeImageOrientation clitkCommon ITKIO)
-ADD_EXECUTABLE(clitkVFArithm clitkVFArithm.cxx clitkVFArithmGenericFilter.cxx clitkVFArithm_ggo.c)
-TARGET_LINK_LIBRARIES(clitkVFArithm clitkJef clitkCommon ITKNumerics ITKStatistics ITKIO)
-
-ADD_EXECUTABLE(clitkVFConvert clitkVFConvert.cxx clitkVFConvertGenericFilter.cxx clitkVFConvert_ggo.c)
+WRAP_GGO(clitkVFConvert_GGO_C clitkVFConvert.ggo)
+ADD_EXECUTABLE(clitkVFConvert clitkVFConvert.cxx clitkVFConvertGenericFilter.cxx ${clitkVFConvert_GGO_C})
TARGET_LINK_LIBRARIES(clitkVFConvert ITKBasicFilters ITKIO clitkCommon )
-ADD_EXECUTABLE(clitkImageToVectorImage clitkImageToVectorImage.cxx clitkImageToVectorImageGenericFilter.cxx clitkImageToVectorImage_ggo.c)
-TARGET_LINK_LIBRARIES(clitkImageToVectorImage clitkJef clitkCommon ITKNumerics ITKStatistics ITKIO)
+WRAP_GGO(clitkImageToVectorImage_GGO_C clitkImageToVectorImage.ggo)
+ADD_EXECUTABLE(clitkImageToVectorImage clitkImageToVectorImage.cxx clitkImageToVectorImageGenericFilter.cxx ${clitkImageToVectorImage_GGO_C})
+TARGET_LINK_LIBRARIES(clitkImageToVectorImage clitkCommon ITKIO)
+
+WRAP_GGO(clitkVectorImageToImage_GGO_C clitkVectorImageToImage.ggo)
+ADD_EXECUTABLE(clitkVectorImageToImage clitkVectorImageToImage.cxx clitkVectorImageToImageGenericFilter.cxx ${clitkVectorImageToImage_GGO_C})
+TARGET_LINK_LIBRARIES(clitkVectorImageToImage clitkCommon ITKIO)
+
+WRAP_GGO(clitkBSplineCoefficientsToValues_GGO_C clitkBSplineCoefficientsToValues.ggo)
+ADD_EXECUTABLE(clitkBSplineCoefficientsToValues clitkBSplineCoefficientsToValues.cxx clitkBSplineCoefficientsToValuesGenericFilter.cxx ${clitkBSplineCoefficientsToValues_GGO_C})
+TARGET_LINK_LIBRARIES(clitkBSplineCoefficientsToValues clitkCommon ITKIO)
+
+WRAP_GGO(clitkValuesToBSplineCoefficients_GGO_C clitkValuesToBSplineCoefficients.ggo)
+ADD_EXECUTABLE(clitkValuesToBSplineCoefficients clitkValuesToBSplineCoefficients.cxx clitkValuesToBSplineCoefficientsGenericFilter.cxx ${clitkValuesToBSplineCoefficients_GGO_C})
+TARGET_LINK_LIBRARIES(clitkValuesToBSplineCoefficients clitkCommon ITKIO)
-ADD_EXECUTABLE(clitkVectorImageToImage clitkVectorImageToImage.cxx clitkVectorImageToImageGenericFilter.cxx clitkVectorImageToImage_ggo.c)
-TARGET_LINK_LIBRARIES(clitkVectorImageToImage clitkJef clitkCommon ITKNumerics ITKStatistics ITKIO)
--- /dev/null
+/*=========================================================================
+ 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 clitkBSplineCoefficientsToValues.cxx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+// clitk
+#include "clitkBSplineCoefficientsToValues_ggo.h"
+#include "clitkIO.h"
+#include "clitkBSplineCoefficientsToValuesGenericFilter.h"
+
+
+//--------------------------------------------------------------------
+int main(int argc, char * argv[]) {
+
+ // Init command line
+ GGO(clitkBSplineCoefficientsToValues, args_info);
+ CLITK_INIT;
+
+ // Filter
+ clitk::BSplineCoefficientsToValuesGenericFilter::Pointer genericFilter=clitk::BSplineCoefficientsToValuesGenericFilter::New();
+
+ genericFilter->SetArgsInfo(args_info);
+ genericFilter->Update();
+
+ return EXIT_SUCCESS;
+}// end main
+
+//--------------------------------------------------------------------
--- /dev/null
+#File clitkBSplineCoefficientsToValues.ggo
+Package "clitkBSplineCoefficientsToValues"
+version "1.0"
+purpose ""
+
+option "config" - "Config file" string no
+option "verbose" v "Verbose" flag off
+
+section "I/O"
+option "input" i "Input image filename" string yes
+option "output" o "Output image filename" string yes
+option "matrix" m "Matrix transform to add" string no
+
+section "Options"
+option "like" l "Resample output this image (size, spacing,origin)" string no
+option "size" - "New output size if different from input" int no multiple
+option "spacing" - "New output spacing if different from input" double no multiple
+option "origin" - "New output origin if different from input" double no multiple
+option "pad" - "Edge padding value" double no default="0.0"
+option "order" - "Spline order of the coefficient image" int no default="3"
+
--- /dev/null
+/*=========================================================================
+ 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 clitkBSplineCoefficientsToValuesGenericFilter_cxx
+#define clitkBSplineCoefficientsToValuesGenericFilter_cxx
+
+/* =================================================
+ * @file clitkBSplineCoefficientsToValuesGenericFilter.cxx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+#include "clitkBSplineCoefficientsToValuesGenericFilter.h"
+
+
+namespace clitk
+{
+
+
+ //-----------------------------------------------------------
+ // Constructor
+ //-----------------------------------------------------------
+ BSplineCoefficientsToValuesGenericFilter::BSplineCoefficientsToValuesGenericFilter()
+ {
+ m_Verbose=false;
+ m_InputFileName="";
+ }
+
+
+ //-----------------------------------------------------------
+ // Update
+ //-----------------------------------------------------------
+ void BSplineCoefficientsToValuesGenericFilter::Update()
+ {
+ // Read the Dimension and PixelType
+ int Dimension, Components;
+ std::string PixelType;
+ ReadImageDimensionAndPixelType(m_InputFileName, Dimension, PixelType, Components);
+
+
+ // Call UpdateWithDim
+ // if(Dimension==2) UpdateWithDim<2>(PixelType, Components);
+ if(Dimension==3) UpdateWithDim<3>(PixelType, Components);
+ //else if (Dimension==4)UpdateWithDim<4>(PixelType, Components);
+ else
+ {
+ std::cout<<"Error, Only for 2, 3 or 4 Dimensions!!!"<<std::endl ;
+ return;
+ }
+ }
+
+
+} //end clitk
+
+#endif //#define clitkBSplineCoefficientsToValuesGenericFilter_cxx
--- /dev/null
+/*=========================================================================
+ 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 clitkBSplineCoefficientsToValuesGenericFilter_h
+#define clitkBSplineCoefficientsToValuesGenericFilter_h
+
+/* =================================================
+ * @file clitkBSplineCoefficientsToValuesGenericFilter.h
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+// clitk include
+#include "clitkIO.h"
+#include "clitkCommon.h"
+#include "clitkBSplineCoefficientsToValues_ggo.h"
+#include "clitkTransformUtilities.h"
+
+//itk include
+#include "itkLightObject.h"
+#include "itkResampleImageFilter.h"
+#include "itkVectorResampleImageFilter.h"
+#include "itkBSplineResampleImageFunction.h"
+#include "clitkVectorBSplineResampleImageFunction.h"
+#include "itkAddImageFilter.h"
+#include "itkTransformToDeformationFieldSource.h"
+
+namespace clitk
+{
+
+
+ class ITK_EXPORT BSplineCoefficientsToValuesGenericFilter : public itk::LightObject
+ {
+ public:
+ //----------------------------------------
+ // ITK
+ //----------------------------------------
+ typedef BSplineCoefficientsToValuesGenericFilter Self;
+ typedef itk::LightObject Superclass;
+ typedef itk::SmartPointer<Self> Pointer;
+ typedef itk::SmartPointer<const Self> ConstPointer;
+
+ // Method for creation through the object factory
+ itkNewMacro(Self);
+
+ // Run-time type information (and related methods)
+ itkTypeMacro( BSplineCoefficientsToValuesGenericFilter, LightObject );
+
+
+ //----------------------------------------
+ // Typedefs
+ //----------------------------------------
+
+
+ //----------------------------------------
+ // Set & Get
+ //----------------------------------------
+ void SetArgsInfo(const args_info_clitkBSplineCoefficientsToValues & a)
+ {
+ m_ArgsInfo=a;
+ m_Verbose=m_ArgsInfo.verbose_flag;
+ m_InputFileName=m_ArgsInfo.input_arg;
+ }
+
+
+ //----------------------------------------
+ // Update
+ //----------------------------------------
+ void Update();
+
+ protected:
+
+ //----------------------------------------
+ // Constructor & Destructor
+ //----------------------------------------
+ BSplineCoefficientsToValuesGenericFilter();
+ ~BSplineCoefficientsToValuesGenericFilter() {};
+
+
+ //----------------------------------------
+ // Templated members
+ //----------------------------------------
+ template <unsigned int Dimension> void UpdateWithDim(std::string PixelType, unsigned int Components);
+ template <unsigned int Dimension, class PixelType> void UpdateWithDimAndPixelType();
+ template <unsigned int Dimension, class PixelType> void UpdateWithDimAndVectorType();
+
+ //----------------------------------------
+ // Data members
+ //----------------------------------------
+ args_info_clitkBSplineCoefficientsToValues m_ArgsInfo;
+ bool m_Verbose;
+ std::string m_InputFileName;
+
+ };
+
+
+} // end namespace clitk
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#include "clitkBSplineCoefficientsToValuesGenericFilter.txx"
+#endif
+
+#endif // #define clitkBSplineCoefficientsToValuesGenericFilter_h
--- /dev/null
+/*=========================================================================
+ 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 clitkBSplineCoefficientsToValuesGenericFilter_txx
+#define clitkBSplineCoefficientsToValuesGenericFilter_txx
+
+/* =================================================
+ * @file clitkBSplineCoefficientsToValuesGenericFilter.txx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+namespace clitk
+{
+
+ //-------------------------------------------------------------------
+ // Update with the number of dimensions
+ //-------------------------------------------------------------------
+ template<unsigned int Dimension>
+ void
+ BSplineCoefficientsToValuesGenericFilter::UpdateWithDim(std::string PixelType, unsigned int Components)
+ {
+ if (m_Verbose) std::cout << "Image was detected to be "<<Dimension<<"D and "<<Components<<" component(s) of "<< PixelType<<"..."<<std::endl;
+
+ if (Components==1)
+ {
+ // if(PixelType == "short"){
+ // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed short..." << std::endl;
+ // UpdateWithDimAndPixelType<Dimension, signed short>();
+ // }
+ // else if(PixelType == "unsigned_short"){
+ // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_short..." << std::endl;
+ // UpdateWithDimAndPixelType<Dimension, unsigned short>();
+ // }
+
+ // else if (PixelType == "unsigned_char"){
+ // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_char..." << std::endl;
+ // UpdateWithDimAndPixelType<Dimension, unsigned char>();
+ // }
+
+ // else if (PixelType == "char"){
+ // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed_char..." << std::endl;
+ // UpdateWithDimAndPixelType<Dimension, signed char>();
+ // }
+ // else {
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and float..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, float>();
+ // }
+ }
+
+ else
+ if (Components==3)
+ {
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and 3D float (DVF)" << std::endl;
+ UpdateWithDimAndVectorType<Dimension, itk::Vector<float, 3> >();
+ }
+
+ else std::cerr<<"Number of components is "<<Components<<", not supported!"<<std::endl;
+
+ }
+
+
+ //-------------------------------------------------------------------
+ // Update with the number of dimensions and the pixeltype
+ //-------------------------------------------------------------------
+ template <unsigned int Dimension, class PixelType>
+ void
+ BSplineCoefficientsToValuesGenericFilter::UpdateWithDimAndPixelType()
+ {
+
+ // ImageTypes
+ typedef itk::Image<PixelType, Dimension> InputImageType;
+ typedef itk::Image<PixelType, Dimension> OutputImageType;
+
+ // Read the input
+ typedef itk::ImageFileReader<InputImageType> InputReaderType;
+ typename InputReaderType::Pointer reader = InputReaderType::New();
+ reader->SetFileName( m_InputFileName);
+ reader->Update();
+ typename InputImageType::Pointer input= reader->GetOutput();
+
+ //Filter
+ typedef itk::ResampleImageFilter< InputImageType,OutputImageType > ResampleFilterType;
+ typename ResampleFilterType::Pointer resampler = ResampleFilterType::New();
+
+ // Properties
+ if (m_ArgsInfo.like_given)
+ {
+ typename InputReaderType::Pointer likeReader=InputReaderType::New();
+ likeReader->SetFileName(m_ArgsInfo.like_arg);
+ likeReader->Update();
+ resampler->SetOutputParametersFromImage(likeReader->GetOutput());
+ if (m_Verbose)std::cout<<"Resampling output like "<<m_ArgsInfo.like_arg<<"..."<<std::endl;
+ }
+ else
+ {
+ // Size
+ typename OutputImageType::SizeType outputSize;
+ if (m_ArgsInfo.size_given)
+ {
+ for(unsigned int i=0; i< Dimension; i++)
+ outputSize[i]=m_ArgsInfo.size_arg[i];
+ }
+ else outputSize=input->GetLargestPossibleRegion().GetSize();
+ if (m_Verbose)std::cout<<"Setting the size to "<<outputSize<<"..."<<std::endl;
+
+ // Spacing
+ typename OutputImageType::SpacingType outputSpacing;
+ if (m_ArgsInfo.spacing_given)
+ {
+ for(unsigned int i=0; i< Dimension; i++)
+ outputSpacing[i]=m_ArgsInfo.spacing_arg[i];
+ }
+ else outputSpacing=input->GetSpacing();
+ if (m_Verbose)std::cout<<"Setting the spacing to "<<outputSpacing<<"..."<<std::endl;
+
+ // Origin
+ typename OutputImageType::PointType outputOrigin;
+ if (m_ArgsInfo.origin_given)
+ {
+ for(unsigned int i=0; i< Dimension; i++)
+ outputOrigin[i]=m_ArgsInfo.origin_arg[i];
+ }
+ else outputOrigin=input->GetOrigin();
+ if (m_Verbose)std::cout<<"Setting the origin to "<<outputOrigin<<"..."<<std::endl;
+
+ // Set
+ resampler->SetSize( outputSize );
+ resampler->SetOutputSpacing( outputSpacing );
+ resampler->SetOutputOrigin( outputOrigin );
+
+ }
+
+ // Interp : coeff
+ typedef itk::BSplineResampleImageFunction<InputImageType, double> InterpolatorType;
+ typename InterpolatorType::Pointer interpolator=InterpolatorType::New();
+ interpolator->SetSplineOrder(m_ArgsInfo.order_arg);
+
+ // Set
+ resampler->SetInterpolator( interpolator);
+ resampler->SetDefaultPixelValue( static_cast<PixelType>(m_ArgsInfo.pad_arg) );
+ resampler->SetInput( input );
+
+ // Update
+ try
+ {
+ resampler->Update();
+ }
+ catch(itk::ExceptionObject)
+ {
+ std::cerr<<"Error resampling the image"<<std::endl;
+ }
+
+ typename OutputImageType::Pointer output = resampler->GetOutput();
+
+ // Output
+ typedef itk::ImageFileWriter<OutputImageType> WriterType;
+ typename WriterType::Pointer writer = WriterType::New();
+ writer->SetFileName(m_ArgsInfo.output_arg);
+ writer->SetInput(output);
+ writer->Update();
+ }
+
+
+ //-------------------------------------------------------------------
+ // Update with the number of dimensions and the Vectortype
+ //-------------------------------------------------------------------
+ template <unsigned int Dimension, class PixelType>
+ void
+ BSplineCoefficientsToValuesGenericFilter::UpdateWithDimAndVectorType()
+ {
+
+ // ImageTypes
+ typedef itk::Image<PixelType, Dimension> InputImageType;
+ typedef itk::Image<PixelType, Dimension> OutputImageType;
+
+ // Read the input
+ typedef itk::ImageFileReader<InputImageType> InputReaderType;
+ typename InputReaderType::Pointer reader = InputReaderType::New();
+ reader->SetFileName( m_InputFileName);
+ reader->Update();
+ typename InputImageType::Pointer input= reader->GetOutput();
+
+ //Filter
+ typedef itk::VectorResampleImageFilter< InputImageType,OutputImageType > ResampleFilterType;
+ typename ResampleFilterType::Pointer resampler = ResampleFilterType::New();
+
+ // Properties
+ if (m_ArgsInfo.like_given)
+ {
+ typename InputReaderType::Pointer likeReader=InputReaderType::New();
+ likeReader->SetFileName(m_ArgsInfo.like_arg);
+ likeReader->Update();
+
+ // Set
+ resampler->SetSize( likeReader->GetOutput()->GetLargestPossibleRegion().GetSize() );
+ resampler->SetOutputSpacing(likeReader->GetOutput()->GetSpacing() );
+ resampler->SetOutputOrigin( likeReader->GetOutput()->GetOrigin() );
+ if (m_Verbose)std::cout<<"Resampling output like "<<m_ArgsInfo.like_arg<<"..."<<std::endl;
+ }
+ else
+ {
+ // Size
+ typename OutputImageType::SizeType outputSize;
+ if (m_ArgsInfo.size_given)
+ {
+ for(unsigned int i=0; i< Dimension; i++)
+ outputSize[i]=m_ArgsInfo.size_arg[i];
+ }
+ else outputSize=input->GetLargestPossibleRegion().GetSize();
+ if (m_Verbose)std::cout<<"Setting the size to "<<outputSize<<"..."<<std::endl;
+
+ // Spacing
+ typename OutputImageType::SpacingType outputSpacing;
+ if (m_ArgsInfo.spacing_given)
+ {
+ for(unsigned int i=0; i< Dimension; i++)
+ outputSpacing[i]=m_ArgsInfo.spacing_arg[i];
+ }
+ else outputSpacing=input->GetSpacing();
+ if (m_Verbose)std::cout<<"Setting the spacing to "<<outputSpacing<<"..."<<std::endl;
+
+ // Origin
+ typename OutputImageType::PointType outputOrigin;
+ if (m_ArgsInfo.origin_given)
+ {
+ for(unsigned int i=0; i< Dimension; i++)
+ outputOrigin[i]=m_ArgsInfo.origin_arg[i];
+ }
+ else outputOrigin=input->GetOrigin();
+ if (m_Verbose)std::cout<<"Setting the origin to "<<outputOrigin<<"..."<<std::endl;
+
+ // Set
+ resampler->SetSize( outputSize );
+ resampler->SetOutputSpacing( outputSpacing );
+ resampler->SetOutputOrigin( outputOrigin );
+
+ }
+
+ // Interp : coeff
+ typedef clitk::VectorBSplineResampleImageFunction<InputImageType, double> InterpolatorType;
+ typename InterpolatorType::Pointer interpolator=InterpolatorType::New();
+ interpolator->SetSplineOrder(m_ArgsInfo.order_arg);
+
+
+ // Set
+ resampler->SetInterpolator( interpolator);
+ resampler->SetDefaultPixelValue( static_cast<PixelType>(m_ArgsInfo.pad_arg) );
+ resampler->SetInput( input );
+
+ // Update
+ try
+ {
+ resampler->Update();
+ }
+ catch(itk::ExceptionObject)
+ {
+ std::cerr<<"Error resampling the image"<<std::endl;
+ }
+
+ typename OutputImageType::Pointer output = resampler->GetOutput();
+ writeImage<OutputImageType>(output, "/home/jef/tmp/output1.mhd", true);
+
+
+ // Matrix Transform
+ if(m_ArgsInfo.matrix_given)
+ {
+ typedef itk::TransformToDeformationFieldSource<OutputImageType, double> ConvertorType;
+ typename ConvertorType::Pointer filter= ConvertorType::New();
+ filter->SetOutputParametersFromImage(output);
+
+ typedef itk::AffineTransform<double, Dimension> TransformType;
+ typename TransformType::Pointer transform =TransformType::New();
+ itk::Matrix<double, Dimension+1, Dimension+1> homMatrix= ReadMatrix<Dimension>( m_ArgsInfo.matrix_arg);
+ itk::Matrix<double, Dimension, Dimension> matrix =GetRotationalPartMatrix( homMatrix);
+ itk::Vector<double, Dimension> offset= GetTranslationPartMatrix( homMatrix);
+ transform->SetMatrix(matrix);
+ transform->SetOffset(offset);
+ filter->SetTransform(transform);
+ filter->Update();
+ typename OutputImageType::Pointer output2=filter->GetOutput();
+ writeImage<OutputImageType>(output2, "/home/jef/tmp/output2.mhd", true);
+
+ // Add
+ typedef itk::AddImageFilter< OutputImageType, OutputImageType, OutputImageType > AddType;
+ typename AddType::Pointer adder= AddType::New();
+ adder->SetInput(output);
+ adder->SetInput(1,output2);
+ adder->Update();
+ output=adder->GetOutput();
+ }
+
+
+ // Output
+ typedef itk::ImageFileWriter<OutputImageType> WriterType;
+ typename WriterType::Pointer writer = WriterType::New();
+ writer->SetFileName(m_ArgsInfo.output_arg);
+ writer->SetInput(output);
+ writer->Update();
+ }
+
+}//end clitk
+
+#endif //#define clitkBSplineCoefficientsToValuesGenericFilter_txx
--- /dev/null
+/*=========================================================================
+ 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 CLITKBACKPROJECTIMAGE_CXX
+#define CLITKBACKPROJECTIMAGE_CXX
+/**
+ =================================================
+ * @file clitkBackProjectImage.cxx
+ * @author Jef Vandemeulebroucke <jefvdmb@gmail.com>
+ * @date 24 February 2009
+ *
+ * @brief "Back project a 3D image using a Cone-Beam geometry"
+ =================================================*/
+
+// clitk include
+#include "clitkBackProjectImage_ggo.h"
+#include "clitkBackProjectImageGenericFilter.h"
+#include "clitkIO.h"
+#include "clitkImageCommon.h"
+#include "clitkTransformUtilities.h"
+
+int main(int argc, char * argv[]) {
+
+ //Init command line
+ GGO(clitkBackProjectImage, args_info);
+ CLITK_INIT;
+
+ //Creation of a generic filter
+ clitk::BackProjectImageGenericFilter::Pointer genericFilter = clitk::BackProjectImageGenericFilter::New();
+
+ //Passing the arguments to the generic filter
+ genericFilter->SetArgsInfo(args_info);
+
+ //update
+ genericFilter->Update();
+
+ return 0;
+}
+
+#endif
+
+
--- /dev/null
+#File clitkConeBeamProjectImage.ggo
+#Author: Jef Vandemeulebroucke <jefvdmb@gmail.com>
+#Date : Tue 24 February 2009 16.35
+
+Package "clitk"
+Version "Back project a 2D image with cone-beam geometry"
+
+option "config" - "Config file" string no
+
+
+section "Run Time"
+
+option "verbose" v "Verbose" flag off
+option "threads" - "Number of threads to use (default=min(cores,8))" int no
+
+
+section "Input"
+
+option "input" i "Input grid filename" string yes
+option "output" o "Output grid filename" string yes
+option "mask" m "3D Mask in which the filter should be applied (not supported yet;-)" string no
+
+
+section "Projection Parameters"
+
+option "iso" - "The isocenter" float no multiple default="0.0"
+option "screen" - "Specify the source to screen distance in mm" float no default="1536.0"
+option "axis" - "Specify the source to axis distance in mm" float no default="1000.0"
+option "angle" - "Specify the projection angle" float no default="0.0"
+option "matrix" - "Rigid tranform prior to projection (4x4)" string no
+option "pad" - "Padding value" float no default="0.0"
+
+
+section "Output Image"
+
+option "like" - "Make output like this image" string no
+option "origin" - "Origin for the output image" double multiple no default="0.0"
+option "size" - "Size for the output image" int multiple no default="100"
+option "spacing" - "Spacing for the output image" double multiple no default="1.0"
+
+
--- /dev/null
+/*=========================================================================
+ 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 CLITKBACKPROJECTIMAGEGENERICFILTER_CXX
+#define CLITKBACKPROJECTIMAGEGENERICFILTER_CXX
+
+/**
+ * @file clitkBackProjectImageGenericFilter.cxx
+ * @author Jef Vandemeulebroucke <jef@creatis.insa-lyon.fr>
+ * @date Wed April 30 13:47:57 2008
+ *
+ * @brief
+ *
+ *
+ */
+
+#include "clitkBackProjectImageGenericFilter.h"
+
+namespace clitk
+{
+
+ //====================================================================
+ // Constructor
+ BackProjectImageGenericFilter::BackProjectImageGenericFilter()
+ {
+ m_Verbose=false;
+ m_InputFileName="";
+ }
+
+ //====================================================================
+ // Update
+ void BackProjectImageGenericFilter::Update()
+ {
+
+ //Read the PixelType and dimension of the input image
+ int Dimension;
+ std::string PixelType;
+ clitk::ReadImageDimensionAndPixelType(m_InputFileName, Dimension, PixelType);
+
+ //Launch for the right pixelType
+ if (Dimension==2)
+ {
+ if (m_Verbose) std::cout << "Input was detected to be "<< Dimension << "D and " << PixelType << "..." << std::endl;
+
+
+ if(PixelType == "short"){
+ if (m_Verbose) std::cout << "Launching back projection in signed short..." << std::endl;
+ UpdateWithPixelType<signed short>();
+ }
+
+// else if(PixelType == "unsigned_short"){
+// if (m_Verbose) std::cout << "Launching Projection in unsigned_short..." << std::endl;
+// UpdateWithPixelType<unsigned short>();
+// }
+
+ else if (PixelType == "unsigned_char"){
+ if (m_Verbose) std::cout << "Launching Projection in unsigned_char..." << std::endl;
+ UpdateWithPixelType<unsigned char>();
+ }
+
+// else if (PixelType == "char"){
+// if (m_Verbose) std::cout << "Launching Projection in signed_char..." << std::endl;
+// UpdateWithPixelType<signed char>();
+// }
+ else {
+ if (m_Verbose) std::cout << "Launching Projection in float..." << std::endl;
+ UpdateWithPixelType<float>();
+ }
+ }
+ else std::cerr<<"The input image should be 2D!"<<std::endl;
+
+ }
+
+
+ //====================================================================
+
+}
+#endif //#define CLITKBACKPROJECTIMAGEGENERICFILTER_CXX
--- /dev/null
+/*=========================================================================
+ 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 CLITKBACKPROJECTIMAGEGENERICFILTER__H
+#define CLITKBACKPROJECTIMAGEGENERICFILTER__H
+/**
+ =================================================
+ * @file clitkBackProjectImageGenericFilter.h
+ * @author Jef Vandemeulebroucke <jef@creatis.insa-lyon.fr>
+ * @date 30 April 2008
+ *
+ * @brief Project a 3D image using a ConeBeam geometry
+ *
+ =================================================*/
+
+// clitk include
+#include "clitkIO.h"
+#include "clitkImageCommon.h"
+#include "clitkCommon.h"
+#include "clitkImageCommon.h"
+#include "clitkBackProjectImageFilter.h"
+#include "clitkBackProjectImage_ggo.h"
+
+// itk include
+#include "itkLightObject.h"
+
+
+namespace clitk {
+
+ //====================================================================
+ class BackProjectImageGenericFilter: public itk::LightObject
+ {
+ public:
+
+ //================================================
+ typedef BackProjectImageGenericFilter Self;
+ typedef itk::LightObject Superclass;
+ typedef itk::SmartPointer<Self> Pointer;
+ typedef itk::SmartPointer<const Self> ConstPointer;
+
+ //================================================
+ itkNewMacro(Self);
+
+ //====================================================================
+ // Set methods
+ void SetArgsInfo(const args_info_clitkBackProjectImage a)
+ {
+ m_ArgsInfo=a;
+ m_InputFileName=m_ArgsInfo.input_arg;
+ m_Verbose=m_ArgsInfo.verbose_flag;
+ }
+
+ //====================================================================
+ // Update
+ virtual void Update();
+
+ protected:
+ const char * GetNameOfClass() const { return "BackProjectImageGenericFilter"; }
+
+ //====================================================================
+ // Constructor & Destructor
+ BackProjectImageGenericFilter();
+ ~BackProjectImageGenericFilter(){;}
+
+ //====================================================================
+ //Protected member functions
+ template <class PixelType> void UpdateWithPixelType();
+
+ args_info_clitkBackProjectImage m_ArgsInfo;
+ bool m_Verbose;
+ std::string m_InputFileName;
+
+ };
+
+} // end namespace clitk
+#ifndef ITK_MANUAL_INSTANTIATION
+#include "clitkBackProjectImageGenericFilter.txx"
+#endif
+
+#endif //#define CLITKBACKPROJECTIMAGEGENERICFILTER__H
--- /dev/null
+/*=========================================================================
+ 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 CLITKBACKPROJECTIMAGEGENERICFILTER_TXX
+#define CLITKBACKPROJECTIMAGEGENERICFILTER_TXX
+/**
+ =================================================
+ * @file clitkBackProjectImageGenericFilter.txx
+ * @author Jef Vandemeulebroucke <jef@creatis.insa-lyon.fr>
+ * @date 30 April 2008
+ *
+ * @brief Project a 3D image using a cone-beam geometry
+ *
+ =================================================*/
+
+
+namespace clitk
+{
+
+ //================================================================================
+ template <class InputPixelType> void BackProjectImageGenericFilter::UpdateWithPixelType()
+ {
+
+ //---------------------------------
+ // Define the images
+ //---------------------------------
+ const unsigned int InputImageDimension=2;
+ typedef itk::Image<InputPixelType, InputImageDimension> InputImageType;
+ typedef itk::ImageFileReader<InputImageType> ImageReaderType;
+ typename ImageReaderType::Pointer reader = ImageReaderType::New();
+ reader->SetFileName(m_InputFileName);
+ reader->Update();
+ typename InputImageType::Pointer input = reader->GetOutput();
+
+ //Define the output type
+ //JV always float?
+ const unsigned int OutputImageDimension=3;
+ typedef float OutputPixelType;
+ typedef itk::Image<OutputPixelType, OutputImageDimension> OutputImageType;
+
+ //Create the BackProjectImageFilter
+ typedef BackProjectImageFilter<InputImageType, OutputImageType> BackProjectImageFilterType;
+ typename BackProjectImageFilterType::Pointer filter=BackProjectImageFilterType::New();
+
+
+ //---------------------------------
+ //Pass all the necessary parameters
+ //---------------------------------
+ unsigned int i=0;
+ filter->SetInput(input);
+ if (m_ArgsInfo.threads_given) filter->SetNumberOfThreads(m_ArgsInfo.threads_arg);
+
+ //Projection parameters
+ OutputImageType::PointType iso;
+ if (m_ArgsInfo.iso_given)
+ {
+ for(i=0;i<OutputImageDimension;i++)
+ iso[i]=m_ArgsInfo.iso_arg[i];
+ filter->SetIsoCenter(iso);
+ }
+ filter->SetSourceToScreen(m_ArgsInfo.screen_arg);
+ filter->SetSourceToAxis(m_ArgsInfo.axis_arg);
+ filter->SetProjectionAngle(m_ArgsInfo.angle_arg);
+ if (m_ArgsInfo.matrix_given)
+ {
+ itk::Matrix<double,4,4> rt =ReadMatrix3D(m_ArgsInfo.matrix_arg);
+ filter->SetRigidTransformMatrix(rt);
+ }
+ filter->SetEdgePaddingValue(static_cast<OutputPixelType>(m_ArgsInfo.pad_arg));
+
+ //Output image info
+ if (m_ArgsInfo.like_given)
+ {
+ typedef itk::ImageFileReader<OutputImageType> ReaderType;
+ ReaderType::Pointer reader2=ReaderType::New();
+ reader2->SetFileName(m_ArgsInfo.like_arg);
+ reader2->Update();
+
+ OutputImageType::Pointer image=reader2->GetOutput();
+ filter->SetOutputParametersFromImage(image);
+ }
+ else
+ {
+ if(m_ArgsInfo.origin_given)
+ {
+ OutputImageType::PointType origin;
+ for(i=0;i<OutputImageDimension;i++)
+ origin[i]=m_ArgsInfo.origin_arg[i];
+ filter->SetOutputOrigin(origin);
+ }
+ if (m_ArgsInfo.spacing_given)
+ {
+ OutputImageType::SpacingType spacing;
+ for(i=0;i<OutputImageDimension;i++)
+ spacing[i]=m_ArgsInfo.spacing_arg[i];
+ filter->SetOutputSpacing(spacing);
+ }
+ if (m_ArgsInfo.spacing_given)
+ {
+ OutputImageType::SizeType size;
+ for(i=0;i<OutputImageDimension;i++)
+ size[i]=m_ArgsInfo.size_arg[i];
+ filter->SetOutputSize(size);
+ }
+ }
+
+ //Go
+ filter->Update();
+
+ //Get the output
+ OutputImageType::Pointer output=filter->GetOutput();
+
+ //Write the output
+ typedef itk::ImageFileWriter<OutputImageType> OutputWriterType;
+ OutputWriterType::Pointer outputWriter = OutputWriterType::New();
+ outputWriter->SetInput(output);
+ outputWriter->SetFileName(m_ArgsInfo.output_arg);
+ if (m_Verbose)std::cout<<"Writing back projected image..."<<std::endl;
+ outputWriter->Update();
+ }
+
+}
+
+#endif //#define CLITKBACKPROJECTIMAGEGENERICFILTER_TXX
--- /dev/null
+/*=========================================================================
+ 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 clitkChangeImageOrientation.cxx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+// clitk
+#include "clitkChangeImageOrientation_ggo.h"
+#include "clitkIO.h"
+#include "clitkChangeImageOrientationGenericFilter.h"
+
+
+//--------------------------------------------------------------------
+int main(int argc, char * argv[]) {
+
+ // Init command line
+ GGO(clitkChangeImageOrientation, args_info);
+ CLITK_INIT;
+
+ // Filter
+ clitk::ChangeImageOrientationGenericFilter::Pointer genericFilter=clitk::ChangeImageOrientationGenericFilter::New();
+
+ genericFilter->SetArgsInfo(args_info);
+ genericFilter->Update();
+
+ return EXIT_SUCCESS;
+}// end main
+
+//--------------------------------------------------------------------
--- /dev/null
+#File clitkChangeImageOrientation.ggo
+Package "clitkChangeImageOrientation"
+version "1.0"
+purpose ""
+
+option "config" - "Config file" string no
+option "verbose" v "Verbose" flag off
+
+option "input" i "Input image filename" string yes
+option "output" o "Output image filename" string yes
+
+
--- /dev/null
+/*=========================================================================
+ 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 clitkChangeImageOrientationGenericFilter_cxx
+#define clitkChangeImageOrientationGenericFilter_cxx
+
+/* =================================================
+ * @file clitkChangeImageOrientationGenericFilter.cxx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+#include "clitkChangeImageOrientationGenericFilter.h"
+
+
+namespace clitk
+{
+
+
+ //-----------------------------------------------------------
+ // Constructor
+ //-----------------------------------------------------------
+ ChangeImageOrientationGenericFilter::ChangeImageOrientationGenericFilter()
+ {
+ m_Verbose=false;
+ m_InputFileName="";
+ }
+
+
+ //-----------------------------------------------------------
+ // Update
+ //-----------------------------------------------------------
+ void ChangeImageOrientationGenericFilter::Update()
+ {
+ // Read the Dimension and PixelType
+ int Dimension;
+ std::string PixelType;
+ ReadImageDimensionAndPixelType(m_InputFileName, Dimension, PixelType);
+
+
+ // Call UpdateWithDim
+ // if(Dimension==2) UpdateWithDim<2>(PixelType);
+ if(Dimension==3) UpdateWithDim<3>(PixelType);
+ // else if (Dimension==4)UpdateWithDim<4>(PixelType);
+ else
+ {
+ std::cout<<"Error, Only for 3 Dimensions!!!"<<std::endl ;
+ return;
+ }
+ }
+
+
+} //end clitk
+
+#endif //#define clitkChangeImageOrientationGenericFilter_cxx
--- /dev/null
+/*=========================================================================
+ 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 clitkChangeImageOrientationGenericFilter_h
+#define clitkChangeImageOrientationGenericFilter_h
+
+/* =================================================
+ * @file clitkChangeImageOrientationGenericFilter.h
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+// clitk include
+#include "clitkIO.h"
+#include "clitkCommon.h"
+#include "clitkImageCommon.h"
+#include "clitkChangeImageOrientation_ggo.h"
+
+//itk include
+#include "itkLightObject.h"
+#include "itkOrientImageFilter.h"
+#include "itkSpatialOrientation.h"
+
+namespace clitk
+{
+
+
+ class ITK_EXPORT ChangeImageOrientationGenericFilter : public itk::LightObject
+ {
+ public:
+ //----------------------------------------
+ // ITK
+ //----------------------------------------
+ typedef ChangeImageOrientationGenericFilter Self;
+ typedef itk::LightObject Superclass;
+ typedef itk::SmartPointer<Self> Pointer;
+ typedef itk::SmartPointer<const Self> ConstPointer;
+
+ // Method for creation through the object factory
+ itkNewMacro(Self);
+
+ // Run-time type information (and related methods)
+ itkTypeMacro( ChangeImageOrientationGenericFilter, LightObject );
+
+
+ //----------------------------------------
+ // Typedefs
+ //----------------------------------------
+
+
+ //----------------------------------------
+ // Set & Get
+ //----------------------------------------
+ void SetArgsInfo(const args_info_clitkChangeImageOrientation & a)
+ {
+ m_ArgsInfo=a;
+ m_Verbose=m_ArgsInfo.verbose_flag;
+ m_InputFileName=m_ArgsInfo.input_arg;
+ }
+
+
+ //----------------------------------------
+ // Update
+ //----------------------------------------
+ void Update();
+
+ protected:
+
+ //----------------------------------------
+ // Constructor & Destructor
+ //----------------------------------------
+ ChangeImageOrientationGenericFilter();
+ ~ChangeImageOrientationGenericFilter() {};
+
+
+ //----------------------------------------
+ // Templated members
+ //----------------------------------------
+ template <unsigned int Dimension> void UpdateWithDim(std::string PixelType);
+ template <unsigned int Dimension, class PixelType> void UpdateWithDimAndPixelType();
+
+
+ //----------------------------------------
+ // Data members
+ //----------------------------------------
+ args_info_clitkChangeImageOrientation m_ArgsInfo;
+ bool m_Verbose;
+ std::string m_InputFileName;
+
+ };
+
+
+} // end namespace clitk
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#include "clitkChangeImageOrientationGenericFilter.txx"
+#endif
+
+#endif // #define clitkChangeImageOrientationGenericFilter_h
--- /dev/null
+/*=========================================================================
+ 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 clitkChangeImageOrientationGenericFilter_txx
+#define clitkChangeImageOrientationGenericFilter_txx
+
+/* =================================================
+ * @file clitkChangeImageOrientationGenericFilter.txx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+namespace clitk
+{
+
+ //-------------------------------------------------------------------
+ // Update with the number of dimensions
+ //-------------------------------------------------------------------
+ template<unsigned int Dimension>
+ void
+ ChangeImageOrientationGenericFilter::UpdateWithDim(std::string PixelType)
+ {
+ if (m_Verbose) std::cout << "Image was detected to be "<<Dimension<<"D and "<< PixelType<<"..."<<std::endl;
+
+ if(PixelType == "short"){
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed short..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, signed short>();
+ }
+ // else if(PixelType == "unsigned_short"){
+ // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_short..." << std::endl;
+ // UpdateWithDimAndPixelType<Dimension, unsigned short>();
+ // }
+
+ else if (PixelType == "unsigned_char"){
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_char..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, unsigned char>();
+ }
+
+ // else if (PixelType == "char"){
+ // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed_char..." << std::endl;
+ // UpdateWithDimAndPixelType<Dimension, signed char>();
+ // }
+ else {
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and float..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, float>();
+ }
+ }
+
+
+ //-------------------------------------------------------------------
+ // Update with the number of dimensions and the pixeltype
+ //-------------------------------------------------------------------
+ template <unsigned int Dimension, class PixelType>
+ void
+ ChangeImageOrientationGenericFilter::UpdateWithDimAndPixelType()
+ {
+
+ // ImageTypes
+ typedef itk::Image<PixelType, Dimension> InputImageType;
+ typedef itk::Image<PixelType, Dimension> OutputImageType;
+
+ // Read the input
+ typedef itk::ImageFileReader<InputImageType> InputReaderType;
+ typename InputReaderType::Pointer reader = InputReaderType::New();
+ reader->SetFileName( m_InputFileName);
+ reader->Update();
+ typename InputImageType::Pointer input= reader->GetOutput();
+
+ // Filter
+ typedef itk::OrientImageFilter<InputImageType,InputImageType> OrientFilterType;
+ typename OrientFilterType::Pointer orienter = itk::OrientImageFilter<InputImageType,InputImageType>::New();
+ orienter->UseImageDirectionOn();
+ orienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_RIP);
+ orienter->SetInput(input);
+ orienter->Update();
+ typename OutputImageType::Pointer output=orienter->GetOutput();
+
+
+ // Output
+ typedef itk::ImageFileWriter<OutputImageType> WriterType;
+ typename WriterType::Pointer writer = WriterType::New();
+ writer->SetFileName(m_ArgsInfo.output_arg);
+ writer->SetInput(output);
+ writer->Update();
+
+ }
+
+
+}//end clitk
+
+#endif //#define clitkChangeImageOrientationGenericFilter_txx
--- /dev/null
+/*=========================================================================
+ 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 clitkCombineImage.cxx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+// clitk
+#include "clitkCombineImage_ggo.h"
+#include "clitkIO.h"
+#include "clitkCombineImageGenericFilter.h"
+
+
+//--------------------------------------------------------------------
+int main(int argc, char * argv[]) {
+
+ // Init command line
+ GGO(clitkCombineImage, args_info);
+ CLITK_INIT;
+
+ // Filter
+ clitk::CombineImageGenericFilter::Pointer genericFilter=clitk::CombineImageGenericFilter::New();
+
+ genericFilter->SetArgsInfo(args_info);
+ genericFilter->Update();
+
+ return EXIT_SUCCESS;
+}// end main
+
+//--------------------------------------------------------------------
--- /dev/null
+#File clitkCombineImage.ggo
+Package "clitkCombineImage"
+version "1.0"
+purpose ""
+
+option "config" - "Config file" string no
+option "verbose" v "Verbose" flag off
+
+option "input" i "Input image filename" string yes
+option "input2" j "Input image filename" string yes
+option "mask" m "Binary image: if(mask) input1,else input2" string yes
+option "output" o "Output image filename" string yes
+
+
--- /dev/null
+/*=========================================================================
+ 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 clitkCombineImageFilter_h
+#define clitkCombineImageFilter_h
+
+/* =================================================
+ * @file clitkCombineImageFilter.h
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+// clitk include
+#include "clitkIO.h"
+#include "clitkCommon.h"
+
+//itk include
+#include "itkImageToImageFilter.h"
+
+namespace clitk
+{
+
+ template <class InputImageType>
+ class ITK_EXPORT CombineImageFilter :
+ public itk::ImageToImageFilter<InputImageType, InputImageType>
+ {
+ public:
+ //----------------------------------------
+ // ITK
+ //----------------------------------------
+ typedef CombineImageFilter Self;
+ typedef itk::ImageToImageFilter<InputImageType, InputImageType> Superclass;
+ typedef itk::SmartPointer<Self> Pointer;
+ typedef itk::SmartPointer<const Self> ConstPointer;
+
+ // Method for creation through the object factory
+ itkNewMacro(Self);
+
+ // Run-time type information (and related methods)
+ itkTypeMacro( CombineImageFilter, ImageToImageFilter );
+
+ /** Dimension of the domain space. */
+ itkStaticConstMacro(InputImageDimension, unsigned int, Superclass::InputImageDimension);
+ itkStaticConstMacro(OutputImageDimension, unsigned int, Superclass::OutputImageDimension);
+ typedef itk::Image<int, InputImageDimension> MaskImageType;
+
+ //----------------------------------------
+ // Typedefs
+ //----------------------------------------
+ typedef typename InputImageType::RegionType OutputImageRegionType;
+
+ //----------------------------------------
+ // Set & Get
+ //----------------------------------------
+ itkBooleanMacro(Verbose);
+ itkSetMacro( Verbose, bool);
+ itkGetConstReferenceMacro( Verbose, bool);
+
+ void SetMask(typename MaskImageType::Pointer m){m_Mask=m;}
+ typename MaskImageType::Pointer GetMask(void){return m_Mask;}
+
+
+ protected:
+
+ //----------------------------------------
+ // Constructor & Destructor
+ //----------------------------------------
+ CombineImageFilter();
+ ~CombineImageFilter() {};
+
+ //----------------------------------------
+ // Update
+ //----------------------------------------
+ // Generate Data
+ void ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread, int threadId);
+
+ //----------------------------------------
+ // Data members
+ //----------------------------------------
+ bool m_Verbose;
+ typename MaskImageType::Pointer m_Mask;
+
+
+ };
+
+
+} // end namespace clitk
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#include "clitkCombineImageFilter.txx"
+#endif
+
+#endif // #define clitkCombineImageFilter_h
+
+
--- /dev/null
+/*=========================================================================
+ 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 clitkCombineImageFilter_txx
+#define clitkCombineImageFilter_txx
+
+/* =================================================
+ * @file clitkCombineImageFilter.txx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+namespace clitk
+{
+
+ //-------------------------------------------------------------------
+ // Update with the number of dimensions
+ //-------------------------------------------------------------------
+ template<class InputImageType>
+ CombineImageFilter<InputImageType>::CombineImageFilter()
+ {
+ m_Verbose=false;
+ }
+
+
+ //-------------------------------------------------------------------
+ // Update with the number of dimensions and the pixeltype
+ //-------------------------------------------------------------------
+ template<class InputImageType>
+ void
+ CombineImageFilter<InputImageType>::ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread, int threadId)
+ {
+ typename InputImageType::ConstPointer input1=this->GetInput(0);
+ typename InputImageType::ConstPointer input2=this->GetInput(1);
+ typename InputImageType::Pointer output=this->GetOutput();
+
+ typedef itk::ImageRegionIterator<InputImageType> IteratorType;
+ typedef itk::ImageRegionConstIterator<InputImageType> ConstIteratorType;
+ typedef itk::ImageRegionConstIterator<MaskImageType> MaskIteratorType;
+
+ ConstIteratorType it1(input1, outputRegionForThread);
+ ConstIteratorType it2(input2, outputRegionForThread);
+ MaskIteratorType itM(m_Mask, outputRegionForThread);
+ IteratorType itO(output, outputRegionForThread);
+
+ it1.GoToBegin();
+ it2.GoToBegin();
+ itM.GoToBegin();
+ itO.GoToBegin();
+
+ while(! itO.IsAtEnd())
+ {
+ if(itM.Get())
+ itO.Set(it1.Get());
+ else
+ itO.Set(it2.Get());
+
+ ++it1;
+ ++it2;
+ ++itM;
+ ++itO;
+ }
+
+ }
+
+
+}//end clitk
+
+#endif //#define clitkCombineImageFilter_txx
--- /dev/null
+/*=========================================================================
+ 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 clitkCombineImageGenericFilter_cxx
+#define clitkCombineImageGenericFilter_cxx
+
+/* =================================================
+ * @file clitkCombineImageGenericFilter.cxx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+#include "clitkCombineImageGenericFilter.h"
+
+
+namespace clitk
+{
+
+
+ //-----------------------------------------------------------
+ // Constructor
+ //-----------------------------------------------------------
+ CombineImageGenericFilter::CombineImageGenericFilter()
+ {
+ m_Verbose=false;
+ m_InputFileName="";
+ }
+
+
+ //-----------------------------------------------------------
+ // Update
+ //-----------------------------------------------------------
+ void CombineImageGenericFilter::Update()
+ {
+ // Read the Dimension and PixelType
+ int Dimension, Components;
+ std::string PixelType;
+ ReadImageDimensionAndPixelType(m_InputFileName, Dimension, PixelType, Components);
+
+
+ // Call UpdateWithDim
+ if(Dimension==2) UpdateWithDim<2>(PixelType, Components);
+ else if(Dimension==3) UpdateWithDim<3>(PixelType, Components);
+ else if (Dimension==4)UpdateWithDim<4>(PixelType, Components);
+ else
+ {
+ std::cout<<"Error, Only for 2, 3 or 4 Dimensions!!!"<<std::endl ;
+ return;
+ }
+ }
+
+
+} //end clitk
+
+#endif //#define clitkCombineImageGenericFilter_cxx
--- /dev/null
+/*=========================================================================
+ 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 clitkCombineImageGenericFilter_h
+#define clitkCombineImageGenericFilter_h
+
+/* =================================================
+ * @file clitkCombineImageGenericFilter.h
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+// clitk include
+#include "clitkIO.h"
+#include "clitkCommon.h"
+#include "clitkImageCommon.h"
+#include "clitkCombineImage_ggo.h"
+#include "clitkCombineImageFilter.h"
+
+//itk include
+#include "itkLightObject.h"
+
+namespace clitk
+{
+
+
+ class ITK_EXPORT CombineImageGenericFilter : public itk::LightObject
+ {
+ public:
+ //----------------------------------------
+ // ITK
+ //----------------------------------------
+ typedef CombineImageGenericFilter Self;
+ typedef itk::LightObject Superclass;
+ typedef itk::SmartPointer<Self> Pointer;
+ typedef itk::SmartPointer<const Self> ConstPointer;
+
+ // Method for creation through the object factory
+ itkNewMacro(Self);
+
+ // Run-time type information (and related methods)
+ itkTypeMacro( CombineImageGenericFilter, LightObject );
+
+
+ //----------------------------------------
+ // Typedefs
+ //----------------------------------------
+
+
+ //----------------------------------------
+ // Set & Get
+ //----------------------------------------
+ void SetArgsInfo(const args_info_clitkCombineImage & a)
+ {
+ m_ArgsInfo=a;
+ m_Verbose=m_ArgsInfo.verbose_flag;
+ m_InputFileName=m_ArgsInfo.input_arg;
+ }
+
+
+ //----------------------------------------
+ // Update
+ //----------------------------------------
+ void Update();
+
+ protected:
+
+ //----------------------------------------
+ // Constructor & Destructor
+ //----------------------------------------
+ CombineImageGenericFilter();
+ ~CombineImageGenericFilter() {};
+
+
+ //----------------------------------------
+ // Templated members
+ //----------------------------------------
+ template <unsigned int Dimension> void UpdateWithDim(std::string PixelType, int Components);
+ template <unsigned int Dimension, class PixelType> void UpdateWithDimAndPixelType();
+
+
+ //----------------------------------------
+ // Data members
+ //----------------------------------------
+ args_info_clitkCombineImage m_ArgsInfo;
+ bool m_Verbose;
+ std::string m_InputFileName;
+
+ };
+
+
+} // end namespace clitk
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#include "clitkCombineImageGenericFilter.txx"
+#endif
+
+#endif // #define clitkCombineImageGenericFilter_h
--- /dev/null
+/*=========================================================================
+ 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 clitkCombineImageGenericFilter_txx
+#define clitkCombineImageGenericFilter_txx
+
+/* =================================================
+ * @file clitkCombineImageGenericFilter.txx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+namespace clitk
+{
+
+ //-------------------------------------------------------------------
+ // Update with the number of dimensions
+ //-------------------------------------------------------------------
+ template<unsigned int Dimension>
+ void
+ CombineImageGenericFilter::UpdateWithDim(std::string PixelType, int Components)
+ {
+ if (m_Verbose) std::cout << "Image was detected to be "<<Dimension<<"D and "<<Components<<" component(s) of "<< PixelType<<"..."<<std::endl;
+
+ if (Components==1)
+ {
+ if(PixelType == "short"){
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed short..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, signed short>();
+ }
+ // else if(PixelType == "unsigned_short"){
+ // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_short..." << std::endl;
+ // UpdateWithDimAndPixelType<Dimension, unsigned short>();
+ // }
+
+ else if (PixelType == "unsigned_char"){
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_char..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, unsigned char>();
+ }
+
+ // else if (PixelType == "char"){
+ // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed_char..." << std::endl;
+ // UpdateWithDimAndPixelType<Dimension, signed char>();
+ // }
+ else {
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and float..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, float>();
+ }
+ }
+
+ else if (Components==3)
+ {
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and 3D float (DVF)" << std::endl;
+ UpdateWithDimAndPixelType<Dimension, itk::Vector<float, Dimension> >();
+ }
+ else std::cerr<<"Number of components is "<<Components<<", not supported!"<<std::endl;
+ }
+
+
+ //-------------------------------------------------------------------
+ // Update with the number of dimensions and the pixeltype
+ //-------------------------------------------------------------------
+ template <unsigned int Dimension, class PixelType>
+ void
+ CombineImageGenericFilter::UpdateWithDimAndPixelType()
+ {
+
+ // ImageTypes
+ typedef itk::Image<PixelType, Dimension> InputImageType;
+ typedef itk::Image<int, Dimension> MaskImageType;
+ typedef itk::Image<PixelType, Dimension> OutputImageType;
+
+ // Read the inputs
+ typedef itk::ImageFileReader<InputImageType> InputReaderType;
+ typename InputReaderType::Pointer reader = InputReaderType::New();
+ reader->SetFileName( m_InputFileName);
+ reader->Update();
+ typename InputImageType::Pointer input1= reader->GetOutput();
+ typename InputReaderType::Pointer reader2 = InputReaderType::New();
+ reader2->SetFileName( m_ArgsInfo.input2_arg);
+ reader2->Update();
+ typename InputImageType::Pointer input2= reader2->GetOutput();
+
+ // Read the mask
+ typedef itk::ImageFileReader<MaskImageType> MaskReaderType;
+ typename MaskReaderType::Pointer mReader = MaskReaderType::New();
+ mReader->SetFileName( m_ArgsInfo.mask_arg);
+ mReader->Update();
+ typename MaskImageType::Pointer mask= mReader->GetOutput();
+
+ // Filter
+ typedef CombineImageFilter<InputImageType> CombineImageFilterType;
+ typename CombineImageFilterType::Pointer filter=CombineImageFilterType::New();
+ filter->SetInput( input1 );
+ filter->SetInput(1, input2 );
+ filter->SetMask( mask );
+ filter->Update();
+ typename OutputImageType::Pointer output=filter->GetOutput();
+
+ // Output
+ typedef itk::ImageFileWriter<OutputImageType> WriterType;
+ typename WriterType::Pointer writer = WriterType::New();
+ writer->SetFileName(m_ArgsInfo.output_arg);
+ writer->SetInput(output);
+ writer->Update();
+
+ }
+
+
+}//end clitk
+
+#endif //#define clitkCombineImageGenericFilter_txx
--- /dev/null
+/*=========================================================================
+ 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 CLITKCOMPOSEVF_CXX
+#define CLITKCOMPOSEVF_CXX
+
+/**
+ * @file clitkComposeVF.cxx
+ * @author Jef Vandemeulebroucke <jefvdmb@gmail.com>
+ * @date July 20 10:14:53 2007
+ *
+ * @brief Read in two VF (ex mhd, vf)compose them using lirear interpolation.
+ *
+ */
+
+// clitk include
+#include "clitkComposeVF_ggo.h"
+#include "clitkIO.h"
+#include "clitkImageCommon.h"
+#include "clitkComposeVFGenericFilter.h"
+
+int main( int argc, char *argv[] )
+{
+
+ // Init command line
+ GGO(clitkComposeVF, args_info);
+ CLITK_INIT;
+
+ //Creation of the generic filter
+ clitk::ComposeVFGenericFilter::Pointer ComposeVFGenericFilter= clitk::ComposeVFGenericFilter::New();
+
+ //Pass the parameters
+ ComposeVFGenericFilter->SetInput1(args_info.input1_arg);
+ ComposeVFGenericFilter->SetInput2(args_info.input2_arg);
+ ComposeVFGenericFilter->SetOutput(args_info.output_arg);
+ //JV how to pass for different dims?
+ //ComposeVFGenericFilter->SetEdgePaddingValue(args_info.pad_arg);
+ ComposeVFGenericFilter->SetVerbose(args_info.verbose_flag);
+ ComposeVFGenericFilter->Update();
+
+ return EXIT_SUCCESS;
+}
+#endif
+
--- /dev/null
+#File clitkComposeVF.ggo
+#Author: Jef Vandemeulebroucke <jefvdmb@gmail.com>
+#Date : Tue 20 August 16.35
+
+Package "clitk"
+Version "Read two vector fields (.mhd, .vf, ..) and compose them using linear interpolation"
+
+option "config" - "Config file" string no
+option "input1" i "Input1 VF filename" string yes
+option "input2" j "Input2 VF filename" string yes
+option "output" o "Output VF filename" string yes
+option "pad" p "Edgepadding value" float multiple no default="0.0"
+option "verbose" v "Verbose" flag off
+
/*=========================================================================
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
- BSD See included LICENSE.txt file
- CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
======================================================================-====*/
-#ifndef CLITKIMAGEFILLREGIONGENERICFILTER_TXX
-#define CLITKIMAGEFILLREGIONGENERICFILTER_TXX
+#ifndef CLITKCOMPOSEVFGENERICFILTER_CXX
+#define CLITKCOMPOSEVFGENERICFILTER_CXX
+#include "clitkComposeVFGenericFilter.h"
-/*-------------------------------------------------
- * @file clitkImageFillRegionGenericFilter.txx
- * @author Cristina Gimenez <cristina.gs@gmail.com>
- * @date 9 August 2006
- *
- -------------------------------------------------*/
-#endif //#define CLITKIMAGEFILLREGIONGENERICFILTER_TXX
+namespace clitk {
+
+ clitk::ComposeVFGenericFilter::ComposeVFGenericFilter()
+ {
+ m_Verbose=false;
+ }
+
+
+ void clitk::ComposeVFGenericFilter::Update()
+ {
+ //Get the image Dimension and PixelType
+ int Dimension;
+ std::string PixelType;
+
+ clitk::ReadImageDimensionAndPixelType(m_InputName1, Dimension, PixelType);
+
+ if(Dimension==2) UpdateWithDim<2>(PixelType);
+ else if(Dimension==3) UpdateWithDim<3>(PixelType);
+ else
+ {
+ std::cout<<"Error, Only for 2 and 3 Dimensions!!!"<<std::endl ;
+ return;
+ }
+
+ }
+} //end namespace
+
+#endif
--- /dev/null
+/*=========================================================================
+ 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 __clitkComposeVFGenericFilter_h
+#define __clitkComposeVFGenericFilter_h
+#include "clitkImageCommon.h"
+#include "clitkImageCommon.h"
+#include "clitkComposeVFFilter.h"
+
+//itk include
+#include "itkLightObject.h"
+#include "itkImage.h"
+#include "itkVector.h"
+
+
+namespace clitk
+{
+
+ class ITK_EXPORT ComposeVFGenericFilter : public itk::LightObject
+
+ {
+ public:
+ typedef ComposeVFGenericFilter Self;
+ typedef itk::LightObject Superclass;
+ typedef itk::SmartPointer<Self> Pointer;
+ typedef itk::SmartPointer<const Self> ConstPointer;
+
+ /** Method for creation through the object factory. */
+ itkNewMacro(Self);
+
+ /** Run-time type information (and related methods) */
+ itkTypeMacro( ComposeVFGenericFilter, ImageToImageFilter );
+
+ //Set Methods (inline)
+ void SetInput1(const std::string m){m_InputName1=m;}
+ void SetInput2(const std::string m){m_InputName2=m;}
+ void SetOutput(const std::string m){m_OutputName=m;}
+ void SetVerbose(const bool m){m_Verbose=m;}
+
+
+ //Update
+ void Update( );
+
+ protected:
+
+ ComposeVFGenericFilter();
+ ~ComposeVFGenericFilter() {};
+
+ //Templated members
+ template<unsigned int Dimension> void UpdateWithDim(std::string PixelType);
+ template<unsigned int Dimension, class PixelType> void UpdateWithDimAndPixelType();
+
+ std::string m_InputName1;
+ std::string m_InputName2;
+ std::string m_OutputName;
+ bool m_Verbose;
+
+ };
+
+
+} // end namespace clitk
+#ifndef ITK_MANUAL_INSTANTIATION
+#include "clitkComposeVFGenericFilter.txx"
+#endif
+
+#endif // #define __clitkComposeVFGenericFilter_h
--- /dev/null
+/*=========================================================================
+ 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 __clitkComposeVFGenericFilter_txx
+#define __clitkComposeVFGenericFilter_txx
+#include "clitkComposeVFGenericFilter.h"
+
+
+namespace clitk
+{
+
+ template<unsigned int Dimension>
+ void ComposeVFGenericFilter::UpdateWithDim(std::string PixelType)
+ {
+ if (PixelType=="double")
+ {
+ UpdateWithDimAndPixelType<Dimension, double>();
+ }
+ else
+ {
+ UpdateWithDimAndPixelType<Dimension, float>();
+ }
+ }
+
+
+ template<unsigned int Dimension, class PixelType>
+ void ComposeVFGenericFilter::UpdateWithDimAndPixelType()
+ {
+
+ //Define the image type
+ typedef itk::Vector<PixelType, Dimension> DisplacementType;
+ typedef itk::Image<DisplacementType, Dimension> ImageType;
+
+ //Read the input1
+ typedef itk::ImageFileReader<ImageType> ImageReaderType;
+ typename ImageReaderType::Pointer reader1= ImageReaderType::New();
+ reader1->SetFileName(m_InputName1);
+ reader1->Update();
+ typename ImageType::Pointer input1 =reader1->GetOutput();
+
+ //Read the input2
+ typename ImageReaderType::Pointer reader2= ImageReaderType::New();
+ reader2->SetFileName(m_InputName2);
+ reader2->Update();
+ typename ImageType::Pointer input2=reader2->GetOutput();
+
+ //Create the ComposeVFFilter
+ typedef clitk::ComposeVFFilter<ImageType,ImageType> FilterType;
+ typename FilterType::Pointer filter =FilterType::New();
+ filter->SetInput1(input1);
+ filter->SetInput2(input2);
+ filter->SetVerbose(m_Verbose);
+ filter->Update();
+
+ //Write the output
+ typedef itk::ImageFileWriter<ImageType> WriterType;
+ typename WriterType::Pointer writer = WriterType::New();
+ writer->SetFileName(m_OutputName);
+ writer->SetInput(filter->GetOutput());
+ writer->Update();
+
+ }
+}
+
+#endif
--- /dev/null
+/*=========================================================================
+ 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 CLITKCONEBEAMPROJECTIMAGE_CXX
+#define CLITKCONEBEAMPROJECTIMAGE_CXX
+/**
+ =================================================
+ * @file clitkConeBeamProjectImage.cxx
+ * @author Jef Vandemeulebroucke <jefvdmb@gmail.com>
+ * @date 30 April 2008
+ *
+ * @brief "Project a 3D image using a Cone-Beam geometry"
+ =================================================*/
+
+// clitk include
+#include "clitkConeBeamProjectImage_ggo.h"
+#include "clitkConeBeamProjectImageGenericFilter.h"
+#include "clitkIO.h"
+#include "clitkImageCommon.h"
+#include "clitkTransformUtilities.h"
+
+int main(int argc, char * argv[]) {
+
+ // Init command line
+ GGO(clitkConeBeamProjectImage, args_info);
+ CLITK_INIT;
+
+ // Creation of a generic filter
+ clitk::ConeBeamProjectImageGenericFilter::Pointer genericFilter = clitk::ConeBeamProjectImageGenericFilter::New();
+
+ //Passing the arguments to the generic filter
+ genericFilter->SetArgsInfo(args_info);
+
+ // //Passing the arguments to the generic filter
+ // genericFilter->SetVerbose(args_info.verbose_flag);
+ // genericFilter->SetInput(args_info.input_arg);
+ // genericFilter->SetOutput(args_info.output_arg);
+ // //genericFilter->SetMask(args_info.mask_arg);
+
+ // //set the three components of the isocenter
+ // std::vector<double> iso(3);
+ // for (unsigned int i=0 ; i<3 ; i++) iso[i]=args_info.iso_arg[i];
+ // genericFilter->SetIsoCenter(iso);
+ // genericFilter->SetSourceToScreen(args_info.screen_arg);
+ // genericFilter->SetSourceToAxis(args_info.axis_arg);
+ // genericFilter->SetProjectionAngle(args_info.angle_arg);
+ // if (args_info.matrix_given) genericFilter->SetRigidTransformMatrix(clitk::ReadMatrix3D(args_info.matrix_arg));
+ // genericFilter->SetEdgePaddingValue(args_info.pad_arg);
+
+ //update
+ genericFilter->Update();
+
+ return 0;
+}
+
+#endif
+
+
--- /dev/null
+#File clitkConeBeamProjectImage.ggo
+Package "clitk"
+Version "Project a 3D image with cone-beam geometry"
+
+option "config" - "Config file" string no
+
+section "Run Time"
+
+option "verbose" v "Verbose" flag off
+option "threads" - "Number of threads to use (default=min(cores,8))" int no
+
+
+section "Input"
+
+option "input" i "Input grid filename" string yes
+option "output" o "Output grid filename" string yes
+option "mask" m "2D Mask in which the filter should be applied (not supported yet;-)" string no
+
+
+section "Projection Parameters"
+
+option "iso" - "The isocenter" double no multiple default="0.0"
+option "screen" - "Specify the source to screen distance in mm" double no default="1536.0"
+option "axis" - "Specify the source to axis distance in mm" double no default="1000.0"
+option "angle" - "Specify the projection angle" double no default="0.0"
+option "matrix" - "Rigid tranform prior to projection (4x4)" string no
+option "pad" - "Padding value" float no default="0.0"
+
+
+section "Output Image"
+
+option "like" - "Make output like this image" string no
+option "origin" - "Origin for the output image" double multiple no default="0.0"
+option "size" - "Size for the output image" int multiple no default="512"
+option "spacing" - "Spacing for the output image" double multiple no default="0.8"
+
+
--- /dev/null
+/*=========================================================================
+ 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 __clitkConeBeamProjectImageFilter_h
+#define __clitkConeBeamProjectImageFilter_h
+#include "clitkImageCommon.h"
+#include "clitkImageCommon.h"
+#include "clitkTransformUtilities.h"
+#include "clitkExtractImageFilter.h"
+#include "itkRayCastInterpolateImageFunctionWithOrigin.h"
+
+//ITK include
+#include "itkLightObject.h"
+#include "itkResampleImageFilter.h"
+#include "itkEuler3DTransform.h"
+#include "itkExtractImageFilter.h"
+#include "itkFlipImageFilter.h"
+
+namespace clitk
+{
+
+ template <class InputImageType, class OutputImageType >
+ class ITK_EXPORT ConeBeamProjectImageFilter : public itk::LightObject
+
+ {
+ public:
+
+ typedef ConeBeamProjectImageFilter Self;
+ typedef itk::LightObject Superclass;
+ typedef itk::SmartPointer<Self> Pointer;
+ typedef itk::SmartPointer<const Self> ConstPointer;
+
+ /** Method for creation through the object factory. */
+ itkNewMacro(Self);
+
+ /** Determine the image dimension. */
+ itkStaticConstMacro(InputImageDimension, unsigned int,
+ InputImageType::ImageDimension );
+
+ itkStaticConstMacro(OutputImageDimension, unsigned int,
+ OutputImageType::ImageDimension );
+
+
+ //========================================================================================
+ //Typedefs
+ typedef typename InputImageType::Pointer InputImagePointer;
+ typedef typename InputImageType::ConstPointer InputImageConstPointer;
+ typedef typename InputImageType::PixelType InputPixelType;
+ typedef typename InputImageType::SizeType InputSizeType;
+ typedef typename InputImageType::SpacingType InputSpacingType;
+ typedef typename InputImageType::DirectionType InputDirectionType;
+ typedef typename InputImageType::IndexType InputIndexType;
+ typedef typename InputImageType::PointType InputPointType;
+
+ typedef typename OutputImageType::Pointer OutputImagePointer;
+ typedef typename OutputImageType::ConstPointer OutputImageConstPointer;
+ typedef typename OutputImageType::PixelType OutputPixelType;
+ typedef typename OutputImageType::SizeType OutputSizeType;
+ typedef typename OutputImageType::SpacingType OutputSpacingType;
+ typedef typename OutputImageType::DirectionType OutputDirectionType;
+ typedef typename OutputImageType::IndexType OutputIndexType;
+ typedef typename OutputImageType::PointType OutputPointType;
+
+ typedef itk::Image<OutputPixelType, InputImageDimension> InternalImageType;
+
+ //Pipeline
+ typedef itk::Euler3DTransform <double> TransformType;
+ typedef itk::ResampleImageFilter<InputImageType, InternalImageType > ResampleImageFilterType;
+ typedef itk::RayCastInterpolateImageFunctionWithOrigin<InputImageType,double> InterpolatorType;
+ typedef clitk::ExtractImageFilter<InternalImageType, OutputImageType> ExtractImageFilterType;
+ typedef itk::FlipImageFilter<OutputImageType> FlipImageFilterType;
+ typedef itk::Matrix<double,4,4> MatrixType;
+
+ //========================================================================================
+ //Set Methods
+ //========================================================================================
+ // Run-time
+ void SetVerbose(const bool m){m_Verbose=m;}
+ void SetNumberOfThreads(const unsigned int v)
+ {
+ m_NumberOfThreadsIsGiven=true;
+ m_NumberOfThreads=v;
+ }
+
+ void SetInput(const InputImagePointer m) {m_Input=m;} //no reinitialize
+
+ //=================================================================================
+ //Geometry (reinitialize)
+ void SetIsoCenter( const InputPointType & i )
+ {
+ if( m_IsoCenter!=i)
+ {
+ m_IsoCenter=i;
+ m_IsInitialized=false;
+ }
+ }
+
+ void SetSourceToScreen(const double& s)
+ {
+ if( m_SourceToScreen!=s)
+ {
+ m_SourceToScreen=s;
+ m_IsInitialized=false;
+ }
+ }
+
+ void SetSourceToAxis( const double& s)
+ {
+ if( m_SourceToAxis!=s)
+ {
+ m_SourceToAxis=s;
+ m_IsInitialized=false;
+ }
+ }
+
+ void SetProjectionAngle( const double& s)
+ {
+ if( m_SourceToScreen!=s)
+ {
+ m_ProjectionAngle=s;
+ m_IsInitialized=false;
+ }
+ }
+
+ void SetRigidTransformMatrix(const MatrixType& m)
+ {
+ if(m_RigidTransformMatrix != m)
+ {
+ m_RigidTransformMatrix=m;
+ m_IsInitialized=false;
+ }
+ }
+
+ void SetEdgePaddingValue(const OutputPixelType& p)
+ {
+ if (m_EdgePaddingValue!=p)
+ {
+ m_EdgePaddingValue=p;
+ m_IsInitialized=false;
+ }
+ }
+
+
+ //========================================================================================
+ //Output image properties
+ /** Get the size of the output image. */
+ void SetOutputSize(const OutputSizeType& p)
+ {
+ if (m_OutputSize!=p)
+ {
+ m_OutputSize=p;
+ m_IsInitialized=false;
+ }
+ }
+
+ /** Set the output image spacing. */
+ void SetOutputSpacing(const OutputSpacingType& p)
+ {
+ if (m_OutputSpacing!=p)
+ {
+ m_OutputSpacing=p;
+ m_IsInitialized=false;
+ }
+ }
+
+ /** Set the output image origin. */
+ void SetOutputOrigin(const OutputPointType& p)
+ {
+ if (m_OutputOrigin!=p)
+ {
+ m_OutputOrigin=p;
+ m_IsInitialized=false;
+ }
+ }
+
+ /** Helper method to set the output parameters based on this image */
+ void SetOutputParametersFromImage( const OutputImagePointer image );
+
+ /** Helper method to set the output parameters based on this image */
+ void SetOutputParametersFromImage( const OutputImageConstPointer image );
+
+ //========================================================================================
+ //Update
+ void Initialize(void)throw (itk::ExceptionObject);
+ void Update(void);
+ OutputImagePointer GetOutput(void);
+
+ protected:
+ ConeBeamProjectImageFilter();
+ ~ConeBeamProjectImageFilter() {};
+
+ // Run time
+ bool m_Verbose;
+ bool m_NumberOfThreadsIsGiven;
+ unsigned int m_NumberOfThreads;
+ bool m_IsInitialized;
+ //std::string m_Mask;
+
+ // Data
+ InputImageConstPointer m_Input;
+ OutputImagePointer m_Output;
+
+ // Geometry
+ InputPointType m_IsoCenter;
+ double m_SourceToScreen;
+ double m_SourceToAxis;
+ double m_ProjectionAngle;
+ MatrixType m_RigidTransformMatrix;
+ OutputPixelType m_EdgePaddingValue;
+
+ // Pipe
+ TransformType::Pointer m_Transform;
+ typename ResampleImageFilterType::Pointer m_Resampler;
+ typename InterpolatorType::Pointer m_Interpolator;
+ typename ExtractImageFilterType::Pointer m_ExtractImageFilter;
+ typename FlipImageFilterType::Pointer m_FlipImageFilter;
+
+ // Output image info
+ OutputSizeType m_OutputSize; // Size of the output image
+ OutputSpacingType m_OutputSpacing; // output image spacing
+ OutputPointType m_OutputOrigin; // output image origin
+ };
+
+
+} // end namespace clitk
+#ifndef ITK_MANUAL_INSTANTIATION
+#include "clitkConeBeamProjectImageFilter.txx"
+#endif
+
+#endif // #define __clitkConeBeamProjectImageFilter_h
--- /dev/null
+/*=========================================================================
+ 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 __clitkConeBeamProjectImageFilter_txx
+#define __clitkConeBeamProjectImageFilter_txx
+namespace clitk
+{
+
+
+ //=========================================================================================================================
+ //Constructor
+ template <class InputImageType, class OutputImageType>
+ ConeBeamProjectImageFilter<InputImageType, OutputImageType>::
+ ConeBeamProjectImageFilter()
+ {
+ // Initialize with the default values (Elekta Synergie)
+ m_Verbose=false;
+ m_IsInitialized=false;
+ m_NumberOfThreadsIsGiven=false;
+
+ // Geometry
+ m_IsoCenter.Fill(0.0);
+ m_SourceToScreen=1536.;
+ m_SourceToAxis=1000.;
+ m_ProjectionAngle=0.;
+ m_RigidTransformMatrix.SetIdentity();
+ m_EdgePaddingValue=itk::NumericTraits<OutputPixelType>::Zero;//density images
+
+ // Pipe
+ m_Transform=TransformType::New();
+ m_Resampler=ResampleImageFilterType::New();
+ m_Interpolator= InterpolatorType::New();
+ m_ExtractImageFilter=ExtractImageFilterType::New();
+ m_FlipImageFilter=FlipImageFilterType::New();
+
+ // Parameters for output
+ this->m_OutputSpacing.Fill(0.8);
+ this->m_OutputOrigin.Fill(0.0);
+ this->m_OutputSize.Fill( 512 );
+
+ }
+
+
+ //-----------------------------------------------------------------------
+ // Set output info from image
+ //-----------------------------------------------------------------------
+ template <class InputImageType, class OutputImageType>
+ void
+ ConeBeamProjectImageFilter<InputImageType, OutputImageType>
+ ::SetOutputParametersFromImage ( OutputImagePointer image )
+ {
+ this->SetOutputOrigin( image->GetOrigin() );
+ this->SetOutputSpacing( image->GetSpacing() );
+ this->SetOutputSize( image->GetLargestPossibleRegion().GetSize() );
+ }
+
+
+ //-----------------------------------------------------------------------
+ // Set output info from image
+ //-----------------------------------------------------------------------
+ template <class InputImageType, class OutputImageType>
+ void
+ ConeBeamProjectImageFilter<InputImageType, OutputImageType>
+ ::SetOutputParametersFromImage ( OutputImageConstPointer image )
+ {
+ this->SetOutputOrigin( image->GetOrigin() );
+ this->SetOutputSpacing( image->GetSpacing() );
+ this->SetOutputSize( image->GetLargestPossibleRegion().GetSize() );
+ }
+
+
+ //=========================================================================================================================
+ // Initialize
+ template <class InputImageType, class OutputImageType>
+ void
+ ConeBeamProjectImageFilter<InputImageType, OutputImageType>
+ ::Initialize(void) throw (itk::ExceptionObject)
+ {
+
+ //====================================================================
+ // Define the transform: composition of rigid transfo around origin and a centered rotation
+ // The center of rotation should be placed at the isocenter!
+
+ if (m_Verbose) std::cout<<"The isocenter is at "<< m_IsoCenter <<"..." <<std::endl;
+
+ // Get the rotation parameter array
+ itk::Array<double> rotationParameters(3);
+ const double dtr = ( atan(1.0) * 4.0 ) / 180.0; //constant for converting degrees into radians
+ if (m_Verbose)std::cout<<"The projection angle is "<< m_ProjectionAngle <<"° (0° being lateral left)..."<< std::endl;
+ rotationParameters[0]= 0.;
+ rotationParameters[1]= 0.;
+ rotationParameters[2]= -dtr*(double) m_ProjectionAngle;
+
+ // We first perform rigid transform (of source and panel), then a centered rotation around the transformed center
+ itk::Matrix<double,3,3> rigidRotation = GetRotationalPartMatrix3D(m_RigidTransformMatrix);
+ itk::Vector<double,3> rigidTranslation = GetTranslationPartMatrix3D(m_RigidTransformMatrix);
+ typename InputImageType::PointType transformedCenter = rigidRotation * m_IsoCenter + rigidTranslation;
+
+ // Calculate the centered rotation matrix
+ itk::Matrix<double,4,4> centeredRotationMatrix = GetCenteredRotationMatrix3D(rotationParameters,transformedCenter);
+
+ // Compose this rotation with the rigid transform matrix
+ itk::Matrix<double,4,4> finalTransform = centeredRotationMatrix * m_RigidTransformMatrix;
+
+ // Set the rotation
+ itk::Matrix<double,3,3> finalRotation = GetRotationalPartMatrix3D(finalTransform);
+ m_Transform->SetMatrix(finalRotation);
+ if (m_Verbose)std::cout<<"The final rotation is "<<finalRotation<<"..."<<std::endl;
+
+ // Set the translation
+ itk::Vector<double,3> finalTranslation = GetTranslationPartMatrix3D(finalTransform);
+ m_Transform->SetTranslation(finalTranslation);
+ if (m_Verbose)std::cout<<"The final translation is "<<finalTranslation<<"..."<<std::endl;
+
+
+ //====================================================================
+ //Define a resample filter for the projection
+ if (m_NumberOfThreadsIsGiven) m_Resampler->SetNumberOfThreads(m_NumberOfThreads);
+ m_Resampler->SetDefaultPixelValue(m_EdgePaddingValue);
+ if (m_Verbose)std::cout<<"The edge padding value is "<<m_EdgePaddingValue<<"..."<<std::endl;
+
+ //JV Original raycast does not take into account origin, but does implicit shift to center of volume
+ //JV patched in RayCastInterpolateImageFunctionWithOrigin
+ m_Interpolator->SetTransform(m_Transform);
+ m_Interpolator->SetThreshold(0.);
+
+ // Focalpoint: we presume that for an angle of 0° the kV is lateral left (for the patient on his back), or on the positive X-axis.
+ typename InterpolatorType::InputPointType focalpoint;
+ focalpoint[0]= m_IsoCenter[0] + m_SourceToAxis;
+ focalpoint[1]= m_IsoCenter[1];
+ focalpoint[2]= m_IsoCenter[2];
+ m_Interpolator->SetFocalPoint(focalpoint);
+ if (m_Verbose)std::cout<<"The focalpoint is at "<< focalpoint <<"..."<< std::endl;
+
+ // Connect the interpolator and the transform with the m_Resampler
+ m_Resampler->SetInterpolator( m_Interpolator );
+ m_Resampler->SetTransform( m_Transform );
+
+ // Describe the output projection image
+ typename InputImageType::SizeType sizeOuput;
+ sizeOuput[0] = 1; // number of pixels along X of the 2D DRR image
+ sizeOuput[1] = m_OutputSize[0]; // number of pixels along Y of the 2D DRR image
+ sizeOuput[2] = m_OutputSize[1]; // number of pixels along Z of the 2D DRR image
+ m_Resampler->SetSize( sizeOuput );
+ if (m_Verbose)std::cout<<"The output size is "<< m_OutputSize <<"..."<< std::endl;
+
+ typename InputImageType::SpacingType spacingOutput;
+ spacingOutput[0] = 1; // pixel spacing along X of the 2D DRR image [mm]
+ spacingOutput[1] = m_OutputSpacing[0]; // pixel spacing along Y of the 2D DRR image [mm]
+ spacingOutput[2] = m_OutputSpacing[1]; // pixel spacing along Y of the 2D DRR image [mm]
+ m_Resampler->SetOutputSpacing( spacingOutput );
+ if (m_Verbose)std::cout<<"The output size is "<< m_OutputSpacing <<"..."<< std::endl;
+
+ // The position of the DRR is specified, we presume that for an angle of 0° the flatpanel is located at the negative x-axis
+ // JV -1 seems to correspond better with shearwarp of Simon Rit
+ typename InterpolatorType::InputPointType originOutput;
+ originOutput[0] = m_IsoCenter[0]- (m_SourceToScreen - m_SourceToAxis);
+ originOutput[1] = m_IsoCenter[1]-static_cast<double>(sizeOuput[1]-1)*spacingOutput[1]/2.0;
+ originOutput[2] = m_IsoCenter[2]-static_cast<double>(sizeOuput[2]-1)*spacingOutput[2]/2.0;
+ m_Resampler->SetOutputOrigin( originOutput );
+ if (m_Verbose)std::cout<<"The origin of the flat panel is at "<< originOutput <<",..."<< std::endl;
+
+ // We define the region to be extracted. Projection was in the YZ plane, X should be set to zero
+ typename InternalImageType::RegionType::SizeType sizeTemp=sizeOuput;
+ sizeTemp[0]=0;
+ typename InternalImageType::IndexType startTemp; //=temp->GetLargestPossibleRegion().GetIndex();
+ startTemp.Fill(0);
+
+ typename InternalImageType::RegionType desiredRegion;
+ desiredRegion.SetSize( sizeTemp );
+ desiredRegion.SetIndex( startTemp );
+ m_ExtractImageFilter->SetExtractionRegion( desiredRegion );
+
+ // Prepare the Flip Image filter
+ typename FlipImageFilterType::FlipAxesArrayType flipArray;
+ flipArray[0] = 0;
+ flipArray[1] = 1;
+ m_FlipImageFilter->SetFlipAxes( flipArray );
+
+ // Initialization complete
+ m_IsInitialized=true;
+
+ }
+
+ //=========================================================================================================================
+ // Update
+ template <class InputImageType, class OutputImageType>
+ void
+ ConeBeamProjectImageFilter<InputImageType, OutputImageType>
+ ::Update(void)
+ {
+
+ //==================================================================
+ // If geometry changed reinitialize
+ if (! m_IsInitialized) this->Initialize();
+
+ // Input
+ m_Resampler->SetInput( m_Input );
+
+ //==================================================================
+ // Execute the filter
+ if (m_Verbose)std::cout<<"Starting the projection..."<<std::endl;
+ try {
+ m_Resampler->Update();
+ }
+ catch( itk::ExceptionObject & err )
+ {
+ std::cerr << "ExceptionObject caught! Projection failed!" << std::endl;
+ std::cerr << err << std::endl;
+ }
+
+ //==================================================================
+ // Make a 2D image out of it
+ typename InternalImageType::Pointer temp=m_Resampler->GetOutput();
+ m_ExtractImageFilter->SetInput(temp);
+
+ // We should flip the Y axis
+ m_FlipImageFilter->SetInput(m_ExtractImageFilter->GetOutput());
+ m_FlipImageFilter->Update();
+
+ // Get output
+ m_Output= m_FlipImageFilter->GetOutput();
+ m_Output->Update();
+ m_Output->SetOrigin(m_OutputOrigin);
+ }
+
+ //=========================================================================================================================
+ // GetOutput
+ template <class InputImageType, class OutputImageType>
+ typename OutputImageType::Pointer
+ ConeBeamProjectImageFilter<InputImageType, OutputImageType>
+ ::GetOutput(void)
+ {
+ //JV it is not safe to repeatedly call getoutput/ always call Update first
+ return m_Output;
+ }
+
+}
+
+
+#endif
--- /dev/null
+/*=========================================================================
+ 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 CLITKCONEBEAMPROJECTIMAGEGENERICFILTER_CXX
+#define CLITKCONEBEAMPROJECTIMAGEGENERICFILTER_CXX
+
+/**
+ * @file clitkConeBeamProjectImageGenericFilter.cxx
+ * @author Jef Vandemeulebroucke <jef@creatis.insa-lyon.fr>
+ * @date Wed April 30 13:47:57 2008
+ *
+ * @brief
+ *
+ *
+ */
+
+#include "clitkConeBeamProjectImageGenericFilter.h"
+
+namespace clitk
+{
+
+ //====================================================================
+ // Constructor
+ ConeBeamProjectImageGenericFilter::ConeBeamProjectImageGenericFilter()
+ {
+
+ m_Verbose=false;
+ m_InputFileName="";
+
+// mIsoCenter.resize(3);
+// for (unsigned int j=0; j < 3; j++) mIsoCenter[j]=128.;
+// mSourceToScreen=1536.;
+// mSourceToAxis=1000.;
+// mProjectionAngle=0.;
+
+// // set the rigid transform matrix to the identity
+// for (unsigned int i=0; i <4; i++)
+// for (unsigned int j=0; j <4; j++)
+// if (i==j)mRigidTransformMatrix[i][j]=1.;
+// else mRigidTransformMatrix[i][j]=0.;
+
+// //Padding value
+// mEdgePaddingValue=0.0;
+ }
+
+ //====================================================================
+ // Update
+ void ConeBeamProjectImageGenericFilter::Update()
+ {
+ //Read the PixelType and dimension of the input image
+ int Dimension;
+ std::string PixelType;
+ clitk::ReadImageDimensionAndPixelType(m_InputFileName, Dimension, PixelType);
+ if (Dimension == 3)
+ {
+ if (m_Verbose) std::cout << "Input was detected to be "<< Dimension << "D and " << PixelType << "..." << std::endl;
+
+ if(PixelType == "short"){
+ if (m_Verbose) std::cout << "Launching Projection in signed short..." << std::endl;
+ UpdateWithPixelType<signed short>();
+ }
+
+// else if(PixelType == "unsigned_short"){
+// if (m_Verbose) std::cout << "Launching Projection in unsigned_short..." << std::endl;
+// UpdateWithPixelType<unsigned short>();
+// }
+
+ else if (PixelType == "unsigned_char"){
+ if (m_Verbose) std::cout << "Launching Projection in unsigned_char..." << std::endl;
+ UpdateWithPixelType<unsigned char>();
+ }
+
+// else if (PixelType == "char"){
+// if (m_Verbose) std::cout << "Launching Projection in signed_char..." << std::endl;
+// UpdateWithPixelType<signed char>();
+// }
+ else {
+ if (m_Verbose) std::cout << "Launching Projection in float..." << std::endl;
+ UpdateWithPixelType<float>();
+ }
+ }
+
+ else {itkExceptionMacro(<< "Input Image dimension is " << Dimension
+ << " but I can only work on 3D images.");
+ }
+ }
+
+
+ //====================================================================
+
+}
+#endif //#define CLITKCONEBEAMPROJECTIMAGEGENERICFILTER_CXX
--- /dev/null
+/*=========================================================================
+ 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 CLITKCONEBEAMPROJECTIMAGEGENERICFILTER__H
+#define CLITKCONEBEAMPROJECTIMAGEGENERICFILTER__H
+/**
+ =================================================
+ * @file clitkConeBeamProjectImageGenericFilter.h
+ * @author Jef Vandemeulebroucke <jef@creatis.insa-lyon.fr>
+ * @date 30 April 2008
+ *
+ * @brief Project a 3D image using a ConeBeam geometry
+ *
+ =================================================*/
+
+// clitk include
+#include "clitkIO.h"
+#include "clitkImageCommon.h"
+#include "clitkImageCommon.h"
+#include "clitkConeBeamProjectImageFilter.h"
+#include "clitkConeBeamProjectImage_ggo.h"
+
+// itk include
+#include "itkLightObject.h"
+
+
+namespace clitk {
+
+ //====================================================================
+ class ConeBeamProjectImageGenericFilter: public itk::LightObject
+ {
+ public:
+
+ //Typedefs ITK================================================
+ typedef ConeBeamProjectImageGenericFilter Self;
+ typedef itk::LightObject Superclass;
+ typedef itk::SmartPointer<Self> Pointer;
+ typedef itk::SmartPointer<const Self> ConstPointer;
+
+ //ITK Method for object creation================================================
+ itkNewMacro(Self);
+
+
+ //====================================================================
+ // Set methods
+ void SetArgsInfo(const args_info_clitkConeBeamProjectImage a)
+ {
+ m_ArgsInfo=a;
+ m_InputFileName=m_ArgsInfo.input_arg;
+ m_Verbose=m_ArgsInfo.verbose_flag;
+ }
+
+ // void SetVerbose(const bool v){mVerbose=v;}
+ // void SetInput(const std::string i) { mInput = i; }
+ // void SetOutput(const std::string o) { mOutput = o; }
+ // void SetMask(const std::string m) {mMask = m;}
+ // void SetIsoCenter(const std::vector<double> i)
+ // {
+ // mIsoCenter.resize(3);
+ // for (unsigned int j=0; j < 3; j++) mIsoCenter[j]=i[j];
+ // }
+ // void SetSourceToScreen(const double s) {mSourceToScreen = s;}
+ // void SetSourceToAxis(const double s) {mSourceToAxis = s;}
+ // void SetProjectionAngle(const double a) {mProjectionAngle = a;}
+ // void SetRigidTransformMatrix(const itk::Matrix<double,4,4> m) {mRigidTransformMatrix=m;}
+ // void SetEdgePaddingValue(const double m) {mEdgePaddingValue=m;}
+
+ //====================================================================
+ // Update
+ virtual void Update();
+
+ protected:
+ const char * GetNameOfClass() const { return "ConeBeamProjectImageGenericFilter"; }
+
+ //====================================================================
+ // Constructor & Destructor
+ ConeBeamProjectImageGenericFilter();
+ ~ConeBeamProjectImageGenericFilter(){;}
+
+ //====================================================================
+ //Protected member functions
+ template <class PixelType> void UpdateWithPixelType();
+
+ bool m_Verbose;
+ std::string m_InputFileName;
+ args_info_clitkConeBeamProjectImage m_ArgsInfo;
+ // std::string mOutput;
+ // std::string mMask;
+ // std::vector<double> mIsoCenter;
+ // double mSourceToScreen;
+ // double mSourceToAxis;
+ // double mProjectionAngle;
+ // itk::Matrix<double,4,4> mRigidTransformMatrix;
+ // double mEdgePaddingValue;
+
+ };
+
+} // end namespace clitk
+#ifndef ITK_MANUAL_INSTANTIATION
+#include "clitkConeBeamProjectImageGenericFilter.txx"
+#endif
+
+#endif //#define CLITKCONEBEAMPROJECTIMAGEGENERICFILTER__H
--- /dev/null
+/*=========================================================================
+ 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 CLITKCONEBEAMPROJECTIMAGEGENERICFILTER_TXX
+#define CLITKCONEBEAMPROJECTIMAGEGENERICFILTER_TXX
+/**
+ =================================================
+ * @file clitkConeBeamProjectImageGenericFilter.txx
+ * @author Jef Vandemeulebroucke <jef@creatis.insa-lyon.fr>
+ * @date 30 April 2008
+ *
+ * @brief Project a 3D image using a cone-beam geometry
+ *
+ =================================================*/
+
+
+namespace clitk
+{
+
+ //================================================================================
+ template <class PixelType> void ConeBeamProjectImageGenericFilter::UpdateWithPixelType()
+ {
+
+ //===================================================================
+ // Read the input image
+ const unsigned int InputImageDimension=3;
+ typedef itk::Image<PixelType, InputImageDimension> InputImageType;
+ typedef itk::ImageFileReader<InputImageType> ImageReaderType;
+ typename ImageReaderType::Pointer reader = ImageReaderType::New();
+ reader->SetFileName(m_InputFileName);
+ reader->Update();
+ typename InputImageType::Pointer input = reader->GetOutput();
+
+ // Define the output type
+ //JV always float?
+ typedef float OutputPixelType;
+ const unsigned int OutputImageDimension=2;
+ typedef itk::Image<OutputPixelType, OutputImageDimension> OutputImageType;
+
+ // Create the ConeBeamProjectImageFilter
+ typedef clitk::ConeBeamProjectImageFilter<InputImageType, OutputImageType> ConeBeamProjectImageFilterType;
+ typename ConeBeamProjectImageFilterType::Pointer filter=ConeBeamProjectImageFilterType::New();
+
+ // Pass all the necessary parameters
+ filter->SetInput(input);
+ filter->SetVerbose(m_Verbose);
+ if (m_ArgsInfo.threads_given) filter->SetNumberOfThreads(m_ArgsInfo.threads_arg);
+
+ // Projection parameters
+ typename InputImageType::PointType iso;
+ unsigned int i;
+ if (m_ArgsInfo.iso_given)
+ for(i=0;i<InputImageDimension;i++)
+ {
+ iso[i]=m_ArgsInfo.iso_arg[i];
+ filter->SetIsoCenter(iso);
+ }
+ filter->SetSourceToScreen(m_ArgsInfo.screen_arg);
+ filter->SetSourceToAxis(m_ArgsInfo.axis_arg);
+ filter->SetProjectionAngle(m_ArgsInfo.angle_arg);
+ if (m_ArgsInfo.matrix_given)
+ {
+ itk::Matrix<double,4,4> rt =ReadMatrix3D(m_ArgsInfo.matrix_arg);
+ filter->SetRigidTransformMatrix(rt);
+ }
+ filter->SetEdgePaddingValue(static_cast<OutputPixelType>(m_ArgsInfo.pad_arg));
+
+ // Output image info
+ if (m_ArgsInfo.like_given)
+ {
+ typedef itk::ImageFileReader<OutputImageType> ReaderType;
+ ReaderType::Pointer reader2=ReaderType::New();
+ reader2->SetFileName(m_ArgsInfo.like_arg);
+ reader2->Update();
+
+ OutputImageType::Pointer image=reader2->GetOutput();
+ filter->SetOutputParametersFromImage(image);
+ }
+ else
+ {
+ if (m_ArgsInfo.origin_given)
+ {
+ OutputImageType::PointType origin;
+ for(i=0;i<OutputImageDimension;i++)
+ origin[i]=m_ArgsInfo.origin_arg[i];
+ filter->SetOutputOrigin(origin);
+ }
+ if (m_ArgsInfo.spacing_given)
+ {
+ OutputImageType::SpacingType spacing;
+ for(i=0;i<OutputImageDimension;i++)
+ spacing[i]=m_ArgsInfo.spacing_arg[i];
+ filter->SetOutputSpacing(spacing);
+ }
+ if (m_ArgsInfo.size_given)
+ {
+ OutputImageType::SizeType size;
+ for(i=0;i<OutputImageDimension;i++)
+ size[i]=m_ArgsInfo.size_arg[i];
+ filter->SetOutputSize(size);
+ }
+ }
+
+ //Go
+ filter->Update();
+
+ //Get the output
+ OutputImageType::Pointer output=filter->GetOutput();
+
+ //Write the output
+ typedef itk::ImageFileWriter<OutputImageType> OutputWriterType;
+ OutputWriterType::Pointer outputWriter = OutputWriterType::New();
+ outputWriter->SetInput(output);
+ outputWriter->SetFileName(m_ArgsInfo.output_arg);
+ if (m_Verbose)std::cout<<"Writing projected image..."<<std::endl;
+ outputWriter->Update();
+ }
+
+}
+
+#endif //#define CLITKGENERICIMAGEFILTER
--- /dev/null
+/*=========================================================================
+ 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 clitkCropImage.cxx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+// clitk
+#include "clitkCropImage_ggo.h"
+#include "clitkIO.h"
+#include "clitkCropImageGenericFilter.h"
+
+
+//--------------------------------------------------------------------
+int main(int argc, char * argv[]) {
+
+ // Init command line
+ GGO(clitkCropImage, args_info);
+ CLITK_INIT;
+
+ // Filter
+ clitk::CropImageGenericFilter::Pointer genericFilter=clitk::CropImageGenericFilter::New();
+
+ genericFilter->SetArgsInfo(args_info);
+ genericFilter->Update();
+
+ return EXIT_SUCCESS;
+}// end main
+
+//--------------------------------------------------------------------
--- /dev/null
+#File clitkCropImage.ggo
+Package "clitkCropImage"
+version "1.0"
+purpose "Reduce the image size by removing regions at the lower and upper end."
+
+option "config" - "Config file" string no
+option "verbose" v "Verbose" flag off
+
+option "input" i "Input image filename" string yes
+option "output" o "Output image filename" string yes
+option "boundingBox" b "Bounding box of the crop region" int no multiple
+option "lower" l "Size of the lower crop region" int no multiple
+option "upper" u "Size of the upper crop region" int no multiple
+option "origin" - "Set new origin to zero" flag off
--- /dev/null
+/*=========================================================================
+ 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 clitkCropImageGenericFilter_cxx
+#define clitkCropImageGenericFilter_cxx
+
+/* =================================================
+ * @file clitkCropImageGenericFilter.cxx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+#include "clitkCropImageGenericFilter.h"
+
+
+namespace clitk
+{
+
+
+ //-----------------------------------------------------------
+ // Constructor
+ //-----------------------------------------------------------
+ CropImageGenericFilter::CropImageGenericFilter()
+ {
+ m_Verbose=false;
+ m_InputFileName="";
+ }
+
+
+ //-----------------------------------------------------------
+ // Update
+ //-----------------------------------------------------------
+ void CropImageGenericFilter::Update()
+ {
+ // Read the Dimension and PixelType
+ int Dimension, Components;
+ std::string PixelType;
+ ReadImageDimensionAndPixelType(m_InputFileName, Dimension, PixelType, Components);
+
+
+ // Call UpdateWithDim
+ if(Dimension==2) UpdateWithDim<2>(PixelType, Components);
+ else if(Dimension==3) UpdateWithDim<3>(PixelType, Components);
+ else if (Dimension==4)UpdateWithDim<4>(PixelType, Components);
+ else
+ {
+ std::cout<<"Error, Only for 2, 3 or 4 Dimensions!!!"<<std::endl ;
+ return;
+ }
+ }
+
+
+} //end clitk
+
+#endif //#define clitkCropImageGenericFilter_cxx
--- /dev/null
+/*=========================================================================
+ 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 clitkCropImageGenericFilter_h
+#define clitkCropImageGenericFilter_h
+
+/* =================================================
+ * @file clitkCropImageGenericFilter.h
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+// clitk include
+#include "clitkIO.h"
+#include "clitkCommon.h"
+#include "clitkImageCommon.h"
+#include "clitkCropImage_ggo.h"
+
+//itk include
+#include "itkLightObject.h"
+#include "itkCropImageFilter.h"
+
+namespace clitk
+{
+
+
+ class ITK_EXPORT CropImageGenericFilter : public itk::LightObject
+ {
+ public:
+ //----------------------------------------
+ // ITK
+ //----------------------------------------
+ typedef CropImageGenericFilter Self;
+ typedef itk::LightObject Superclass;
+ typedef itk::SmartPointer<Self> Pointer;
+ typedef itk::SmartPointer<const Self> ConstPointer;
+
+ // Method for creation through the object factory
+ itkNewMacro(Self);
+
+ // Run-time type information (and related methods)
+ itkTypeMacro( CropImageGenericFilter, LightObject );
+
+
+ //----------------------------------------
+ // Typedefs
+ //----------------------------------------
+
+
+ //----------------------------------------
+ // Set & Get
+ //----------------------------------------
+ void SetArgsInfo(const args_info_clitkCropImage & a)
+ {
+ m_ArgsInfo=a;
+ m_Verbose=m_ArgsInfo.verbose_flag;
+ m_InputFileName=m_ArgsInfo.input_arg;
+ }
+
+
+ //----------------------------------------
+ // Update
+ //----------------------------------------
+ void Update();
+
+ protected:
+
+ //----------------------------------------
+ // Constructor & Destructor
+ //----------------------------------------
+ CropImageGenericFilter();
+ ~CropImageGenericFilter() {};
+
+
+ //----------------------------------------
+ // Templated members
+ //----------------------------------------
+ template <unsigned int Dimension> void UpdateWithDim(std::string PixelType, unsigned int Components);
+ template <unsigned int Dimension, class PixelType> void UpdateWithDimAndPixelType();
+
+
+ //----------------------------------------
+ // Data members
+ //----------------------------------------
+ args_info_clitkCropImage m_ArgsInfo;
+ bool m_Verbose;
+ std::string m_InputFileName;
+
+ };
+
+
+} // end namespace clitk
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#include "clitkCropImageGenericFilter.txx"
+#endif
+
+#endif // #define clitkCropImageGenericFilter_h
--- /dev/null
+/*=========================================================================
+ 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 clitkCropImageGenericFilter_txx
+#define clitkCropImageGenericFilter_txx
+
+/* =================================================
+ * @file clitkCropImageGenericFilter.txx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+namespace clitk
+{
+
+ //-------------------------------------------------------------------
+ // Update with the number of dimensions
+ //-------------------------------------------------------------------
+ template<unsigned int Dimension>
+ void
+ CropImageGenericFilter::UpdateWithDim(std::string PixelType, unsigned int Components)
+ {
+ if (m_Verbose) std::cout << "Image was detected to be "<<Dimension<<"D and "<<Components<<" component(s) of "<< PixelType<<"..."<<std::endl;
+
+ if (Components==1)
+ {
+ if(PixelType == "short"){
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed short..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, signed short>();
+ }
+ // else if(PixelType == "unsigned_short"){
+ // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_short..." << std::endl;
+ // UpdateWithDimAndPixelType<Dimension, unsigned short>();
+ // }
+
+ else if (PixelType == "unsigned_char"){
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_char..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, unsigned char>();
+ }
+
+ // else if (PixelType == "char"){
+ // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed_char..." << std::endl;
+ // UpdateWithDimAndPixelType<Dimension, signed char>();
+ // }
+ else {
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and float..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, float>();
+ }
+ }
+
+ else if (Components==3)
+ {
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and 3D float (DVF)" << std::endl;
+ UpdateWithDimAndPixelType<Dimension, itk::Vector<float, 3> >();
+ }
+
+ else std::cerr<<"Number of components is "<<Components<<", not supported!"<<std::endl;
+ }
+
+
+ //-------------------------------------------------------------------
+ // Update with the number of dimensions and the pixeltype
+ //-------------------------------------------------------------------
+ template <unsigned int Dimension, class PixelType>
+ void
+ CropImageGenericFilter::UpdateWithDimAndPixelType()
+ {
+
+ // ImageTypes
+ typedef itk::Image<PixelType, Dimension> InputImageType;
+ typedef itk::Image<PixelType, Dimension> OutputImageType;
+
+ // Read the input
+ typedef itk::ImageFileReader<InputImageType> InputReaderType;
+ typename InputReaderType::Pointer reader = InputReaderType::New();
+ reader->SetFileName( m_InputFileName);
+ reader->Update( );
+ typename InputImageType::Pointer input= reader->GetOutput();
+
+ // Filter
+ typedef itk::CropImageFilter<InputImageType, OutputImageType> CropImageFilterType;
+ typename CropImageFilterType::Pointer cropFilter=CropImageFilterType::New();
+ cropFilter->SetInput(input);
+ typename InputImageType::SizeType lSize, uSize;
+
+ if (m_ArgsInfo.boundingBox_given)
+ {
+ for(unsigned int i=0;i<Dimension;i++)
+ {
+ lSize[i]=m_ArgsInfo.boundingBox_arg[2*i];
+ uSize[i]=input->GetLargestPossibleRegion().GetSize()[i]-m_ArgsInfo.boundingBox_arg[2*i+1]-1;
+ }
+ }
+ else
+ {
+
+ if (m_ArgsInfo.lower_given)
+ for(unsigned int i=0;i<Dimension;i++)
+ lSize[i]=static_cast<unsigned int >(m_ArgsInfo.lower_arg[i]);
+ else lSize.Fill(0);
+
+ if (m_ArgsInfo.upper_given)
+ for(unsigned int i=0;i<Dimension;i++)
+ uSize[i]=static_cast<unsigned int >(m_ArgsInfo.upper_arg[i]);
+ else uSize.Fill(0);
+ }
+
+ cropFilter->SetLowerBoundaryCropSize(lSize);
+ cropFilter->SetUpperBoundaryCropSize(uSize);
+ cropFilter->Update();
+ typename OutputImageType::Pointer output= cropFilter->GetOutput();
+
+ // Origin?
+ typename OutputImageType::PointType origin;
+ origin.Fill(itk::NumericTraits<double>::Zero);
+ if (m_ArgsInfo.origin_flag)
+ {
+ output->SetOrigin(origin);
+ output->Update();
+ if (m_Verbose) std::cout<<"Setting origin to "<< origin<<"..."<<std::endl;
+ }
+
+ // Output
+ typedef itk::ImageFileWriter<OutputImageType> WriterType;
+ typename WriterType::Pointer writer = WriterType::New();
+ writer->SetFileName(m_ArgsInfo.output_arg);
+ writer->SetInput(output);
+ writer->Update();
+ }
+
+
+}//end clitk
+
+#endif //#define clitkCropImageGenericFilter_txx
--- /dev/null
+/*=========================================================================
+ 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 clitkExtractSlice.cxx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+// clitk
+#include "clitkExtractSlice_ggo.h"
+#include "clitkIO.h"
+#include "clitkExtractSliceGenericFilter.h"
+
+
+//--------------------------------------------------------------------
+int main(int argc, char * argv[]) {
+
+ // Init command line
+ GGO(clitkExtractSlice,args_info);
+ CLITK_INIT;
+
+ // Filter
+ clitk::ExtractSliceGenericFilter::Pointer genericFilter=clitk::ExtractSliceGenericFilter::New();
+
+ genericFilter->SetArgsInfo(args_info);
+ genericFilter->Update();
+
+ return EXIT_SUCCESS;
+}// end main
+
+//--------------------------------------------------------------------
--- /dev/null
+#File clitkExtractSlice.ggo
+Package "clitkExtractSlice"
+version "1.0"
+purpose "Extract a slice: will collapse the dimension given by axe, retaining only the index given by slice."
+
+option "config" - "Config file" string no
+option "verbose" v "Verbose" flag off
+
+option "input" i "Input image filename" string yes
+option "output" o "Output image filename" string yes
+option "axe" a "Axe (0,1, ...)" int no default="0"
+option "slice" s "Slice index (0,1,....)" int no default="0"
+
--- /dev/null
+/*=========================================================================
+ 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 clitkExtractSliceGenericFilter_cxx
+#define clitkExtractSliceGenericFilter_cxx
+
+/* =================================================
+ * @file clitkExtractSliceGenericFilter.cxx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+#include "clitkExtractSliceGenericFilter.h"
+
+
+namespace clitk
+{
+
+
+ //-----------------------------------------------------------
+ // Constructor
+ //-----------------------------------------------------------
+ ExtractSliceGenericFilter::ExtractSliceGenericFilter()
+ {
+ m_Verbose=false;
+ m_InputFileName="";
+ }
+
+
+ //-----------------------------------------------------------
+ // Update
+ //-----------------------------------------------------------
+ void ExtractSliceGenericFilter::Update()
+ {
+ // Read the Dimension and PixelType
+ int Dimension;
+ std::string PixelType;
+ ReadImageDimensionAndPixelType(m_InputFileName, Dimension, PixelType);
+
+
+ // Call UpdateWithDim
+ if(Dimension==2) UpdateWithDim<2>(PixelType);
+ else if(Dimension==3) UpdateWithDim<3>(PixelType);
+ // else if (Dimension==4)UpdateWithDim<4>(PixelType);
+ else
+ {
+ std::cout<<"Error, Only for 2 or 3 Dimensions!!!"<<std::endl ;
+ return;
+ }
+ }
+
+
+} //end clitk
+
+#endif //#define clitkExtractSliceGenericFilter_cxx
--- /dev/null
+/*=========================================================================
+ 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 clitkExtractSliceGenericFilter_h
+#define clitkExtractSliceGenericFilter_h
+
+/* =================================================
+ * @file clitkExtractSliceGenericFilter.h
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+// clitk include
+#include "clitkIO.h"
+#include "clitkCommon.h"
+#include "clitkExtractImageFilter.h"
+#include "clitkExtractSlice_ggo.h"
+
+//itk include
+#include "itkLightObject.h"
+
+namespace clitk
+{
+
+
+ class ITK_EXPORT ExtractSliceGenericFilter : public itk::LightObject
+ {
+ public:
+ //----------------------------------------
+ // ITK
+ //----------------------------------------
+ typedef ExtractSliceGenericFilter Self;
+ typedef itk::LightObject Superclass;
+ typedef itk::SmartPointer<Self> Pointer;
+ typedef itk::SmartPointer<const Self> ConstPointer;
+
+ // Method for creation through the object factory
+ itkNewMacro(Self);
+
+ // Run-time type information (and related methods)
+ itkTypeMacro( ExtractSliceGenericFilter, LightObject );
+
+
+ //----------------------------------------
+ // Typedefs
+ //----------------------------------------
+
+
+ //----------------------------------------
+ // Set & Get
+ //----------------------------------------
+ void SetArgsInfo(const args_info_clitkExtractSlice & a)
+ {
+ m_ArgsInfo=a;
+ m_Verbose=m_ArgsInfo.verbose_flag;
+ m_InputFileName=m_ArgsInfo.input_arg;
+ }
+
+
+ //----------------------------------------
+ // Update
+ //----------------------------------------
+ void Update();
+
+ protected:
+
+ //----------------------------------------
+ // Constructor & Destructor
+ //----------------------------------------
+ ExtractSliceGenericFilter();
+ ~ExtractSliceGenericFilter() {};
+
+
+ //----------------------------------------
+ // Templated members
+ //----------------------------------------
+ template <unsigned int Dimension> void UpdateWithDim(std::string PixelType);
+ template <unsigned int Dimension, class PixelType> void UpdateWithDimAndPixelType();
+
+
+ //----------------------------------------
+ // Data members
+ //----------------------------------------
+ args_info_clitkExtractSlice m_ArgsInfo;
+ bool m_Verbose;
+ std::string m_InputFileName;
+
+ };
+
+
+} // end namespace clitk
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#include "clitkExtractSliceGenericFilter.txx"
+#endif
+
+#endif // #define clitkExtractSliceGenericFilter_h
--- /dev/null
+/*=========================================================================
+ 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 clitkExtractSliceGenericFilter_txx
+#define clitkExtractSliceGenericFilter_txx
+
+/* =================================================
+ * @file clitkExtractSliceGenericFilter.txx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+namespace clitk
+{
+
+ //-------------------------------------------------------------------
+ // Update with the number of dimensions
+ //-------------------------------------------------------------------
+ template<unsigned int Dimension>
+ void
+ ExtractSliceGenericFilter::UpdateWithDim(std::string PixelType)
+ {
+ if (m_Verbose) std::cout << "Image was detected to be "<<Dimension<<"D and "<< PixelType<<"..."<<std::endl;
+
+ if(PixelType == "short"){
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed short..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, signed short>();
+ }
+ // else if(PixelType == "unsigned_short"){
+ // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_short..." << std::endl;
+ // UpdateWithDimAndPixelType<Dimension, unsigned short>();
+ // }
+
+ else if (PixelType == "unsigned_char"){
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_char..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, unsigned char>();
+ }
+
+ // else if (PixelType == "char"){
+ // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed_char..." << std::endl;
+ // UpdateWithDimAndPixelType<Dimension, signed char>();
+ // }
+ else {
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and float..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, float>();
+ }
+ }
+
+
+ //-------------------------------------------------------------------
+ // Update with the number of dimensions and the pixeltype
+ //-------------------------------------------------------------------
+ template <unsigned int Dimension, class PixelType>
+ void
+ ExtractSliceGenericFilter::UpdateWithDimAndPixelType()
+ {
+
+ // ImageTypes
+ typedef itk::Image<PixelType, Dimension> InputImageType;
+ typedef itk::Image<PixelType, Dimension-1> OutputImageType;
+
+ // Read the input
+ typedef itk::ImageFileReader<InputImageType> InputReaderType;
+ typename InputReaderType::Pointer reader = InputReaderType::New();
+ reader->SetFileName( m_InputFileName);
+ reader->Update();
+ typename InputImageType::Pointer input= reader->GetOutput();
+
+ // Filter
+ typedef clitk::ExtractImageFilter<InputImageType, OutputImageType> ExtractImageFilterType;
+ typename ExtractImageFilterType::Pointer extractFilter=ExtractImageFilterType::New();
+ extractFilter->SetInput(input);
+
+ // Verify input
+ if( (m_ArgsInfo.axe_arg<0) || (static_cast<unsigned int >(m_ArgsInfo.axe_arg) >= Dimension) )
+ {
+ std::cerr<<"The axe index does not name a dimension!!"<<std::endl;
+ return;
+ }
+ typename InputImageType::RegionType region= input->GetLargestPossibleRegion();
+ typename InputImageType::RegionType::SizeType size= region.GetSize();
+
+ if( (m_ArgsInfo.slice_arg<0) || (static_cast<unsigned int>(m_ArgsInfo.slice_arg) >= size[static_cast<unsigned int >(m_ArgsInfo.axe_arg)]) )
+ {
+ std::cerr<<"The slice index does not name a slice!!"<<std::endl;
+ return;
+ }
+
+ // Collapse dimension
+ size[m_ArgsInfo.axe_arg]=0;
+ typename InputImageType::IndexType start;
+ start.Fill(0);
+ start[m_ArgsInfo.axe_arg]=m_ArgsInfo.slice_arg;
+ region.SetSize( size );
+ region.SetIndex(start);
+ extractFilter->SetExtractionRegion(region);
+ extractFilter->Update();
+ typename OutputImageType::Pointer output =extractFilter->GetOutput();
+
+ // Output
+ typedef itk::ImageFileWriter<OutputImageType> WriterType;
+ typename WriterType::Pointer writer = WriterType::New();
+ writer->SetFileName(m_ArgsInfo.output_arg);
+ writer->SetInput(output);
+ writer->Update();
+
+ }
+
+
+}//end clitk
+
+#endif //#define clitkExtractSliceGenericFilter_txx
/*=========================================================================
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
- BSD See included LICENSE.txt file
- CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
======================================================================-====*/
-#ifndef clitkBinarizeImageGenericFilter_cxx
-#define clitkBinarizeImageGenericFilter_cxx
/* =================================================
- * @file clitkBinarizeImageGenericFilter.cxx
- * @author Jef Vandemeulebroucke <jef@creatis.insa-lyon.fr>
- * @date 29 june 2009
- *
- * @brief
- *
+ * @file clitkFilter.cxx
+ * @author
+ * @date
+ *
+ * @brief
+ *
===================================================*/
-#include "clitkBinarizeImageGenericFilter.h"
-#endif //#define clitkBinarizeImageGenericFilter_cxx
+// clitk
+#include "clitkFilter_ggo.h"
+#include "clitkIO.h"
+#include "clitkFilterGenericFilter.h"
+
+
+//--------------------------------------------------------------------
+int main(int argc, char * argv[]) {
+
+ // Init command line
+ GGO(clitkFilter, args_info);
+ CLITK_INIT;
+
+ // Filter
+ clitk::FilterGenericFilter::Pointer genericFilter=clitk::FilterGenericFilter::New();
+
+ genericFilter->SetArgsInfo(args_info);
+ genericFilter->Update();
+
+ return EXIT_SUCCESS;
+}// end main
+
+//--------------------------------------------------------------------
--- /dev/null
+#File clitkFilter.ggo
+Package "clitkFilter"
+version "1.0"
+purpose ""
+
+option "config" - "Config file" string no
+option "verbose" v "Verbose" flag off
+
+option "input" i "Input image filename" string yes
+option "output" o "Output image filename" string yes
+option "mask" m "Mask in which the filter should be applied" string no
+
+option "float" - "Convert to float first " flag off
+
+section "Filter"
+
+option "type" t "Type of filter: 0=derivative, 1= gradient magnitude, 2= projection, 3= intensity windowing, 4=BSplineDownsampling with factor 2, 5=normalize intensities (mean=0 ,SD=1), 6=anisotropic diffusion, 7=gradient anisotropic diffusion, 8=curvature anisotropic diffusion, 9= curvature flow" int no default="0"
+option "order" - "0: what order" int no default="1"
+option "direction" - "0-2: what direction" int no default="0"
+option "projection" - "2: what accumulation (0=sum, 1=max, 2=min) " int no default="0"
+option "inputMin" - "3: set window minimum" float no default="0"
+option "inputMax" - "3: set window maximum" float no default="100"
+option "outputMin" - "3: set output minimum" float no default="0"
+option "outputMax" - "3: set output maximum" float no default="255"
+option "resamplerType" - "4: Resampler type to use for the downsampling (0=Standard, 1=Centered, 2=L2, 3=L2Centered) " int no default="0"
+option "splineOrder" - "4: SplineOrder to use for the downsampling (0-5, some resamplers only odd) " int no default="3"
+option "cond" - "6-8: conductance parameter" double no default="3.0"
+option "time" - "6-9: Time step (6,7: 0.25 for 2D and 0.125 for 3D; 8,9:0.125 for 2D and 0.0625 for 3D)" double no default="0.125"
+option "iter" - "6-9: Iterations (6-8=5; 9=10)" double no default="5"
+option "radius" - "9: radius" double no default="1"
--- /dev/null
+/*=========================================================================
+ 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 clitkFilterGenericFilter_cxx
+#define clitkFilterGenericFilter_cxx
+
+/* =================================================
+ * @file clitkFilterGenericFilter.cxx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+#include "clitkFilterGenericFilter.h"
+
+
+namespace clitk
+{
+
+
+ //-----------------------------------------------------------
+ // Constructor
+ //-----------------------------------------------------------
+ FilterGenericFilter::FilterGenericFilter()
+ {
+ m_Verbose=false;
+ m_InputFileName="";
+ }
+
+
+ //-----------------------------------------------------------
+ // Update
+ //-----------------------------------------------------------
+ void FilterGenericFilter::Update()
+ {
+ // Read the Dimension and PixelType
+ int Dimension;
+ std::string PixelType;
+ ReadImageDimensionAndPixelType(m_InputFileName, Dimension, PixelType);
+
+
+ // Call UpdateWithDim
+ if(Dimension==2) UpdateWithDim<2>(PixelType);
+ else if(Dimension==3) UpdateWithDim<3>(PixelType);
+ else if (Dimension==4)UpdateWithDim<4>(PixelType);
+ else
+ {
+ std::cout<<"Error, Only for 2 or 3 Dimensions!!!"<<std::endl ;
+ return;
+ }
+ }
+
+
+} //end clitk
+
+#endif //#define clitkFilterGenericFilter_cxx
--- /dev/null
+/*=========================================================================
+ 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 clitkFilterGenericFilter_h
+#define clitkFilterGenericFilter_h
+
+/* =================================================
+ * @file clitkFilterGenericFilter.h
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+// clitk include
+#include "clitkIO.h"
+#include "clitkCommon.h"
+#include "clitkImageCommon.h"
+#include "clitkFilter_ggo.h"
+
+//itk include
+#include "itkLightObject.h"
+#include "itkCastImageFilter.h"
+#include "itkDerivativeImageFilter.h"
+#include "itkGradientMagnitudeImageFilter.h"
+#include "itkSumProjectionImageFilter.h"
+#include "itkMaximumProjectionImageFilter.h"
+#include "itkMinimumProjectionImageFilter.h"
+#include "itkAccumulateImageFilter.h"
+#include "itkIntensityWindowingImageFilter.h"
+#include "itkRescaleIntensityImageFilter.h"
+#include "itkSmoothingRecursiveGaussianImageFilter.h"
+#include "itkDiscreteGaussianImageFilter.h"
+#include "itkBSplineDownsampleImageFilter.h"
+#include "itkNormalizeImageFilter.h"
+#include "itkAnisotropicDiffusionImageFilter.h"
+#include "itkGradientAnisotropicDiffusionImageFilter.h"
+#include "itkCurvatureAnisotropicDiffusionImageFilter.h"
+#include "itkCurvatureFlowImageFilter.h"
+
+namespace clitk
+{
+
+
+ class ITK_EXPORT FilterGenericFilter : public itk::LightObject
+ {
+ public:
+ //----------------------------------------
+ // ITK
+ //----------------------------------------
+ typedef FilterGenericFilter Self;
+ typedef itk::LightObject Superclass;
+ typedef itk::SmartPointer<Self> Pointer;
+ typedef itk::SmartPointer<const Self> ConstPointer;
+
+ // Method for creation through the object factory
+ itkNewMacro(Self);
+
+ // Run-time type information (and related methods)
+ itkTypeMacro( FilterGenericFilter, LightObject );
+
+
+ //----------------------------------------
+ // Typedefs
+ //----------------------------------------
+
+
+ //----------------------------------------
+ // Set & Get
+ //----------------------------------------
+ void SetArgsInfo(const args_info_clitkFilter & a)
+ {
+ m_ArgsInfo=a;
+ m_Verbose=m_ArgsInfo.verbose_flag;
+ m_InputFileName=m_ArgsInfo.input_arg;
+ }
+
+
+ //----------------------------------------
+ // Update
+ //----------------------------------------
+ void Update();
+
+ protected:
+
+ //----------------------------------------
+ // Constructor & Destructor
+ //----------------------------------------
+ FilterGenericFilter();
+ ~FilterGenericFilter() {};
+
+
+ //----------------------------------------
+ // Templated members
+ //----------------------------------------
+ template <unsigned int Dimension> void UpdateWithDim(std::string PixelType);
+ template <unsigned int Dimension, class PixelType> void UpdateWithDimAndPixelType();
+
+
+ //----------------------------------------
+ // Data members
+ //----------------------------------------
+ args_info_clitkFilter m_ArgsInfo;
+ bool m_Verbose;
+ std::string m_InputFileName;
+
+ };
+
+
+} // end namespace clitk
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#include "clitkFilterGenericFilter.txx"
+#endif
+
+#endif // #define clitkFilterGenericFilter_h
--- /dev/null
+/*=========================================================================
+ 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 clitkFilterGenericFilter_txx
+#define clitkFilterGenericFilter_txx
+
+/* =================================================
+ * @file clitkFilterGenericFilter.txx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+namespace clitk
+{
+
+ //-------------------------------------------------------------------
+ // Update with the number of dimensions
+ //-------------------------------------------------------------------
+ template<unsigned int Dimension>
+ void
+ FilterGenericFilter::UpdateWithDim(std::string PixelType)
+ {
+ if (m_Verbose) std::cout << "Image was detected to be "<<Dimension<<"D and "<< PixelType<<"..."<<std::endl;
+
+// if(PixelType == "short"){
+// if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed short..." << std::endl;
+// UpdateWithDimAndPixelType<Dimension, signed short>();
+// }
+ // else if(PixelType == "unsigned_short"){
+ // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_short..." << std::endl;
+ // UpdateWithDimAndPixelType<Dimension, unsigned short>();
+ // }
+
+// else if (PixelType == "unsigned_char"){
+// if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_char..." << std::endl;
+// UpdateWithDimAndPixelType<Dimension, unsigned char>();
+// }
+
+ // else if (PixelType == "char"){
+ // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed_char..." << std::endl;
+ // UpdateWithDimAndPixelType<Dimension, signed char>();
+ // }
+ // else {
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and float..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, float>();
+// }
+ }
+
+
+ //-------------------------------------------------------------------
+ // Update with the number of dimensions and the pixeltype
+ //-------------------------------------------------------------------
+ template <unsigned int Dimension, class InternalPixelType>
+ void
+ FilterGenericFilter::UpdateWithDimAndPixelType()
+ {
+
+ // ImageTypes
+ typedef itk::Image<InternalPixelType, Dimension> InputImageType;
+ typedef itk::Image<InternalPixelType, Dimension> InternalImageType;
+ typedef itk::Image<InternalPixelType, Dimension> OutputImageType;
+
+ // Read the input
+ typedef itk::ImageFileReader<InputImageType> InputReaderType;
+ typename InputReaderType::Pointer reader = InputReaderType::New();
+ reader->SetFileName( m_InputFileName);
+ reader->Update();
+ typename InputImageType::Pointer input= reader->GetOutput();
+
+
+ // Filter
+ typedef itk::ImageToImageFilter< InternalImageType, InternalImageType > ImageToImageFilterType;
+ typename ImageToImageFilterType::Pointer filter;
+
+ switch ( m_ArgsInfo.type_arg ){
+
+ case 0:{
+ typename itk::DerivativeImageFilter< InternalImageType,InternalImageType >::Pointer df = itk::DerivativeImageFilter<InternalImageType,InternalImageType >::New();
+
+ //Set parameters
+ df->SetDirection(m_ArgsInfo.direction_arg);
+ df->SetOrder(m_ArgsInfo.order_arg);
+ filter=df;
+ if (m_Verbose) std::cout<<"Using the derivative image filter with order "<<m_ArgsInfo.order_arg <<" on direction "<< m_ArgsInfo.direction_arg << "..." << std::endl;
+ break;
+ }
+ case 1:{
+ typename itk::GradientMagnitudeImageFilter< InternalImageType,InternalImageType >::Pointer gf = itk::GradientMagnitudeImageFilter<InternalImageType,InternalImageType >::New();
+
+ //Set parameters
+ gf->SetUseImageSpacingOn();
+
+ filter=gf;
+ if (m_Verbose) std::cout<<"Using the gradient magnitude image filter... "<< std::endl;
+ break;
+ }
+ case 2:{
+
+ switch ( m_ArgsInfo.projection_arg ){
+
+ case 0:{
+ //Sum
+ typename itk::SumProjectionImageFilter< InternalImageType,InternalImageType >::Pointer pf = itk::SumProjectionImageFilter<InternalImageType,InternalImageType>::New();
+ //Set parameters
+ pf->SetProjectionDimension(m_ArgsInfo.direction_arg);
+
+ filter=pf;
+ if (m_Verbose) std::cout<<"Using the Sum projection image filter on the dimension "<< m_ArgsInfo.direction_arg << "..."<<std::endl;
+ break;
+ }
+ case 1:{
+ //Max
+ typename itk::MaximumProjectionImageFilter< InternalImageType,InternalImageType >::Pointer pf = itk::MaximumProjectionImageFilter<InternalImageType,InternalImageType>::New();
+ //Set parameters
+ pf->SetProjectionDimension(m_ArgsInfo.direction_arg);
+
+ filter=pf;
+ if (m_Verbose) std::cout<<"Using the maximum intensity projection image filter on the dimension "<< m_ArgsInfo.direction_arg << "..."<<std::endl;
+ break;
+ }
+ case 2:{
+ //Sum
+ typename itk::MinimumProjectionImageFilter< InternalImageType,InternalImageType >::Pointer pf = itk::MinimumProjectionImageFilter<InternalImageType,InternalImageType>::New();
+ //Set parameters
+ pf->SetProjectionDimension(m_ArgsInfo.direction_arg);
+
+ filter=pf;
+ if (m_Verbose) std::cout<<"Using the minimum intensity projection image filter on the dimension "<< m_ArgsInfo.direction_arg << "..."<<std::endl;
+ break;
+ }
+ }
+ break;
+ }//end case projection filter
+
+ case 3: {
+ typename itk::IntensityWindowingImageFilter< InternalImageType,InternalImageType >::Pointer pf
+ = itk::IntensityWindowingImageFilter<InternalImageType,InternalImageType>::New();
+ //Set parameters
+ pf->SetWindowMinimum((InternalPixelType) m_ArgsInfo.inputMin_arg);
+ pf->SetWindowMaximum((InternalPixelType) m_ArgsInfo.inputMax_arg);
+ pf->SetOutputMinimum((InternalPixelType) m_ArgsInfo.outputMin_arg);
+ pf->SetOutputMaximum((InternalPixelType) m_ArgsInfo.outputMax_arg);
+
+ filter=pf;
+ if (m_Verbose) std::cout<<"Using the window intensity image filter with the window min and max being "
+ << m_ArgsInfo.inputMin_arg << " and "<< m_ArgsInfo.inputMax_arg
+ <<" and the output min and max being "<<m_ArgsInfo.outputMin_arg<<" and "
+ << m_ArgsInfo.outputMax_arg << std::endl;
+ break;
+ }
+ case 4: {
+
+ //Downsample using bsplines: four types of resamplers
+ typedef itk::BSplineResampleImageFilterBase<InternalImageType, InternalImageType> ResamplerType;
+ typedef itk::BSplineCenteredResampleImageFilterBase<InternalImageType, InternalImageType> CenteredResamplerType;
+ typedef itk::BSplineL2ResampleImageFilterBase<InternalImageType, InternalImageType> L2ResamplerType;
+ typedef itk::BSplineCenteredL2ResampleImageFilterBase<InternalImageType, InternalImageType> CenteredL2ResamplerType;
+
+ //ResamplerType
+ if(m_ArgsInfo.resamplerType_arg==0)
+ {
+ typename itk::BSplineDownsampleImageFilter< InternalImageType,InternalImageType, ResamplerType >::Pointer df
+ = itk::BSplineDownsampleImageFilter< InternalImageType,InternalImageType, ResamplerType >::New();
+ df->SetSplineOrder(m_ArgsInfo.splineOrder_arg);
+ filter=df;
+ if (m_Verbose) std::cout<<"Using the BSpline downsample image filter with Standard Resampler"<<std::endl;
+ }
+ //CenteredResamplerType
+ else if(m_ArgsInfo.resamplerType_arg==1)
+ {
+ typename itk::BSplineDownsampleImageFilter< InternalImageType,InternalImageType, CenteredResamplerType >::Pointer df
+ = itk::BSplineDownsampleImageFilter< InternalImageType,InternalImageType, CenteredResamplerType >::New();
+ df->SetSplineOrder(m_ArgsInfo.splineOrder_arg);
+ filter=df;
+ if (m_Verbose) std::cout<<"Using the BSpline downsample image filter with Centered Resampler"<<std::endl;
+ }
+ //L2ResamplerType
+ else if(m_ArgsInfo.resamplerType_arg==2)
+ {
+ typename itk::BSplineDownsampleImageFilter< InternalImageType,InternalImageType, L2ResamplerType >::Pointer df
+ = itk::BSplineDownsampleImageFilter< InternalImageType,InternalImageType,L2ResamplerType >::New();
+ df->SetSplineOrder(m_ArgsInfo.splineOrder_arg);
+ filter=df;
+ if (m_Verbose) std::cout<<"Using the BSpline downsample image filter with L2 Resampler"<<std::endl;
+ }
+ else if(m_ArgsInfo.resamplerType_arg==3)
+ {
+ typename itk::BSplineDownsampleImageFilter< InternalImageType,InternalImageType, CenteredL2ResamplerType >::Pointer df
+ = itk::BSplineDownsampleImageFilter< InternalImageType,InternalImageType,CenteredL2ResamplerType >::New();
+ df->SetSplineOrder(m_ArgsInfo.splineOrder_arg);
+ filter=df;
+ if (m_Verbose) std::cout<<"Using the BSpline downsample image filter with L2 Centered Resampler"<<std::endl;
+ }
+ break;
+ }
+ case 5: {
+ typedef itk::NormalizeImageFilter<InternalImageType, InternalImageType> NormalizeFilterType;
+ typename NormalizeFilterType::Pointer df = NormalizeFilterType::New();
+ filter=df;
+ if (m_Verbose) std::cout << "Normalizing image intensities to a zero mean and 1 SD (float!)..." << std::endl;
+ break;
+ }
+// case 6: {
+// typedef itk::AnisotropicDiffusionImageFilter<InternalImageType, InternalImageType> FilterType;
+// typename FilterType::Pointer df = FilterType::New();
+// df->SetConductanceParameter(m_ArgsInfo.cond_arg);
+// df->SetNumberOfIterations(m_ArgsInfo.iter_arg);
+// df->SetTimeStep(m_ArgsInfo.time_arg);
+// df->SetUseImageSpacing(true);
+
+// filter=df;
+// if (m_Verbose) std::cout << "Using the anisotropic diffusion image filter..." << std::endl;
+// break;
+// }
+
+ case 7: {
+ typedef itk::GradientAnisotropicDiffusionImageFilter<InternalImageType, InternalImageType> FilterType;
+ typename FilterType::Pointer df = FilterType::New();
+ df->SetConductanceParameter(m_ArgsInfo.cond_arg);
+ df->SetNumberOfIterations(m_ArgsInfo.iter_arg);
+ df->SetTimeStep(m_ArgsInfo.time_arg);
+ df->SetUseImageSpacing(true);
+
+ filter=df;
+ if (m_Verbose) std::cout << "Using the gradient anisotropic diffusion image filter..." << std::endl;
+ break;
+ }
+
+ case 8: {
+ typedef itk::CurvatureAnisotropicDiffusionImageFilter<InternalImageType, InternalImageType> FilterType;
+ typename FilterType::Pointer df = FilterType::New();
+ df->SetConductanceParameter(m_ArgsInfo.cond_arg);
+ df->SetNumberOfIterations(m_ArgsInfo.iter_arg);
+ df->SetTimeStep(m_ArgsInfo.time_arg);
+ df->SetUseImageSpacing(true);
+
+ filter=df;
+ if (m_Verbose) std::cout << "Using the Curvature anisotropic diffusion image filter..." << std::endl;
+ break;
+ }
+
+ case 9: {
+ typedef itk::CurvatureFlowImageFilter<InternalImageType, InternalImageType> FilterType;
+ typename FilterType::Pointer df = FilterType::New();
+ df->SetTimeStep(m_ArgsInfo.time_arg);
+ df->SetUseImageSpacing(true);
+ df->SetNumberOfIterations(m_ArgsInfo.iter_arg);
+ filter=df;
+ if (m_Verbose) std::cout << "Using the curvature flow image filter......" << std::endl;
+ break;
+ }
+
+
+ }//end switch filterType
+
+
+ //==================================================================
+ //execute the filter
+ filter->SetInput(input);
+
+
+ if (m_Verbose)std::cout<<"Starting filter..."<<std::endl;
+
+ try {
+ filter->Update();
+ }
+ catch( itk::ExceptionObject & err )
+ {
+ std::cerr << "ExceptionObject caught! Filter failed!" << std::endl;
+ std::cerr << err << std::endl;
+ return;
+ }
+
+ // Output
+ typedef itk::ImageFileWriter<OutputImageType> WriterType;
+ typename WriterType::Pointer writer = WriterType::New();
+ writer->SetFileName(m_ArgsInfo.output_arg);
+ writer->SetInput(filter->GetOutput());
+ writer->Update();
+
+ }
+
+
+}//end clitk
+
+#endif //#define clitkFilterGenericFilter_txx
--- /dev/null
+/*=========================================================================
+ 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 clitkFlipImage.cxx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+// clitk
+#include "clitkFlipImage_ggo.h"
+#include "clitkIO.h"
+#include "clitkFlipImageGenericFilter.h"
+
+
+//--------------------------------------------------------------------
+int main(int argc, char * argv[]) {
+
+ // Init command line
+ GGO(clitkFlipImage, args_info);
+ CLITK_INIT;
+
+ // Filter
+ clitk::FlipImageGenericFilter::Pointer genericFilter=clitk::FlipImageGenericFilter::New();
+
+ genericFilter->SetArgsInfo(args_info);
+ genericFilter->Update();
+
+ return EXIT_SUCCESS;
+}// end main
+
+//--------------------------------------------------------------------
--- /dev/null
+#File clitkFlipImage.ggo
+Package "clitkFlipImage"
+version "1.0"
+purpose ""
+
+option "config" - "Config file" string no
+option "verbose" v "Verbose" flag off
+
+option "input" i "Input image filename" string yes
+option "output" o "Output image filename" string yes
+option "axe" a "Axe" int no default="0"
+option "origin" - "Flip around origin" flag off
--- /dev/null
+/*=========================================================================
+ 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 clitkFlipImageGenericFilter_cxx
+#define clitkFlipImageGenericFilter_cxx
+
+/* =================================================
+ * @file clitkFlipImageGenericFilter.cxx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+#include "clitkFlipImageGenericFilter.h"
+
+
+namespace clitk
+{
+
+
+ //-----------------------------------------------------------
+ // Constructor
+ //-----------------------------------------------------------
+ FlipImageGenericFilter::FlipImageGenericFilter()
+ {
+ m_Verbose=false;
+ m_InputFileName="";
+ }
+
+
+ //-----------------------------------------------------------
+ // Update
+ //-----------------------------------------------------------
+ void FlipImageGenericFilter::Update()
+ {
+ // Read the Dimension and PixelType
+ int Dimension;
+ std::string PixelType;
+ ReadImageDimensionAndPixelType(m_InputFileName, Dimension, PixelType);
+
+
+ // Call UpdateWithDim
+ if(Dimension==2) UpdateWithDim<2>(PixelType);
+ else if(Dimension==3) UpdateWithDim<3>(PixelType);
+ else if (Dimension==4)UpdateWithDim<4>(PixelType);
+ else
+ {
+ std::cout<<"Error, Only for 2,3 or 4 Dimensions!!!"<<std::endl ;
+ return;
+ }
+ }
+
+
+} //end clitk
+
+#endif //#define clitkFlipImageGenericFilter_cxx
--- /dev/null
+/*=========================================================================
+ 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 clitkFlipImageGenericFilter_h
+#define clitkFlipImageGenericFilter_h
+
+/* =================================================
+ * @file clitkFlipImageGenericFilter.h
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+// clitk include
+#include "clitkIO.h"
+#include "clitkCommon.h"
+#include "clitkImageCommon.h"
+#include "clitkFlipImage_ggo.h"
+
+//itk include
+#include "itkLightObject.h"
+#include "itkFlipImageFilter.h"
+namespace clitk
+{
+
+
+ class ITK_EXPORT FlipImageGenericFilter : public itk::LightObject
+ {
+ public:
+ //----------------------------------------
+ // ITK
+ //----------------------------------------
+ typedef FlipImageGenericFilter Self;
+ typedef itk::LightObject Superclass;
+ typedef itk::SmartPointer<Self> Pointer;
+ typedef itk::SmartPointer<const Self> ConstPointer;
+
+ // Method for creation through the object factory
+ itkNewMacro(Self);
+
+ // Run-time type information (and related methods)
+ itkTypeMacro( FlipImageGenericFilter, LightObject );
+
+
+ //----------------------------------------
+ // Typedefs
+ //----------------------------------------
+
+
+ //----------------------------------------
+ // Set & Get
+ //----------------------------------------
+ void SetArgsInfo(const args_info_clitkFlipImage & a)
+ {
+ m_ArgsInfo=a;
+ m_Verbose=m_ArgsInfo.verbose_flag;
+ m_InputFileName=m_ArgsInfo.input_arg;
+ }
+
+
+ //----------------------------------------
+ // Update
+ //----------------------------------------
+ void Update();
+
+ protected:
+
+ //----------------------------------------
+ // Constructor & Destructor
+ //----------------------------------------
+ FlipImageGenericFilter();
+ ~FlipImageGenericFilter() {};
+
+
+ //----------------------------------------
+ // Templated members
+ //----------------------------------------
+ template <unsigned int Dimension> void UpdateWithDim(std::string PixelType);
+ template <unsigned int Dimension, class PixelType> void UpdateWithDimAndPixelType();
+
+
+ //----------------------------------------
+ // Data members
+ //----------------------------------------
+ args_info_clitkFlipImage m_ArgsInfo;
+ bool m_Verbose;
+ std::string m_InputFileName;
+
+ };
+
+
+} // end namespace clitk
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#include "clitkFlipImageGenericFilter.txx"
+#endif
+
+#endif // #define clitkFlipImageGenericFilter_h
--- /dev/null
+/*=========================================================================
+ 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 clitkFlipImageGenericFilter_txx
+#define clitkFlipImageGenericFilter_txx
+
+/* =================================================
+ * @file clitkFlipImageGenericFilter.txx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+namespace clitk
+{
+
+ //-------------------------------------------------------------------
+ // Update with the number of dimensions
+ //-------------------------------------------------------------------
+ template<unsigned int Dimension>
+ void
+ FlipImageGenericFilter::UpdateWithDim(std::string PixelType)
+ {
+ if (m_Verbose) std::cout << "Image was detected to be "<<Dimension<<"D and "<< PixelType<<"..."<<std::endl;
+
+ if(PixelType == "short"){
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed short..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, signed short>();
+ }
+ // else if(PixelType == "unsigned_short"){
+ // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_short..." << std::endl;
+ // UpdateWithDimAndPixelType<Dimension, unsigned short>();
+ // }
+
+ else if (PixelType == "unsigned_char"){
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_char..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, unsigned char>();
+ }
+
+ // else if (PixelType == "char"){
+ // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed_char..." << std::endl;
+ // UpdateWithDimAndPixelType<Dimension, signed char>();
+ // }
+ else {
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and float..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, float>();
+ }
+ }
+
+
+ //-------------------------------------------------------------------
+ // Update with the number of dimensions and the pixeltype
+ //-------------------------------------------------------------------
+ template <unsigned int Dimension, class PixelType>
+ void
+ FlipImageGenericFilter::UpdateWithDimAndPixelType()
+ {
+
+ // ImageTypes
+ typedef itk::Image<PixelType, Dimension> InputImageType;
+ typedef itk::Image<PixelType, Dimension> OutputImageType;
+
+ // Read the input
+ typedef itk::ImageFileReader<InputImageType> InputReaderType;
+ typename InputReaderType::Pointer reader = InputReaderType::New();
+ reader->SetFileName( m_InputFileName);
+ reader->Update();
+ typename InputImageType::Pointer input= reader->GetOutput();
+
+ // Filter
+ typedef itk::FlipImageFilter<InputImageType> FlipImageFilterType;
+ typename FlipImageFilterType::Pointer flipFilter=FlipImageFilterType::New();
+ flipFilter->SetInput(input);
+ if ((unsigned int)m_ArgsInfo.axe_arg>= Dimension || (unsigned int)m_ArgsInfo.axe_arg<0)
+ {
+ std::cerr<<"Bad axe input!!"<<std::endl;
+ return;
+ }
+ else
+ {
+ typename FlipImageFilterType::FlipAxesArrayType axes;
+ axes.Fill(false);
+ axes[m_ArgsInfo.axe_arg]=true;
+ flipFilter->SetFlipAxes(axes);
+ flipFilter->SetFlipAboutOrigin(m_ArgsInfo.origin_flag);
+ }
+
+ flipFilter->Update();
+ typename OutputImageType::Pointer output=flipFilter->GetOutput();
+
+ // Output
+ typedef itk::ImageFileWriter<OutputImageType> WriterType;
+ typename WriterType::Pointer writer = WriterType::New();
+ writer->SetFileName(m_ArgsInfo.output_arg);
+ writer->SetInput(output);
+ writer->Update();
+
+ }
+
+
+}//end clitk
+
+#endif //#define clitkFlipImageGenericFilter_txx
--- /dev/null
+/*=========================================================================
+ 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 clitkGetDirection.cxx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+// clitk
+#include "clitkGetDirection_ggo.h"
+#include "clitkIO.h"
+#include "clitkGetDirectionGenericFilter.h"
+
+
+//--------------------------------------------------------------------
+int main(int argc, char * argv[]) {
+
+ // Init command line
+ GGO(clitkGetDirection, args_info);
+ CLITK_INIT;
+
+ // Filter
+ clitk::GetDirectionGenericFilter::Pointer genericFilter=clitk::GetDirectionGenericFilter::New();
+
+ genericFilter->SetArgsInfo(args_info);
+ genericFilter->Update();
+
+ return EXIT_SUCCESS;
+}// end main
+
+//--------------------------------------------------------------------
--- /dev/null
+#File clitkGetDirection.ggo
+Package "clitkGetDirection"
+version "1.0"
+purpose ""
+
+option "config" - "Config file" string no
+option "verbose" v "Verbose" flag off
+
+option "input" i "Input image filename" string yes
+
+
--- /dev/null
+/*=========================================================================
+ 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 clitkGetDirectionGenericFilter_cxx
+#define clitkGetDirectionGenericFilter_cxx
+
+/* =================================================
+ * @file clitkGetDirectionGenericFilter.cxx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+#include "clitkGetDirectionGenericFilter.h"
+
+
+namespace clitk
+{
+
+
+ //-----------------------------------------------------------
+ // Constructor
+ //-----------------------------------------------------------
+ GetDirectionGenericFilter::GetDirectionGenericFilter()
+ {
+ m_Verbose=false;
+ m_InputFileName="";
+ }
+
+
+ //-----------------------------------------------------------
+ // Update
+ //-----------------------------------------------------------
+ void GetDirectionGenericFilter::Update()
+ {
+ // Read the Dimension and PixelType
+ int Dimension;
+ std::string PixelType;
+ ReadImageDimensionAndPixelType(m_InputFileName, Dimension, PixelType);
+
+
+ // Call UpdateWithDim
+ if(Dimension==2) UpdateWithDim<2>(PixelType);
+ else if(Dimension==3) UpdateWithDim<3>(PixelType);
+ else if (Dimension==4)UpdateWithDim<4>(PixelType);
+ else
+ {
+ std::cout<<"Error, Only for 2,3 or 4 Dimensions!!!"<<std::endl ;
+ return;
+ }
+ }
+
+
+} //end clitk
+
+#endif //#define clitkGetDirectionGenericFilter_cxx
--- /dev/null
+/*=========================================================================
+ 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 clitkGetDirectionGenericFilter_h
+#define clitkGetDirectionGenericFilter_h
+
+/* =================================================
+ * @file clitkGetDirectionGenericFilter.h
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+// clitk include
+#include "clitkIO.h"
+#include "clitkCommon.h"
+#include "clitkImageCommon.h"
+#include "clitkGetDirection_ggo.h"
+
+//itk include
+#include "itkLightObject.h"
+
+namespace clitk
+{
+
+
+ class ITK_EXPORT GetDirectionGenericFilter : public itk::LightObject
+ {
+ public:
+ //----------------------------------------
+ // ITK
+ //----------------------------------------
+ typedef GetDirectionGenericFilter Self;
+ typedef itk::LightObject Superclass;
+ typedef itk::SmartPointer<Self> Pointer;
+ typedef itk::SmartPointer<const Self> ConstPointer;
+
+ // Method for creation through the object factory
+ itkNewMacro(Self);
+
+ // Run-time type information (and related methods)
+ itkTypeMacro( GetDirectionGenericFilter, LightObject );
+
+
+ //----------------------------------------
+ // Typedefs
+ //----------------------------------------
+
+
+ //----------------------------------------
+ // Set & Get
+ //----------------------------------------
+ void SetArgsInfo(const args_info_clitkGetDirection & a)
+ {
+ m_ArgsInfo=a;
+ m_Verbose=m_ArgsInfo.verbose_flag;
+ m_InputFileName=m_ArgsInfo.input_arg;
+ }
+
+
+ //----------------------------------------
+ // Update
+ //----------------------------------------
+ void Update();
+
+ protected:
+
+ //----------------------------------------
+ // Constructor & Destructor
+ //----------------------------------------
+ GetDirectionGenericFilter();
+ ~GetDirectionGenericFilter() {};
+
+
+ //----------------------------------------
+ // Templated members
+ //----------------------------------------
+ template <unsigned int Dimension> void UpdateWithDim(std::string PixelType);
+ template <unsigned int Dimension, class PixelType> void UpdateWithDimAndPixelType();
+
+
+ //----------------------------------------
+ // Data members
+ //----------------------------------------
+ args_info_clitkGetDirection m_ArgsInfo;
+ bool m_Verbose;
+ std::string m_InputFileName;
+
+ };
+
+
+} // end namespace clitk
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#include "clitkGetDirectionGenericFilter.txx"
+#endif
+
+#endif // #define clitkGetDirectionGenericFilter_h
--- /dev/null
+/*=========================================================================
+ 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 clitkGetDirectionGenericFilter_txx
+#define clitkGetDirectionGenericFilter_txx
+
+/* =================================================
+ * @file clitkGetDirectionGenericFilter.txx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+namespace clitk
+{
+
+ //-------------------------------------------------------------------
+ // Update with the number of dimensions
+ //-------------------------------------------------------------------
+ template<unsigned int Dimension>
+ void
+ GetDirectionGenericFilter::UpdateWithDim(std::string PixelType)
+ {
+ if (m_Verbose) std::cout << "Image was detected to be "<<Dimension<<"D and "<< PixelType<<"..."<<std::endl;
+
+ if(PixelType == "short"){
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed short..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, signed short>();
+ }
+ // else if(PixelType == "unsigned_short"){
+ // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_short..." << std::endl;
+ // UpdateWithDimAndPixelType<Dimension, unsigned short>();
+ // }
+
+ else if (PixelType == "unsigned_char"){
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_char..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, unsigned char>();
+ }
+
+ // else if (PixelType == "char"){
+ // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed_char..." << std::endl;
+ // UpdateWithDimAndPixelType<Dimension, signed char>();
+ // }
+ else {
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and float..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, float>();
+ }
+ }
+
+
+ //-------------------------------------------------------------------
+ // Update with the number of dimensions and the pixeltype
+ //-------------------------------------------------------------------
+ template <unsigned int Dimension, class PixelType>
+ void
+ GetDirectionGenericFilter::UpdateWithDimAndPixelType()
+ {
+
+ // ImageTypes
+ typedef itk::Image<PixelType, Dimension> InputImageType;
+ typedef itk::Image<PixelType, Dimension> OutputImageType;
+
+ // Read the input
+ typedef itk::ImageFileReader<InputImageType> InputReaderType;
+ typename InputReaderType::Pointer reader = InputReaderType::New();
+ reader->SetFileName( m_InputFileName);
+ reader->Update();
+ typename InputImageType::Pointer input= reader->GetOutput();
+
+ // Filter
+ typename InputImageType::DirectionType direction=input->GetDirection();
+ for (unsigned int i=0;i<Dimension;i++)
+ for (unsigned int j=0;j<Dimension;j++)
+ {
+ if (i+j !=0)std::cout<<",";
+ std::cout<<direction[i][j];
+ }
+ std::cout<<std::endl;
+
+
+ }
+
+
+}//end clitk
+
+#endif //#define clitkGetDirectionGenericFilter_txx
--- /dev/null
+/*=========================================================================
+ 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 clitkGetOrigin.cxx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+// clitk
+#include "clitkGetOrigin_ggo.h"
+#include "clitkIO.h"
+#include "clitkGetOriginGenericFilter.h"
+
+
+//--------------------------------------------------------------------
+int main(int argc, char * argv[]) {
+
+ // Init command line
+ GGO(clitkGetOrigin, args_info);
+ CLITK_INIT;
+
+ // Filter
+ clitk::GetOriginGenericFilter::Pointer genericFilter=clitk::GetOriginGenericFilter::New();
+
+ genericFilter->SetArgsInfo(args_info);
+ genericFilter->Update();
+
+ return EXIT_SUCCESS;
+}// end main
+
+//--------------------------------------------------------------------
--- /dev/null
+#File clitkGetOrigin.ggo
+Package "clitkGetOrigin"
+version "1.0"
+purpose ""
+
+option "config" - "Config file" string no
+option "verbose" v "Verbose" flag off
+
+option "input" i "Input image filename" string yes
+option "comma" o "Output comma separated values" flag off
+
+
--- /dev/null
+/*=========================================================================
+ 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 clitkGetOriginGenericFilter_cxx
+#define clitkGetOriginGenericFilter_cxx
+
+/* =================================================
+ * @file clitkGetOriginGenericFilter.cxx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+#include "clitkGetOriginGenericFilter.h"
+
+
+namespace clitk
+{
+
+
+ //-----------------------------------------------------------
+ // Constructor
+ //-----------------------------------------------------------
+ GetOriginGenericFilter::GetOriginGenericFilter()
+ {
+ m_Verbose=false;
+ m_InputFileName="";
+ }
+
+
+ //-----------------------------------------------------------
+ // Update
+ //-----------------------------------------------------------
+ void GetOriginGenericFilter::Update()
+ {
+ // Read the Dimension and PixelType
+ int Dimension;
+ std::string PixelType;
+ ReadImageDimensionAndPixelType(m_InputFileName, Dimension, PixelType);
+
+
+ // Call UpdateWithDim
+ if(Dimension==2) UpdateWithDim<2>(PixelType);
+ else if(Dimension==3) UpdateWithDim<3>(PixelType);
+ else if (Dimension==4)UpdateWithDim<4>(PixelType);
+ else
+ {
+ std::cout<<"Error, Only for 2 or 3 or 4 Dimensions!!!"<<std::endl ;
+ return;
+ }
+ }
+
+
+} //end clitk
+
+#endif //#define clitkGetOriginGenericFilter_cxx
--- /dev/null
+/*=========================================================================
+ 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 clitkGetOriginGenericFilter_h
+#define clitkGetOriginGenericFilter_h
+
+/* =================================================
+ * @file clitkGetOriginGenericFilter.h
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+// clitk include
+#include "clitkIO.h"
+#include "clitkCommon.h"
+#include "clitkImageCommon.h"
+#include "clitkGetOrigin_ggo.h"
+
+//itk include
+#include "itkLightObject.h"
+
+namespace clitk
+{
+
+
+ class ITK_EXPORT GetOriginGenericFilter : public itk::LightObject
+ {
+ public:
+ //----------------------------------------
+ // ITK
+ //----------------------------------------
+ typedef GetOriginGenericFilter Self;
+ typedef itk::LightObject Superclass;
+ typedef itk::SmartPointer<Self> Pointer;
+ typedef itk::SmartPointer<const Self> ConstPointer;
+
+ // Method for creation through the object factory
+ itkNewMacro(Self);
+
+ // Run-time type information (and related methods)
+ itkTypeMacro( GetOriginGenericFilter, LightObject );
+
+
+ //----------------------------------------
+ // Typedefs
+ //----------------------------------------
+
+
+ //----------------------------------------
+ // Set & Get
+ //----------------------------------------
+ void SetArgsInfo(const args_info_clitkGetOrigin & a)
+ {
+ m_ArgsInfo=a;
+ m_Verbose=m_ArgsInfo.verbose_flag;
+ m_InputFileName=m_ArgsInfo.input_arg;
+ }
+
+
+ //----------------------------------------
+ // Update
+ //----------------------------------------
+ void Update();
+
+ protected:
+
+ //----------------------------------------
+ // Constructor & Destructor
+ //----------------------------------------
+ GetOriginGenericFilter();
+ ~GetOriginGenericFilter() {};
+
+
+ //----------------------------------------
+ // Templated members
+ //----------------------------------------
+ template <unsigned int Dimension> void UpdateWithDim(std::string PixelType);
+ template <unsigned int Dimension, class PixelType> void UpdateWithDimAndPixelType();
+
+
+ //----------------------------------------
+ // Data members
+ //----------------------------------------
+ args_info_clitkGetOrigin m_ArgsInfo;
+ bool m_Verbose;
+ std::string m_InputFileName;
+
+ };
+
+
+} // end namespace clitk
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#include "clitkGetOriginGenericFilter.txx"
+#endif
+
+#endif // #define clitkGetOriginGenericFilter_h
--- /dev/null
+/*=========================================================================
+ 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 clitkGetOriginGenericFilter_txx
+#define clitkGetOriginGenericFilter_txx
+
+/* =================================================
+ * @file clitkGetOriginGenericFilter.txx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+namespace clitk
+{
+
+ //-------------------------------------------------------------------
+ // Update with the number of dimensions
+ //-------------------------------------------------------------------
+ template<unsigned int Dimension>
+ void
+ GetOriginGenericFilter::UpdateWithDim(std::string PixelType)
+ {
+ if (m_Verbose) std::cout << "Image was detected to be "<<Dimension<<"D and "<< PixelType<<"..."<<std::endl;
+
+ if(PixelType == "short"){
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed short..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, signed short>();
+ }
+ // else if(PixelType == "unsigned_short"){
+ // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_short..." << std::endl;
+ // UpdateWithDimAndPixelType<Dimension, unsigned short>();
+ // }
+
+ else if (PixelType == "unsigned_char"){
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_char..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, unsigned char>();
+ }
+
+ // else if (PixelType == "char"){
+ // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed_char..." << std::endl;
+ // UpdateWithDimAndPixelType<Dimension, signed char>();
+ // }
+ else {
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and float..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, float>();
+ }
+ }
+
+
+ //-------------------------------------------------------------------
+ // Update with the number of dimensions and the pixeltype
+ //-------------------------------------------------------------------
+ template <unsigned int Dimension, class PixelType>
+ void
+ GetOriginGenericFilter::UpdateWithDimAndPixelType()
+ {
+
+ // ImageTypes
+ typedef itk::Image<PixelType, Dimension> InputImageType;
+ typedef itk::Image<PixelType, Dimension> OutputImageType;
+
+ // Read the input
+ typedef itk::ImageFileReader<InputImageType> InputReaderType;
+ typename InputReaderType::Pointer reader = InputReaderType::New();
+ reader->SetFileName( m_InputFileName);
+ reader->Update();
+ typename InputImageType::Pointer input= reader->GetOutput();
+
+ //Get Origin
+ typename InputImageType::PointType origin=input->GetOrigin();
+ for(unsigned int i=0; i<Dimension-1; i++)
+ {
+ std::cout<<origin[i];
+ if (!m_ArgsInfo.comma_flag)std::cout<<" ";
+ else std::cout<<",";
+ }
+ std::cout<<origin[Dimension-1]<<std::endl;
+
+ }
+
+
+}//end clitk
+
+#endif //#define clitkGetOriginGenericFilter_txx
--- /dev/null
+/*=========================================================================
+ 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 clitkGetSize.cxx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+// clitk
+#include "clitkGetSize_ggo.h"
+#include "clitkIO.h"
+#include "clitkGetSizeGenericFilter.h"
+
+
+//--------------------------------------------------------------------
+int main(int argc, char * argv[]) {
+
+ // Init command line
+ GGO(clitkGetSize, args_info);
+ CLITK_INIT;
+
+ // Filter
+ clitk::GetSizeGenericFilter::Pointer genericFilter=clitk::GetSizeGenericFilter::New();
+
+ genericFilter->SetArgsInfo(args_info);
+ genericFilter->Update();
+
+ return EXIT_SUCCESS;
+}// end main
+
+//--------------------------------------------------------------------
--- /dev/null
+#File clitkGetSize.ggo
+Package "clitkGetSize"
+version "1.0"
+purpose ""
+
+option "config" - "Config file" string no
+option "verbose" v "Verbose" flag off
+
+option "input" i "Input image filename" string yes
+option "comma" c "Output comma separated values" flag off
+
+
--- /dev/null
+/*=========================================================================
+ 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 clitkGetSizeGenericFilter_cxx
+#define clitkGetSizeGenericFilter_cxx
+
+/* =================================================
+ * @file clitkGetSizeGenericFilter.cxx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+#include "clitkGetSizeGenericFilter.h"
+
+
+namespace clitk
+{
+
+
+ //-----------------------------------------------------------
+ // Constructor
+ //-----------------------------------------------------------
+ GetSizeGenericFilter::GetSizeGenericFilter()
+ {
+ m_Verbose=false;
+ m_InputFileName="";
+ }
+
+
+ //-----------------------------------------------------------
+ // Update
+ //-----------------------------------------------------------
+ void GetSizeGenericFilter::Update()
+ {
+ // Read the Dimension and PixelType
+ int Dimension;
+ std::string PixelType;
+ ReadImageDimensionAndPixelType(m_InputFileName, Dimension, PixelType);
+
+
+ // Call UpdateWithDim
+ if(Dimension==2) UpdateWithDim<2>(PixelType);
+ else if(Dimension==3) UpdateWithDim<3>(PixelType);
+ else if (Dimension==4)UpdateWithDim<4>(PixelType);
+ else
+ {
+ std::cout<<"Error, Only for 2 or 3 or 4 Dimensions!!!"<<std::endl ;
+ return;
+ }
+ }
+
+
+} //end clitk
+
+#endif //#define clitkGetSizeGenericFilter_cxx
--- /dev/null
+/*=========================================================================
+ 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 clitkGetSizeGenericFilter_h
+#define clitkGetSizeGenericFilter_h
+
+/* =================================================
+ * @file clitkGetSizeGenericFilter.h
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+// clitk include
+#include "clitkIO.h"
+#include "clitkCommon.h"
+#include "clitkImageCommon.h"
+#include "clitkGetSize_ggo.h"
+
+//itk include
+#include "itkLightObject.h"
+
+namespace clitk
+{
+
+
+ class ITK_EXPORT GetSizeGenericFilter : public itk::LightObject
+ {
+ public:
+ //----------------------------------------
+ // ITK
+ //----------------------------------------
+ typedef GetSizeGenericFilter Self;
+ typedef itk::LightObject Superclass;
+ typedef itk::SmartPointer<Self> Pointer;
+ typedef itk::SmartPointer<const Self> ConstPointer;
+
+ // Method for creation through the object factory
+ itkNewMacro(Self);
+
+ // Run-time type information (and related methods)
+ itkTypeMacro( GetSizeGenericFilter, LightObject );
+
+
+ //----------------------------------------
+ // Typedefs
+ //----------------------------------------
+
+
+ //----------------------------------------
+ // Set & Get
+ //----------------------------------------
+ void SetArgsInfo(const args_info_clitkGetSize & a)
+ {
+ m_ArgsInfo=a;
+ m_Verbose=m_ArgsInfo.verbose_flag;
+ m_InputFileName=m_ArgsInfo.input_arg;
+ }
+
+
+ //----------------------------------------
+ // Update
+ //----------------------------------------
+ void Update();
+
+ protected:
+
+ //----------------------------------------
+ // Constructor & Destructor
+ //----------------------------------------
+ GetSizeGenericFilter();
+ ~GetSizeGenericFilter() {};
+
+
+ //----------------------------------------
+ // Templated members
+ //----------------------------------------
+ template <unsigned int Dimension> void UpdateWithDim(std::string PixelType);
+ template <unsigned int Dimension, class PixelType> void UpdateWithDimAndPixelType();
+
+
+ //----------------------------------------
+ // Data members
+ //----------------------------------------
+ args_info_clitkGetSize m_ArgsInfo;
+ bool m_Verbose;
+ std::string m_InputFileName;
+
+ };
+
+
+} // end namespace clitk
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#include "clitkGetSizeGenericFilter.txx"
+#endif
+
+#endif // #define clitkGetSizeGenericFilter_h
--- /dev/null
+/*=========================================================================
+ 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 clitkGetSizeGenericFilter_txx
+#define clitkGetSizeGenericFilter_txx
+
+/* =================================================
+ * @file clitkGetSizeGenericFilter.txx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+namespace clitk
+{
+
+ //-------------------------------------------------------------------
+ // Update with the number of dimensions
+ //-------------------------------------------------------------------
+ template<unsigned int Dimension>
+ void
+ GetSizeGenericFilter::UpdateWithDim(std::string PixelType)
+ {
+ if (m_Verbose) std::cout << "Image was detected to be "<<Dimension<<"D and "<< PixelType<<"..."<<std::endl;
+
+ // if(PixelType == "short"){
+ // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed short..." << std::endl;
+ // UpdateWithDimAndPixelType<Dimension, signed short>();
+ // }
+ // else if(PixelType == "unsigned_short"){
+ // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_short..." << std::endl;
+ // UpdateWithDimAndPixelType<Dimension, unsigned short>();
+ // }
+
+ //else if (PixelType == "unsigned_char"){
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_char..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, unsigned char>();
+ //}
+
+ // else if (PixelType == "char"){
+ // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed_char..." << std::endl;
+ // UpdateWithDimAndPixelType<Dimension, signed char>();
+ // }
+ // else {
+ // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and float..." << std::endl;
+ // UpdateWithDimAndPixelType<Dimension, float>();
+ // }
+ }
+
+
+ //-------------------------------------------------------------------
+ // Update with the number of dimensions and the pixeltype
+ //-------------------------------------------------------------------
+ template <unsigned int Dimension, class PixelType>
+ void
+ GetSizeGenericFilter::UpdateWithDimAndPixelType()
+ {
+
+ // ImageTypes
+ typedef itk::Image<PixelType, Dimension> InputImageType;
+ typedef itk::Image<PixelType, Dimension> OutputImageType;
+
+ // Read the input
+ typedef itk::ImageFileReader<InputImageType> InputReaderType;
+ typename InputReaderType::Pointer reader = InputReaderType::New();
+ reader->SetFileName( m_InputFileName);
+ reader->Update();
+ typename InputImageType::Pointer input= reader->GetOutput();
+
+ // Filter
+ typename InputImageType::SizeType size=input->GetLargestPossibleRegion().GetSize();
+ for(unsigned int i=0; i<Dimension-1; i++)
+ {
+ std::cout<<size[i];
+ if (!m_ArgsInfo.comma_flag)std::cout<<" ";
+ else std::cout<<",";
+ }
+ std::cout<<size[Dimension-1]<<std::endl;
+
+
+ }
+
+
+}//end clitk
+
+#endif //#define clitkGetSizeGenericFilter_txx
--- /dev/null
+/*=========================================================================
+ 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 clitkGetSpacing.cxx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+// clitk
+#include "clitkGetSpacing_ggo.h"
+#include "clitkIO.h"
+#include "clitkGetSpacingGenericFilter.h"
+
+
+//--------------------------------------------------------------------
+int main(int argc, char * argv[]) {
+
+ // Init command line
+ GGO(clitkGetSpacing, args_info);
+ CLITK_INIT;
+
+ // Filter
+ clitk::GetSpacingGenericFilter::Pointer genericFilter=clitk::GetSpacingGenericFilter::New();
+
+ genericFilter->SetArgsInfo(args_info);
+ genericFilter->Update();
+
+ return EXIT_SUCCESS;
+}// end main
+
+//--------------------------------------------------------------------
--- /dev/null
+#File clitkGetSpacing.ggo
+Package "clitkGetSpacing"
+version "1.0"
+purpose ""
+
+option "config" - "Config file" string no
+option "verbose" v "Verbose" flag off
+
+option "input" i "Input image filename" string yes
+option "comma" o "Output comma separated values" flag off
+
+
--- /dev/null
+/*=========================================================================
+ 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 clitkGetSpacingGenericFilter_cxx
+#define clitkGetSpacingGenericFilter_cxx
+
+/* =================================================
+ * @file clitkGetSpacingGenericFilter.cxx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+#include "clitkGetSpacingGenericFilter.h"
+
+
+namespace clitk
+{
+
+
+ //-----------------------------------------------------------
+ // Constructor
+ //-----------------------------------------------------------
+ GetSpacingGenericFilter::GetSpacingGenericFilter()
+ {
+ m_Verbose=false;
+ m_InputFileName="";
+ }
+
+
+ //-----------------------------------------------------------
+ // Update
+ //-----------------------------------------------------------
+ void GetSpacingGenericFilter::Update()
+ {
+ // Read the Dimension and PixelType
+ int Dimension;
+ std::string PixelType;
+ ReadImageDimensionAndPixelType(m_InputFileName, Dimension, PixelType);
+
+
+ // Call UpdateWithDim
+ if(Dimension==2) UpdateWithDim<2>(PixelType);
+ else if(Dimension==3) UpdateWithDim<3>(PixelType);
+ else if (Dimension==4)UpdateWithDim<4>(PixelType);
+ else
+ {
+ std::cout<<"Error, Only for 2 or 3 or 4 Dimensions!!!"<<std::endl ;
+ return;
+ }
+ }
+
+
+} //end clitk
+
+#endif //#define clitkGetSpacingGenericFilter_cxx
--- /dev/null
+/*=========================================================================
+ 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 clitkGetSpacingGenericFilter_h
+#define clitkGetSpacingGenericFilter_h
+
+/* =================================================
+ * @file clitkGetSpacingGenericFilter.h
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+// clitk include
+#include "clitkIO.h"
+#include "clitkCommon.h"
+#include "clitkImageCommon.h"
+#include "clitkGetSpacing_ggo.h"
+
+//itk include
+#include "itkLightObject.h"
+
+namespace clitk
+{
+
+
+ class ITK_EXPORT GetSpacingGenericFilter : public itk::LightObject
+ {
+ public:
+ //----------------------------------------
+ // ITK
+ //----------------------------------------
+ typedef GetSpacingGenericFilter Self;
+ typedef itk::LightObject Superclass;
+ typedef itk::SmartPointer<Self> Pointer;
+ typedef itk::SmartPointer<const Self> ConstPointer;
+
+ // Method for creation through the object factory
+ itkNewMacro(Self);
+
+ // Run-time type information (and related methods)
+ itkTypeMacro( GetSpacingGenericFilter, LightObject );
+
+
+ //----------------------------------------
+ // Typedefs
+ //----------------------------------------
+
+
+ //----------------------------------------
+ // Set & Get
+ //----------------------------------------
+ void SetArgsInfo(const args_info_clitkGetSpacing & a)
+ {
+ m_ArgsInfo=a;
+ m_Verbose=m_ArgsInfo.verbose_flag;
+ m_InputFileName=m_ArgsInfo.input_arg;
+ }
+
+
+ //----------------------------------------
+ // Update
+ //----------------------------------------
+ void Update();
+
+ protected:
+
+ //----------------------------------------
+ // Constructor & Destructor
+ //----------------------------------------
+ GetSpacingGenericFilter();
+ ~GetSpacingGenericFilter() {};
+
+
+ //----------------------------------------
+ // Templated members
+ //----------------------------------------
+ template <unsigned int Dimension> void UpdateWithDim(std::string PixelType);
+ template <unsigned int Dimension, class PixelType> void UpdateWithDimAndPixelType();
+
+
+ //----------------------------------------
+ // Data members
+ //----------------------------------------
+ args_info_clitkGetSpacing m_ArgsInfo;
+ bool m_Verbose;
+ std::string m_InputFileName;
+
+ };
+
+
+} // end namespace clitk
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#include "clitkGetSpacingGenericFilter.txx"
+#endif
+
+#endif // #define clitkGetSpacingGenericFilter_h
--- /dev/null
+/*=========================================================================
+ 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 clitkGetSpacingGenericFilter_txx
+#define clitkGetSpacingGenericFilter_txx
+
+/* =================================================
+ * @file clitkGetSpacingGenericFilter.txx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+namespace clitk
+{
+
+ //-------------------------------------------------------------------
+ // Update with the number of dimensions
+ //-------------------------------------------------------------------
+ template<unsigned int Dimension>
+ void
+ GetSpacingGenericFilter::UpdateWithDim(std::string PixelType)
+ {
+ if (m_Verbose) std::cout << "Image was detected to be "<<Dimension<<"D and "<< PixelType<<"..."<<std::endl;
+
+ // if(PixelType == "short"){
+ // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed short..." << std::endl;
+ // UpdateWithDimAndPixelType<Dimension, signed short>();
+ // }
+ // else if(PixelType == "unsigned_short"){
+ // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_short..." << std::endl;
+ // UpdateWithDimAndPixelType<Dimension, unsigned short>();
+ // }
+
+ // else if (PixelType == "unsigned_char"){
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_char..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, unsigned char>();
+ // }
+
+ // else if (PixelType == "char"){
+ // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed_char..." << std::endl;
+ // UpdateWithDimAndPixelType<Dimension, signed char>();
+ // }
+ // else {
+ // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and float..." << std::endl;
+ // UpdateWithDimAndPixelType<Dimension, float>();
+ // }
+ }
+
+
+ //-------------------------------------------------------------------
+ // Update with the number of dimensions and the pixeltype
+ //-------------------------------------------------------------------
+ template <unsigned int Dimension, class PixelType>
+ void
+ GetSpacingGenericFilter::UpdateWithDimAndPixelType()
+ {
+
+ // ImageTypes
+ typedef itk::Image<PixelType, Dimension> InputImageType;
+ typedef itk::Image<PixelType, Dimension> OutputImageType;
+
+ // Read the input
+ typedef itk::ImageFileReader<InputImageType> InputReaderType;
+ typename InputReaderType::Pointer reader = InputReaderType::New();
+ reader->SetFileName( m_InputFileName);
+ reader->Update();
+ typename InputImageType::Pointer input= reader->GetOutput();
+
+ // Filter
+ typename InputImageType::SpacingType spacing=input->GetSpacing();
+ for(unsigned int i=0; i<Dimension-1; i++)
+ {
+ std::cout<<spacing[i];
+ if (!m_ArgsInfo.comma_flag)std::cout<<" ";
+ else std::cout<<",";
+ }
+ std::cout<<spacing[Dimension-1]<<std::endl;
+ }
+
+
+}//end clitk
+
+#endif //#define clitkGetSpacingGenericFilter_txx
--- /dev/null
+/*=========================================================================
+ 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 CLITKIMAGELOG_CXX
+#define CLITKIMAGELOG_CXX
+/**
+ =================================================
+ * @file clitkImageLog.cxx
+ * @author Jef Vandemeulebroucke <Jef@creatis.insa-lyon.fr>
+ * @date 04 April 2008 15:28:32
+ *
+ * @brief
+ *
+ * Take an inverse normalized log of the image intensity
+ =================================================*/
+
+// clitk include
+#include "clitkImageLog_ggo.h"
+#include "clitkIO.h"
+#include "clitkCommon.h"
+
+// itk include
+#include "itkImageFileReader.h"
+#include "itkImageFileWriter.h"
+#include "itkImageRegionIterator.h"
+
+int main(int argc, char * argv[]) {
+
+ // init command line
+ GGO(clitkImageLog, args_info);
+ CLITK_INIT;
+
+ typedef float PixelType;
+ const unsigned int Dimension=3;
+ typedef itk::Image<PixelType, Dimension> ImageType;
+ typedef itk::ImageFileReader<ImageType> ImageReaderType;
+ typedef itk::ImageFileWriter<ImageType> ImageWriterType;
+ typedef itk::ImageRegionIterator<ImageType> IteratorType;
+
+ //Read input
+ ImageReaderType::Pointer reader= ImageReaderType::New();
+ reader->SetFileName(args_info.input_arg);
+ reader->Update();
+ ImageType::Pointer input = reader->GetOutput();
+
+ //Create iterators
+ IteratorType pi (input, input->GetLargestPossibleRegion());
+ pi.GoToBegin();
+
+ PixelType max=std::numeric_limits<unsigned short>::max();
+
+ //Create output
+ while(!pi.IsAtEnd())
+ {
+ if (pi.Get()< 0)
+ {
+ pi.Set(0.);
+ }
+ else
+ {
+ pi.Set(-log((PixelType)(max-pi.Get()+1)/(PixelType)max));
+ }
+ ++pi;
+ }
+
+ ImageWriterType::Pointer writer= ImageWriterType::New();
+ writer->SetFileName(args_info.output_arg);
+ writer->SetInput(input);
+ writer->Update();
+ return 0;
+}
+
+
+
+#endif /* end #define CLITKIMAGELOG_CXX */
--- /dev/null
+# file clitkImageLog.ggo
+Package "clitk"
+version "Perform a inverse normalized log on the image"
+
+option "config" - "Config file" string no
+option "input" i "Input image filename" string yes
+option "output" o "Output image filename" string yes
+option "verbose" v "Verbose" flag off
+
--- /dev/null
+/*=========================================================================
+ 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 clitkImageMoment.cxx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+// clitk
+#include "clitkImageMoment_ggo.h"
+#include "clitkIO.h"
+#include "clitkImageMomentGenericFilter.h"
+
+
+//--------------------------------------------------------------------
+int main(int argc, char * argv[]) {
+
+ // Init command line
+ GGO(clitkImageMoment, args_info);
+ CLITK_INIT;
+
+ // Filter
+ clitk::ImageMomentGenericFilter::Pointer genericFilter=clitk::ImageMomentGenericFilter::New();
+
+ genericFilter->SetArgsInfo(args_info);
+ genericFilter->Update();
+
+ return EXIT_SUCCESS;
+}// end main
+
+//--------------------------------------------------------------------
--- /dev/null
+#File clitkImageMoment.ggo
+Package "clitkImageMoment"
+version "1.0"
+purpose "Calculate the image moment: the center of gravity"
+
+option "config" - "Config file" string no
+option "verbose" v "Verbose" flag off
+
+option "input" i "Input image filename" string yes
+option "center" c "Compute center of gravity" flag on
+option "second" s "Compute second order moments" flag off
+option "axes" a "Compute the principal axes" flag off
--- /dev/null
+/*=========================================================================
+ 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 clitkImageMomentGenericFilter_cxx
+#define clitkImageMomentGenericFilter_cxx
+
+/* =================================================
+ * @file clitkImageMomentGenericFilter.cxx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+#include "clitkImageMomentGenericFilter.h"
+
+
+namespace clitk
+{
+
+
+ //-----------------------------------------------------------
+ // Constructor
+ //-----------------------------------------------------------
+ ImageMomentGenericFilter::ImageMomentGenericFilter()
+ {
+ m_Verbose=false;
+ m_InputFileName="";
+ }
+
+
+ //-----------------------------------------------------------
+ // Update
+ //-----------------------------------------------------------
+ void ImageMomentGenericFilter::Update()
+ {
+ // Read the Dimension and PixelType
+ int Dimension;
+ std::string PixelType;
+ ReadImageDimensionAndPixelType(m_InputFileName, Dimension, PixelType);
+
+
+ // Call UpdateWithDim
+ if(Dimension==2) UpdateWithDim<2>(PixelType);
+ else if(Dimension==3) UpdateWithDim<3>(PixelType);
+ // else if (Dimension==4)UpdateWithDim<4>(PixelType);
+ else
+ {
+ std::cout<<"Error, Only for 2 or 3 Dimensions!!!"<<std::endl ;
+ return;
+ }
+ }
+
+
+} //end clitk
+
+#endif //#define clitkImageMomentGenericFilter_cxx
--- /dev/null
+/*=========================================================================
+ 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 clitkImageMomentGenericFilter_h
+#define clitkImageMomentGenericFilter_h
+
+/* =================================================
+ * @file clitkImageMomentGenericFilter.h
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+// clitk include
+#include "clitkIO.h"
+#include "clitkCommon.h"
+#include "clitkImageCommon.h"
+#include "clitkImageMoment_ggo.h"
+
+//itk include
+#include "itkLightObject.h"
+#include "itkImageMomentsCalculator.h"
+namespace clitk
+{
+
+
+ class ITK_EXPORT ImageMomentGenericFilter : public itk::LightObject
+ {
+ public:
+ //----------------------------------------
+ // ITK
+ //----------------------------------------
+ typedef ImageMomentGenericFilter Self;
+ typedef itk::LightObject Superclass;
+ typedef itk::SmartPointer<Self> Pointer;
+ typedef itk::SmartPointer<const Self> ConstPointer;
+
+ // Method for creation through the object factory
+ itkNewMacro(Self);
+
+ // Run-time type information (and related methods)
+ itkTypeMacro( ImageMomentGenericFilter, LightObject );
+
+
+ //----------------------------------------
+ // Typedefs
+ //----------------------------------------
+
+
+ //----------------------------------------
+ // Set & Get
+ //----------------------------------------
+ void SetArgsInfo(const args_info_clitkImageMoment & a)
+ {
+ m_ArgsInfo=a;
+ m_Verbose=m_ArgsInfo.verbose_flag;
+ m_InputFileName=m_ArgsInfo.input_arg;
+ }
+
+
+ //----------------------------------------
+ // Update
+ //----------------------------------------
+ void Update();
+
+ protected:
+
+ //----------------------------------------
+ // Constructor & Destructor
+ //----------------------------------------
+ ImageMomentGenericFilter();
+ ~ImageMomentGenericFilter() {};
+
+
+ //----------------------------------------
+ // Templated members
+ //----------------------------------------
+ template <unsigned int Dimension> void UpdateWithDim(std::string PixelType);
+ template <unsigned int Dimension, class PixelType> void UpdateWithDimAndPixelType();
+
+
+ //----------------------------------------
+ // Data members
+ //----------------------------------------
+ args_info_clitkImageMoment m_ArgsInfo;
+ bool m_Verbose;
+ std::string m_InputFileName;
+
+ };
+
+
+} // end namespace clitk
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#include "clitkImageMomentGenericFilter.txx"
+#endif
+
+#endif // #define clitkImageMomentGenericFilter_h
--- /dev/null
+/*=========================================================================
+ 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 clitkImageMomentGenericFilter_txx
+#define clitkImageMomentGenericFilter_txx
+
+/* =================================================
+ * @file clitkImageMomentGenericFilter.txx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+namespace clitk
+{
+
+ //-------------------------------------------------------------------
+ // Update with the number of dimensions
+ //-------------------------------------------------------------------
+ template<unsigned int Dimension>
+ void
+ ImageMomentGenericFilter::UpdateWithDim(std::string PixelType)
+ {
+ if (m_Verbose) std::cout << "Image was detected to be "<<Dimension<<"D and "<< PixelType<<"..."<<std::endl;
+
+ if(PixelType == "short"){
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed short..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, signed short>();
+ }
+ // else if(PixelType == "unsigned_short"){
+ // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_short..." << std::endl;
+ // UpdateWithDimAndPixelType<Dimension, unsigned short>();
+ // }
+
+ else if (PixelType == "unsigned_char"){
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_char..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, unsigned char>();
+ }
+
+ // else if (PixelType == "char"){
+ // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed_char..." << std::endl;
+ // UpdateWithDimAndPixelType<Dimension, signed char>();
+ // }
+ else {
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and float..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, float>();
+ }
+ }
+
+
+ //-------------------------------------------------------------------
+ // Update with the number of dimensions and the pixeltype
+ //-------------------------------------------------------------------
+ template <unsigned int Dimension, class PixelType>
+ void
+ ImageMomentGenericFilter::UpdateWithDimAndPixelType()
+ {
+
+ // ImageTypes
+ typedef itk::Image<PixelType, Dimension> InputImageType;
+
+ // Read the input
+ typedef itk::ImageFileReader<InputImageType> InputReaderType;
+ typename InputReaderType::Pointer reader = InputReaderType::New();
+ reader->SetFileName( m_InputFileName);
+ reader->Update();
+ typename InputImageType::Pointer input= reader->GetOutput();
+
+ // Filter
+ typedef itk::ImageMomentsCalculator<InputImageType> MomentsCalculatorType;
+ typename MomentsCalculatorType::Pointer momentsCalculator=MomentsCalculatorType::New();
+ momentsCalculator->SetImage(input);
+ momentsCalculator->Compute();
+ if (m_ArgsInfo.center_flag)
+ {
+ if (m_Verbose) std::cout<<"The center of gravity is located at (mm) "<<std::endl;
+ typename itk::Vector<double,Dimension> center=momentsCalculator->GetCenterOfGravity();
+ std::cout<<center[0];
+ for (unsigned int i=1; i<Dimension;i++)
+ std::cout<<" "<<center[i];
+ std::cout<<std::endl;
+ }
+ if (m_ArgsInfo.second_flag)
+ {
+ if (m_Verbose) std::cout<<"The second order central moments are (mm) "<<std::endl;
+ std::cout<<momentsCalculator->GetCentralMoments()<<std::endl;
+ }
+ if (m_ArgsInfo.axes_flag)
+ {
+ if (m_Verbose) std::cout<<"The principal axes are (mm) "<<std::endl;
+ std::cout<<momentsCalculator->GetPrincipalAxes()<<std::endl;
+ }
+
+ }
+
+
+}//end clitk
+
+#endif //#define clitkImageMomentGenericFilter_txx
--- /dev/null
+/*=========================================================================
+ 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 clitkImageStatistics.cxx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+// clitk
+#include "clitkImageStatistics_ggo.h"
+#include "clitkIO.h"
+#include "clitkImageStatisticsGenericFilter.h"
+
+
+//--------------------------------------------------------------------
+int main(int argc, char * argv[]) {
+
+ // Init command line
+ GGO(clitkImageStatistics, args_info);
+ CLITK_INIT;
+
+ // Filter
+ clitk::ImageStatisticsGenericFilter::Pointer genericFilter=clitk::ImageStatisticsGenericFilter::New();
+
+ genericFilter->SetArgsInfo(args_info);
+ genericFilter->Update();
+
+ return EXIT_SUCCESS;
+}// end main
+
+//--------------------------------------------------------------------
--- /dev/null
+#File clitkImageStatistics.ggo
+Package "clitkImageStatistics"
+version "1.0"
+purpose "Compute statistics on an image, or on part of an image specified by a mask and label(s)"
+
+option "config" - "Config file" string no
+option "verbose" v "Verbose" flag off
+
+option "input" i "Input image filename" string yes
+option "mask" m "Mask image filename (uchar)" string no
+option "label" l "Label(s) in the mask image to consider" int no multiple default="1"
+option "histogram" - "Compute histogram, allows median calculation" string no
+option "bins" - "Number of histogram bins" int no default="100"
+option "lower" - "Lower histogram bound" double no default="-1000"
+option "upper" - "Upper histogram bound" double no default="1000"
--- /dev/null
+/*=========================================================================
+ 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 clitkImageStatisticsGenericFilter_cxx
+#define clitkImageStatisticsGenericFilter_cxx
+
+/* =================================================
+ * @file clitkImageStatisticsGenericFilter.cxx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+#include "clitkImageStatisticsGenericFilter.h"
+
+
+namespace clitk
+{
+
+
+ //-----------------------------------------------------------
+ // Constructor
+ //-----------------------------------------------------------
+ ImageStatisticsGenericFilter::ImageStatisticsGenericFilter()
+ {
+ m_Verbose=false;
+ m_InputFileName="";
+ }
+
+
+ //-----------------------------------------------------------
+ // Update
+ //-----------------------------------------------------------
+ void ImageStatisticsGenericFilter::Update()
+ {
+ // Read the Dimension and PixelType
+ int Dimension;
+ std::string PixelType;
+ ReadImageDimensionAndPixelType(m_InputFileName, Dimension, PixelType);
+
+
+ // Call UpdateWithDim
+ if(Dimension==2) UpdateWithDim<2>(PixelType);
+ else if(Dimension==3) UpdateWithDim<3>(PixelType);
+ // else if (Dimension==4)UpdateWithDim<4>(PixelType);
+ else
+ {
+ std::cout<<"Error, Only for 2 or 3 Dimensions!!!"<<std::endl ;
+ return;
+ }
+ }
+
+
+} //end clitk
+
+#endif //#define clitkImageStatisticsGenericFilter_cxx
--- /dev/null
+/*=========================================================================
+ 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 clitkImageStatisticsGenericFilter_h
+#define clitkImageStatisticsGenericFilter_h
+
+/* =================================================
+ * @file clitkImageStatisticsGenericFilter.h
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+// clitk include
+#include "clitkIO.h"
+#include "clitkCommon.h"
+#include "clitkImageCommon.h"
+#include "clitkImageStatistics_ggo.h"
+
+//itk include
+#include "itkLightObject.h"
+#include "itkLabelStatisticsImageFilter.h"
+
+namespace clitk
+{
+
+
+ class ITK_EXPORT ImageStatisticsGenericFilter : public itk::LightObject
+ {
+ public:
+ //----------------------------------------
+ // ITK
+ //----------------------------------------
+ typedef ImageStatisticsGenericFilter Self;
+ typedef itk::LightObject Superclass;
+ typedef itk::SmartPointer<Self> Pointer;
+ typedef itk::SmartPointer<const Self> ConstPointer;
+
+ // Method for creation through the object factory
+ itkNewMacro(Self);
+
+ // Run-time type information (and related methods)
+ itkTypeMacro( ImageStatisticsGenericFilter, LightObject );
+
+
+ //----------------------------------------
+ // Typedefs
+ //----------------------------------------
+
+
+ //----------------------------------------
+ // Set & Get
+ //----------------------------------------
+ void SetArgsInfo(const args_info_clitkImageStatistics & a)
+ {
+ m_ArgsInfo=a;
+ m_Verbose=m_ArgsInfo.verbose_flag;
+ m_InputFileName=m_ArgsInfo.input_arg;
+ }
+
+
+ //----------------------------------------
+ // Update
+ //----------------------------------------
+ void Update();
+
+ protected:
+
+ //----------------------------------------
+ // Constructor & Destructor
+ //----------------------------------------
+ ImageStatisticsGenericFilter();
+ ~ImageStatisticsGenericFilter() {};
+
+
+ //----------------------------------------
+ // Templated members
+ //----------------------------------------
+ template <unsigned int Dimension> void UpdateWithDim(std::string PixelType);
+ template <unsigned int Dimension, class PixelType> void UpdateWithDimAndPixelType();
+
+
+ //----------------------------------------
+ // Data members
+ //----------------------------------------
+ args_info_clitkImageStatistics m_ArgsInfo;
+ bool m_Verbose;
+ std::string m_InputFileName;
+
+ };
+
+
+} // end namespace clitk
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#include "clitkImageStatisticsGenericFilter.txx"
+#endif
+
+#endif // #define clitkImageStatisticsGenericFilter_h
--- /dev/null
+/*=========================================================================
+ 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 clitkImageStatisticsGenericFilter_txx
+#define clitkImageStatisticsGenericFilter_txx
+
+/* =================================================
+ * @file clitkImageStatisticsGenericFilter.txx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+namespace clitk
+{
+
+ //-------------------------------------------------------------------
+ // Update with the number of dimensions
+ //-------------------------------------------------------------------
+ template<unsigned int Dimension>
+ void
+ ImageStatisticsGenericFilter::UpdateWithDim(std::string PixelType)
+ {
+ if (m_Verbose) std::cout << "Image was detected to be "<<Dimension<<"D and "<< PixelType<<"..."<<std::endl;
+
+ if(PixelType == "short"){
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed short..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, signed short>();
+ }
+ // else if(PixelType == "unsigned_short"){
+ // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_short..." << std::endl;
+ // UpdateWithDimAndPixelType<Dimension, unsigned short>();
+ // }
+
+ else if (PixelType == "unsigned_char"){
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_char..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, unsigned char>();
+ }
+
+ // else if (PixelType == "char"){
+ // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed_char..." << std::endl;
+ // UpdateWithDimAndPixelType<Dimension, signed char>();
+ // }
+ else {
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and float..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, float>();
+ }
+ }
+
+
+ //-------------------------------------------------------------------
+ // Update with the number of dimensions and the pixeltype
+ //-------------------------------------------------------------------
+ template <unsigned int Dimension, class PixelType>
+ void
+ ImageStatisticsGenericFilter::UpdateWithDimAndPixelType()
+ {
+
+ // ImageTypes
+ typedef itk::Image<PixelType, Dimension> InputImageType;
+ typedef itk::Image<unsigned int, Dimension> LabelImageType;
+ typedef itk::Image<PixelType, Dimension> OutputImageType;
+
+ // Read the input
+ typedef itk::ImageFileReader<InputImageType> InputReaderType;
+ typename InputReaderType::Pointer reader = InputReaderType::New();
+ reader->SetFileName( m_InputFileName);
+ reader->Update();
+ typename InputImageType::Pointer input= reader->GetOutput();
+
+ // Filter
+ typedef itk::LabelStatisticsImageFilter<InputImageType, LabelImageType> StatisticsImageFilterType;
+ typename StatisticsImageFilterType::Pointer statisticsFilter=StatisticsImageFilterType::New();
+ statisticsFilter->SetInput(input);
+
+ // Label image
+ typename LabelImageType::Pointer labelImage;
+ if (m_ArgsInfo.mask_given)
+ {
+ typedef itk::ImageFileReader<LabelImageType> LabelImageReaderType;
+ typename LabelImageReaderType::Pointer labelImageReader=LabelImageReaderType::New();
+ labelImageReader->SetFileName(m_ArgsInfo.mask_arg);
+ labelImageReader->Update();
+ labelImage= labelImageReader->GetOutput();
+ }
+ else
+ {
+ labelImage=LabelImageType::New();
+ labelImage->SetRegions(input->GetLargestPossibleRegion());
+ labelImage->SetOrigin(input->GetOrigin());
+ labelImage->SetSpacing(input->GetSpacing());
+ labelImage->Allocate();
+ labelImage->FillBuffer(m_ArgsInfo.label_arg[0]);
+ }
+ statisticsFilter->SetLabelInput(labelImage);
+
+ // For each Label
+ typename LabelImageType::PixelType label;
+ unsigned int numberOfLabels;
+ if (m_ArgsInfo.label_given)
+ numberOfLabels=m_ArgsInfo.label_given;
+ else
+ numberOfLabels=1;
+
+ for (unsigned int k=0; k< numberOfLabels; k++)
+ {
+ label=m_ArgsInfo.label_arg[k];
+
+ std::cout<<std::endl;
+ if (m_Verbose) std::cout<<"-------------"<<std::endl;
+ if (m_Verbose) std::cout<<"| Label: "<<label<<" |"<<std::endl;
+ if (m_Verbose) std::cout<<"-------------"<<std::endl;
+
+ // Histograms
+ if (m_ArgsInfo.histogram_given)
+ {
+ statisticsFilter->SetUseHistograms(true);
+ statisticsFilter->SetHistogramParameters(m_ArgsInfo.bins_arg, m_ArgsInfo.lower_arg, m_ArgsInfo.upper_arg);
+ }
+ statisticsFilter->Update();
+
+
+ // Output
+ if (m_Verbose) std::cout<<"N° of pixels: ";
+ std::cout<<statisticsFilter->GetCount(label)<<std::endl;
+
+ if (m_Verbose) std::cout<<"Mean: ";
+ std::cout<<statisticsFilter->GetMean(label)<<std::endl;
+
+ if (m_Verbose) std::cout<<"SD: ";
+ std::cout<<statisticsFilter->GetSigma(label)<<std::endl;
+
+ if (m_Verbose) std::cout<<"Variance: ";
+ std::cout<<statisticsFilter->GetVariance(label)<<std::endl;
+
+ if (m_Verbose) std::cout<<"Min: ";
+ std::cout<<statisticsFilter->GetMinimum(label)<<std::endl;
+
+ if (m_Verbose) std::cout<<"Max: ";
+ std::cout<<statisticsFilter->GetMaximum(label)<<std::endl;
+
+ if (m_Verbose) std::cout<<"Sum: ";
+ std::cout<<statisticsFilter->GetSum(label)<<std::endl;
+
+ if (m_Verbose) std::cout<<"Bounding box: ";
+ for(unsigned int i =0; i <statisticsFilter->GetBoundingBox(label).size(); i++)
+ std::cout<<statisticsFilter->GetBoundingBox(label)[i]<<" ";
+ std::cout<<std::endl;
+
+
+ // Histogram
+ if (m_ArgsInfo.histogram_given)
+ {
+ if (m_Verbose) std::cout<<"Median: ";
+ std::cout<<statisticsFilter->GetMedian(label)<<std::endl;
+
+ typename StatisticsImageFilterType::HistogramPointer histogram =statisticsFilter->GetHistogram(label);
+
+ // Screen
+ if (m_Verbose) std::cout<<"Histogram: "<<std::endl;
+ std::cout<<"# MinBin\tMidBin\tMaxBin\tFrequency"<<std::endl;
+ for( int i =0; i <m_ArgsInfo.bins_arg; i++)
+ std::cout<<histogram->GetBinMin(0,i)<<"\t"<<histogram->GetMeasurement(i,0)<<"\t"<<histogram->GetBinMax(0,i)<<"\t"<<histogram->GetFrequency(i)<<std::endl;
+
+ // Add to the file
+ std::ofstream histogramFile(m_ArgsInfo.histogram_arg);
+ histogramFile<<"#Histogram: "<<std::endl;
+ histogramFile<<"#MinBin\tMidBin\tMaxBin\tFrequency"<<std::endl;
+ for( int i =0; i <m_ArgsInfo.bins_arg; i++)
+ histogramFile<<histogram->GetBinMin(0,i)<<"\t"<<histogram->GetMeasurement(i,0)<<"\t"<<histogram->GetBinMax(0,i)<<"\t"<<histogram->GetFrequency(i)<<std::endl;
+ }
+ }
+
+ return;
+
+ }
+
+
+}//end clitk
+
+#endif //#define clitkImageStatisticsGenericFilter_txx
--- /dev/null
+/*=========================================================================
+ 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 clitkImageToVectorImage.cxx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+// clitk
+#include "clitkImageToVectorImage_ggo.h"
+#include "clitkIO.h"
+#include "clitkImageToVectorImageGenericFilter.h"
+
+
+//--------------------------------------------------------------------
+int main(int argc, char * argv[]) {
+
+ // Init command line
+ GGO(clitkImageToVectorImage, args_info);
+ CLITK_INIT;
+
+ // Filter
+ clitk::ImageToVectorImageGenericFilter::Pointer genericFilter=clitk::ImageToVectorImageGenericFilter::New();
+
+ genericFilter->SetArgsInfo(args_info);
+ genericFilter->Update();
+
+ return EXIT_SUCCESS;
+}// end main
+
+//--------------------------------------------------------------------
--- /dev/null
+#File clitkImageToVectorImage.ggo
+Package "clitkImageToVectorImage"
+version "1.0"
+purpose "Compose 3 images to 1 vector image"
+
+option "config" - "Config file" string no
+option "verbose" v "Verbose" flag off
+
+option "output" o "Output image filename" string yes
+
+
--- /dev/null
+/*=========================================================================
+ 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 clitkImageToVectorImageGenericFilter_cxx
+#define clitkImageToVectorImageGenericFilter_cxx
+
+/* =================================================
+ * @file clitkImageToVectorImageGenericFilter.cxx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+#include "clitkImageToVectorImageGenericFilter.h"
+
+
+namespace clitk
+{
+
+
+ //-----------------------------------------------------------
+ // Constructor
+ //-----------------------------------------------------------
+ ImageToVectorImageGenericFilter::ImageToVectorImageGenericFilter()
+ {
+ m_Verbose=false;
+ m_InputFileName="";
+ }
+
+
+ //-----------------------------------------------------------
+ // Update
+ //-----------------------------------------------------------
+ void ImageToVectorImageGenericFilter::Update()
+ {
+ // Read the Dimension and PixelType
+ int Dimension;
+ std::string PixelType;
+ ReadImageDimensionAndPixelType(m_InputFileName, Dimension, PixelType);
+
+
+ // Call UpdateWithDim
+ if(Dimension==2) UpdateWithDim<2>(PixelType);
+ else if(Dimension==3) UpdateWithDim<3>(PixelType);
+ else if (Dimension==4)UpdateWithDim<4>(PixelType);
+ else
+ {
+ std::cout<<"Error, Only for 2 or 3 Dimensions!!!"<<std::endl ;
+ return;
+ }
+ }
+
+
+} //end clitk
+
+#endif //#define clitkImageToVectorImageGenericFilter_cxx
--- /dev/null
+/*=========================================================================
+ 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 clitkImageToVectorImageGenericFilter_h
+#define clitkImageToVectorImageGenericFilter_h
+
+/* =================================================
+ * @file clitkImageToVectorImageGenericFilter.h
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+// clitk include
+#include "clitkIO.h"
+#include "clitkCommon.h"
+#include "clitkImageCommon.h"
+#include "clitkImageToVectorImage_ggo.h"
+
+//itk include
+#include "itkLightObject.h"
+#include "itkCompose3DVectorImageFilter.h"
+
+namespace clitk
+{
+
+
+ class ITK_EXPORT ImageToVectorImageGenericFilter : public itk::LightObject
+ {
+ public:
+ //----------------------------------------
+ // ITK
+ //----------------------------------------
+ typedef ImageToVectorImageGenericFilter Self;
+ typedef itk::LightObject Superclass;
+ typedef itk::SmartPointer<Self> Pointer;
+ typedef itk::SmartPointer<const Self> ConstPointer;
+
+ // Method for creation through the object factory
+ itkNewMacro(Self);
+
+ // Run-time type information (and related methods)
+ itkTypeMacro( ImageToVectorImageGenericFilter, LightObject );
+
+
+ //----------------------------------------
+ // Typedefs
+ //----------------------------------------
+
+
+ //----------------------------------------
+ // Set & Get
+ //----------------------------------------
+ void SetArgsInfo(const args_info_clitkImageToVectorImage & a)
+ {
+ m_ArgsInfo=a;
+ m_Verbose=m_ArgsInfo.verbose_flag;
+ m_InputFileName=m_ArgsInfo.inputs[0];
+ }
+
+
+ //----------------------------------------
+ // Update
+ //----------------------------------------
+ void Update();
+
+ protected:
+
+ //----------------------------------------
+ // Constructor & Destructor
+ //----------------------------------------
+ ImageToVectorImageGenericFilter();
+ ~ImageToVectorImageGenericFilter() {};
+
+
+ //----------------------------------------
+ // Templated members
+ //----------------------------------------
+ template <unsigned int Dimension> void UpdateWithDim(std::string PixelType);
+ template <unsigned int Dimension, class PixelType> void UpdateWithDimAndPixelType();
+
+
+ //----------------------------------------
+ // Data members
+ //----------------------------------------
+ args_info_clitkImageToVectorImage m_ArgsInfo;
+ bool m_Verbose;
+ std::string m_InputFileName;
+
+ };
+
+
+} // end namespace clitk
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#include "clitkImageToVectorImageGenericFilter.txx"
+#endif
+
+#endif // #define clitkImageToVectorImageGenericFilter_h
--- /dev/null
+/*=========================================================================
+ 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 clitkImageToVectorImageGenericFilter_txx
+#define clitkImageToVectorImageGenericFilter_txx
+
+/* =================================================
+ * @file clitkImageToVectorImageGenericFilter.txx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+namespace clitk
+{
+
+ //-------------------------------------------------------------------
+ // Update with the number of dimensions
+ //-------------------------------------------------------------------
+ template<unsigned int Dimension>
+ void
+ ImageToVectorImageGenericFilter::UpdateWithDim(std::string PixelType)
+ {
+ if (m_Verbose) std::cout << "Image was detected to be "<<Dimension<<"D and "<< PixelType<<"..."<<std::endl;
+
+ if(PixelType == "short"){
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed short..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, signed short>();
+ }
+ // else if(PixelType == "unsigned_short"){
+ // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_short..." << std::endl;
+ // UpdateWithDimAndPixelType<Dimension, unsigned short>();
+ // }
+
+ else if (PixelType == "unsigned_char"){
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_char..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, unsigned char>();
+ }
+
+ // else if (PixelType == "char"){
+ // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed_char..." << std::endl;
+ // UpdateWithDimAndPixelType<Dimension, signed char>();
+ // }
+ else {
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and float..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, float>();
+ }
+ }
+
+
+ //-------------------------------------------------------------------
+ // Update with the number of dimensions and the pixeltype
+ //-------------------------------------------------------------------
+ template <unsigned int Dimension, class PixelType>
+ void
+ ImageToVectorImageGenericFilter::UpdateWithDimAndPixelType()
+ {
+
+ // ImageTypes
+ typedef itk::Image<PixelType, Dimension> InputImageType;
+ typedef itk::Image<itk::Vector<PixelType,3>, Dimension> OutputImageType;
+
+ // Filter
+ typedef itk::Compose3DVectorImageFilter<InputImageType,OutputImageType> ComposeFilterType;
+ typename ComposeFilterType::Pointer composeFilter=ComposeFilterType::New();
+
+ // Read the inputs
+ typedef itk::ImageFileReader<InputImageType> InputReaderType;
+ for (unsigned int i=0; i<3;i++)
+ {
+ typename InputReaderType::Pointer reader = InputReaderType::New();
+ reader->SetFileName( m_ArgsInfo.inputs[i]);
+ reader->Update();
+ composeFilter->SetInput(i, reader->GetOutput());
+ }
+ composeFilter->Update();
+ typename OutputImageType::Pointer output = composeFilter->GetOutput();
+
+ // Output
+ typedef itk::ImageFileWriter<OutputImageType> WriterType;
+ typename WriterType::Pointer writer = WriterType::New();
+ writer->SetFileName(m_ArgsInfo.output_arg);
+ writer->SetInput(output);
+ writer->Update();
+
+ }
+
+
+}//end clitk
+
+#endif //#define clitkImageToVectorImageGenericFilter_txx
Program: clitk
Module: $RCSfile: clitkMedianImageGenericFilter.h,v $
Language: C++
- Date: $Date: 2010/04/09 09:50:04 $
+ Date: $Date: 2010/07/23 14:56:21 $
Version: $Revision: 1.1 $
Author : Bharath Navalpakkam <Bharath.Navalpakkam@creatis.insa-lyon.fr>
Copyright (C) 2010
--- /dev/null
+/*=========================================================================
+ 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 CLITKMERGESEQUENCE_CXX
+#define CLITKMERGESEQUENCE_CXX
+
+/**
+ * @file clitkMergeSequence.cxx
+ * @author Jef Vandemeulebroucke <jefvdmb@gmail.com>
+ * @date December 2 10:14:53 2008
+ *
+ * @brief Read in one VF (ex mhd, vf) invert it using a splat with linear kernels to the target.
+ *
+ */
+
+// clitk include
+#include "clitkMergeSequence_ggo.h"
+#include "clitkIO.h"
+#include "clitkImageCommon.h"
+#include "clitkMergeSequenceGenericFilter.h"
+
+int main( int argc, char *argv[] )
+{
+
+ // Init command line
+ GGO(clitkMergeSequence, args_info);
+ CLITK_INIT;
+
+ //Creation of the generic filter
+ clitk::MergeSequenceGenericFilter::Pointer MergeSequenceGenericFilter= clitk::MergeSequenceGenericFilter::New();
+
+ //Pass the parameters
+ std::vector<std::string> names;
+ for(unsigned int i=0; i<args_info.inputs_num;i++)names.push_back(args_info.inputs[i]);
+ MergeSequenceGenericFilter->SetInputs(names);
+ MergeSequenceGenericFilter->SetSpacing(args_info.spacing_arg);
+ MergeSequenceGenericFilter->SetOutput(args_info.output_arg);
+ MergeSequenceGenericFilter->SetVerbose(args_info.verbose_flag);
+
+ //update
+ MergeSequenceGenericFilter->Update();
+ return EXIT_SUCCESS;
+}
+#endif
+
+
--- /dev/null
+#File clitkMergeSequence.ggo
+#Author: Jef Vandemeulebroucke <jefvdmb@gmail.com>
+#Date : Tue 15 June 16.35
+
+Package "clitk"
+Version "Read a series a nD images (unnamed inputs) and merge them to a (n+1)D image"
+
+option "config" - "Config file" string no
+option "spacing" s "Spacing for the new dimension" double no default="1"
+option "output" o "Output VF filename" string yes
+option "verbose" v "Verbose" flag off
+
--- /dev/null
+/*=========================================================================
+ 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 CLITKMERGESEQUENCEGENERICFILTER_CXX
+#define CLITKMERGESEQUENCEGENERICFILTER_CXX
+#include "clitkMergeSequenceGenericFilter.h"
+
+
+namespace clitk {
+
+ clitk::MergeSequenceGenericFilter::MergeSequenceGenericFilter()
+ {
+ m_Verbose=false;
+ m_Spacing=1;
+ }
+
+
+ void clitk::MergeSequenceGenericFilter::Update()
+ {
+ //Get the image Dimension and PixelType
+ int Dimension, Components;
+ std::string PixelType;
+
+ clitk::ReadImageDimensionAndPixelType(m_InputNames[0], Dimension, PixelType, Components);
+
+ if(Dimension==2) UpdateWithDim<2>(PixelType, Components);
+ else if(Dimension==3) UpdateWithDim<3>(PixelType, Components);
+ else
+ {
+ std::cout<<"Error, Only for 2 and 3 Dimensions!!!"<<std::endl ;
+ return;
+ }
+ }
+} //end namespace
+
+#endif
--- /dev/null
+/*=========================================================================
+ 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 __clitkMergeSequenceGenericFilter_h
+#define __clitkMergeSequenceGenericFilter_h
+#include "clitkImageCommon.h"
+#include "clitkImageCommon.h"
+
+//itk include
+#include "itkLightObject.h"
+#include "itkImage.h"
+#include "itkImageSeriesReader.h"
+
+
+namespace clitk
+{
+
+ class ITK_EXPORT MergeSequenceGenericFilter : public itk::LightObject
+
+ {
+ public:
+ typedef MergeSequenceGenericFilter Self;
+ typedef itk::LightObject Superclass;
+ typedef itk::SmartPointer<Self> Pointer;
+ typedef itk::SmartPointer<const Self> ConstPointer;
+
+ /** Method for creation through the object factory. */
+ itkNewMacro(Self);
+
+ //Set Methods (inline)
+ void SetInputs(const std::vector<std::string> m){m_InputNames=m;}
+ void SetSpacing(const double m){m_Spacing=m;}
+ void SetOutput(const std::string m){m_OutputName=m;}
+ void SetVerbose(const bool m){m_Verbose=m;}
+
+ //Update
+ void Update( );
+
+
+ protected:
+
+ MergeSequenceGenericFilter();
+ ~MergeSequenceGenericFilter() {};
+
+ //Templated members
+ template<unsigned int Dimension> void UpdateWithDim(std::string PixelType, unsigned int Components);
+ template<unsigned int Dimension, class PixelType> void UpdateWithDimAndPixelType();
+
+ std::vector<std::string> m_InputNames;
+ double m_Spacing;
+ std::string m_OutputName;
+ bool m_Verbose;
+
+};
+
+
+} // end namespace clitk
+#ifndef ITK_MANUAL_INSTANTIATION
+#include "clitkMergeSequenceGenericFilter.txx"
+#endif
+
+#endif // #define __clitkMergeSequenceGenericFilter_h
--- /dev/null
+/*=========================================================================
+ 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 __clitkMergeSequenceGenericFilter_txx
+#define __clitkMergeSequenceGenericFilter_txx
+#include "clitkMergeSequenceGenericFilter.h"
+
+
+namespace clitk
+{
+ template<unsigned int Dimension>
+ void MergeSequenceGenericFilter::UpdateWithDim(std::string PixelType, unsigned int Components)
+ {
+
+ if (m_Verbose) std::cout << "Image was detected to be "<<Dimension<<"D and "<<Components<<" component(s) of "<< PixelType<<"..."<<std::endl;
+
+ if (Components==1)
+ {
+ if(PixelType == "short"){
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed short..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, signed short>();
+ }
+ // else if(PixelType == "unsigned_short"){
+ // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_short..." << std::endl;
+ // UpdateWithDimAndPixelType<Dimension, unsigned short>();
+ // }
+
+ else if (PixelType == "unsigned_char"){
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_char..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, unsigned char>();
+ }
+
+ // else if (PixelType == "char"){
+ // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed_char..." << std::endl;
+ // UpdateWithDimAndPixelType<Dimension, signed char>();
+ // }
+ else {
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and float..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, float>();
+ }
+ }
+
+ else if (Components==3)
+ {
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and 3D float (DVF)" << std::endl;
+ UpdateWithDimAndPixelType<Dimension, itk::Vector<float, 3> >();
+ }
+
+ else std::cerr<<"Number of components is "<<Components<<", not supported!"<<std::endl;
+
+ }
+
+
+ template<unsigned int Dimension, class PixelType >
+ void MergeSequenceGenericFilter::UpdateWithDimAndPixelType()
+ {
+
+ //Define the input and output image type
+ typedef itk::Image<PixelType, Dimension> InputImageType;
+ typedef itk::Image<PixelType, Dimension+1> OutputImageType;
+
+ //Read the input image series
+ typedef itk::ImageSeriesReader<OutputImageType> ImageReaderType;
+ typename ImageReaderType::Pointer reader= ImageReaderType::New();
+ reader->SetFileNames(m_InputNames);
+ reader->Update();
+ typename OutputImageType::Pointer image =reader->GetOutput();
+
+ //Set the spacing
+ typename OutputImageType::SpacingType spacing=image->GetSpacing();
+ spacing[Dimension]=m_Spacing;
+ image->SetSpacing(spacing);
+
+ //Write the output
+ typedef itk::ImageFileWriter<OutputImageType> WriterType;
+ typename WriterType::Pointer writer = WriterType::New();
+ writer->SetFileName(m_OutputName);
+ writer->SetInput(reader->GetOutput());
+ writer->Update();
+
+ }
+
+
+}
+
+#endif
+
--- /dev/null
+/*=========================================================================
+ 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 clitkMirrorPadImage.cxx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+// clitk
+#include "clitkMirrorPadImage_ggo.h"
+#include "clitkIO.h"
+#include "clitkMirrorPadImageGenericFilter.h"
+
+
+//--------------------------------------------------------------------
+int main(int argc, char * argv[]) {
+
+ // Init command line
+ GGO(clitkMirrorPadImage, args_info);
+ CLITK_INIT;
+
+ // Filter
+ clitk::MirrorPadImageGenericFilter::Pointer genericFilter=clitk::MirrorPadImageGenericFilter::New();
+
+ genericFilter->SetArgsInfo(args_info);
+ genericFilter->Update();
+
+ return EXIT_SUCCESS;
+}// end main
+
+//--------------------------------------------------------------------
--- /dev/null
+#File clitkMirrorPadImage.ggo
+Package "clitkMirrorPadImage"
+version "1.0"
+purpose ""
+
+option "config" - "Config file" string no
+option "verbose" v "Verbose" flag off
+
+option "input" i "Input image filename" string yes
+option "output" o "Output image filename" string yes
+option "mirror" m "Mirror the entire image along given axis" int no
+option "pad" p "Mirror pad with given size" int multiple no
+option "lower" l "Pad on lower end (else upper)" flag off
+option "origin" - "Set new origin to 0" flag off
--- /dev/null
+/*=========================================================================
+ 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 clitkMirrorPadImageGenericFilter_cxx
+#define clitkMirrorPadImageGenericFilter_cxx
+
+/* =================================================
+ * @file clitkMirrorPadImageGenericFilter.cxx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+#include "clitkMirrorPadImageGenericFilter.h"
+
+
+namespace clitk
+{
+
+
+ //-----------------------------------------------------------
+ // Constructor
+ //-----------------------------------------------------------
+ MirrorPadImageGenericFilter::MirrorPadImageGenericFilter()
+ {
+ m_Verbose=false;
+ m_InputFileName="";
+ }
+
+
+ //-----------------------------------------------------------
+ // Update
+ //-----------------------------------------------------------
+ void MirrorPadImageGenericFilter::Update()
+ {
+ // Read the Dimension and PixelType
+ int Dimension;
+ std::string PixelType;
+ ReadImageDimensionAndPixelType(m_InputFileName, Dimension, PixelType);
+
+
+ // Call UpdateWithDim
+ if(Dimension==2) UpdateWithDim<2>(PixelType);
+ else if(Dimension==3) UpdateWithDim<3>(PixelType);
+ // else if (Dimension==4)UpdateWithDim<4>(PixelType);
+ else
+ {
+ std::cout<<"Error, Only for 2 or 3 Dimensions!!!"<<std::endl ;
+ return;
+ }
+ }
+
+
+} //end clitk
+
+#endif //#define clitkMirrorPadImageGenericFilter_cxx
--- /dev/null
+/*=========================================================================
+ 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 clitkMirrorPadImageGenericFilter_h
+#define clitkMirrorPadImageGenericFilter_h
+
+/* =================================================
+ * @file clitkMirrorPadImageGenericFilter.h
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+// clitk include
+#include "clitkIO.h"
+#include "clitkCommon.h"
+#include "clitkImageCommon.h"
+#include "clitkMirrorPadImage_ggo.h"
+
+//itk include
+#include "itkLightObject.h"
+#include "itkMirrorPadImageFilter.h"
+
+namespace clitk
+{
+
+ class ITK_EXPORT MirrorPadImageGenericFilter : public itk::LightObject
+ {
+ public:
+ //----------------------------------------
+ // ITK
+ //----------------------------------------
+ typedef MirrorPadImageGenericFilter Self;
+ typedef itk::LightObject Superclass;
+ typedef itk::SmartPointer<Self> Pointer;
+ typedef itk::SmartPointer<const Self> ConstPointer;
+
+ // Method for creation through the object factory
+ itkNewMacro(Self);
+
+ // Run-time type information (and related methods)
+ itkTypeMacro( MirrorPadImageGenericFilter, LightObject );
+
+
+ //----------------------------------------
+ // Typedefs
+ //----------------------------------------
+
+
+ //----------------------------------------
+ // Set & Get
+ //----------------------------------------
+ void SetArgsInfo(const args_info_clitkMirrorPadImage & a)
+ {
+ m_ArgsInfo=a;
+ m_Verbose=m_ArgsInfo.verbose_flag;
+ m_InputFileName=m_ArgsInfo.input_arg;
+ }
+
+
+ //----------------------------------------
+ // Update
+ //----------------------------------------
+ void Update();
+
+ protected:
+
+ //----------------------------------------
+ // Constructor & Destructor
+ //----------------------------------------
+ MirrorPadImageGenericFilter();
+ ~MirrorPadImageGenericFilter() {};
+
+
+ //----------------------------------------
+ // Templated members
+ //----------------------------------------
+ template <unsigned int Dimension> void UpdateWithDim(std::string PixelType);
+ template <unsigned int Dimension, class PixelType> void UpdateWithDimAndPixelType();
+
+
+ //----------------------------------------
+ // Data members
+ //----------------------------------------
+ args_info_clitkMirrorPadImage m_ArgsInfo;
+ bool m_Verbose;
+ std::string m_InputFileName;
+
+ };
+
+
+} // end namespace clitk
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#include "clitkMirrorPadImageGenericFilter.txx"
+#endif
+
+#endif // #define clitkMirrorPadImageGenericFilter_h
--- /dev/null
+/*=========================================================================
+ 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 clitkMirrorPadImageGenericFilter_txx
+#define clitkMirrorPadImageGenericFilter_txx
+
+/* =================================================
+ * @file clitkMirrorPadImageGenericFilter.txx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+namespace clitk
+{
+
+ //-------------------------------------------------------------------
+ // Update with the number of dimensions
+ //-------------------------------------------------------------------
+ template<unsigned int Dimension>
+ void
+ MirrorPadImageGenericFilter::UpdateWithDim(std::string PixelType)
+ {
+ if (m_Verbose) std::cout << "Image was detected to be "<<Dimension<<"D and "<< PixelType<<"..."<<std::endl;
+
+ if(PixelType == "short"){
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed short..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, signed short>();
+ }
+ // else if(PixelType == "unsigned_short"){
+ // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_short..." << std::endl;
+ // UpdateWithDimAndPixelType<Dimension, unsigned short>();
+ // }
+
+ else if (PixelType == "unsigned_char"){
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_char..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, unsigned char>();
+ }
+
+ // else if (PixelType == "char"){
+ // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed_char..." << std::endl;
+ // UpdateWithDimAndPixelType<Dimension, signed char>();
+ // }
+ else {
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and float..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, float>();
+ }
+ }
+
+
+ //-------------------------------------------------------------------
+ // Update with the number of dimensions and the pixeltype
+ //-------------------------------------------------------------------
+ template <unsigned int Dimension, class PixelType>
+ void
+ MirrorPadImageGenericFilter::UpdateWithDimAndPixelType()
+ {
+
+ // ImageTypes
+ typedef itk::Image<PixelType, Dimension> InputImageType;
+ typedef itk::Image<PixelType, Dimension> OutputImageType;
+
+ // Read the input
+ typedef itk::ImageFileReader<InputImageType> InputReaderType;
+ typename InputReaderType::Pointer reader = InputReaderType::New();
+ reader->SetFileName( m_InputFileName);
+ reader->Update();
+ typename InputImageType::Pointer input= reader->GetOutput();
+
+ // Filter
+ typedef itk::MirrorPadImageFilter<InputImageType, OutputImageType> MirrorPadImageFilterType;
+ typename MirrorPadImageFilterType::Pointer mirrorPadImageFilter=MirrorPadImageFilterType::New();
+ mirrorPadImageFilter->SetInput(input);
+
+ //Get the padding size
+ typename InputImageType::SizeType padSize;
+
+ // Mirror the entire image
+ if (m_ArgsInfo.mirror_given)
+ {
+ typename InputImageType::SizeType inputSize=input->GetLargestPossibleRegion().GetSize();
+ padSize.Fill(0);
+ padSize[m_ArgsInfo.mirror_arg]=inputSize[m_ArgsInfo.mirror_arg];
+ if (m_Verbose) std::cout<<"Mirroring the entire image along axis "<< m_ArgsInfo.mirror_arg<<"..."<<std::endl;
+ }
+
+ // Pad with a given size
+ else
+ {
+ if(m_ArgsInfo.pad_given)
+ for(unsigned int i=0; i<Dimension; i++)
+ padSize[i]=m_ArgsInfo.pad_arg[i];
+ if (m_Verbose) std::cout<<"Mirror padding with size "<< padSize<<"..."<<std::endl;
+ }
+
+ // Lower or upper?
+ if (m_ArgsInfo.lower_given)
+ mirrorPadImageFilter->SetPadLowerBound(padSize);
+
+ else
+ mirrorPadImageFilter->SetPadUpperBound(padSize);
+
+ mirrorPadImageFilter->Update();
+ typename OutputImageType::Pointer output = mirrorPadImageFilter->GetOutput();
+
+ // Origin?
+ typename OutputImageType::PointType origin;
+ origin.Fill(itk::NumericTraits<double>::Zero);
+ if (m_ArgsInfo.origin_flag)
+ {
+ output->Update();
+ output->SetOrigin(origin);
+ if (m_Verbose) std::cout<<"Setting origin to "<< output->GetOrigin()<<"..."<<std::endl;
+ }
+
+ // Output
+ typedef itk::ImageFileWriter<OutputImageType> WriterType;
+ typename WriterType::Pointer writer = WriterType::New();
+ writer->SetFileName(m_ArgsInfo.output_arg);
+ writer->SetInput(output);
+ writer->Update();
+ }
+
+
+}//end clitk
+
+#endif //#define clitkMirrorPadImageGenericFilter_txx
--- /dev/null
+/*=========================================================================
+ 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 clitkPermuteAxes.cxx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+// clitk
+#include "clitkPermuteAxes_ggo.h"
+#include "clitkIO.h"
+#include "clitkPermuteAxesGenericFilter.h"
+
+
+//--------------------------------------------------------------------
+int main(int argc, char * argv[]) {
+
+ // Init command line
+ GGO(clitkPermuteAxes, args_info);
+ CLITK_INIT;
+
+ // Filter
+ clitk::PermuteAxesGenericFilter::Pointer genericFilter=clitk::PermuteAxesGenericFilter::New();
+
+ genericFilter->SetArgsInfo(args_info);
+ genericFilter->Update();
+
+ return EXIT_SUCCESS;
+}// end main
+
+//--------------------------------------------------------------------
--- /dev/null
+#File clitkPermuteAxes.ggo
+Package "clitkPermuteAxes"
+version "1.0"
+purpose ""
+
+option "config" - "Config file" string no
+option "verbose" v "Verbose" flag off
+
+option "input" i "Input image filename" string yes
+option "output" o "Output image filename" string yes
+option "order" - "The new order of the axes (n comma separated values [o,N])" int multiple yes
+
+
--- /dev/null
+/*=========================================================================
+ 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 clitkPermuteAxesGenericFilter_cxx
+#define clitkPermuteAxesGenericFilter_cxx
+
+/* =================================================
+ * @file clitkPermuteAxesGenericFilter.cxx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+#include "clitkPermuteAxesGenericFilter.h"
+
+
+namespace clitk
+{
+
+
+ //-----------------------------------------------------------
+ // Constructor
+ //-----------------------------------------------------------
+ PermuteAxesGenericFilter::PermuteAxesGenericFilter()
+ {
+ m_Verbose=false;
+ m_InputFileName="";
+ }
+
+
+ //-----------------------------------------------------------
+ // Update
+ //-----------------------------------------------------------
+ void PermuteAxesGenericFilter::Update()
+ {
+ // Read the Dimension and PixelType
+ int Dimension;
+ std::string PixelType;
+ ReadImageDimensionAndPixelType(m_InputFileName, Dimension, PixelType);
+
+
+ // Call UpdateWithDim
+ if(Dimension==2) UpdateWithDim<2>(PixelType);
+ else if(Dimension==3) UpdateWithDim<3>(PixelType);
+ else if (Dimension==4)UpdateWithDim<4>(PixelType);
+ else
+ {
+ std::cout<<"Error, Only for 2, 3 or 4 Dimensions!!!"<<std::endl ;
+ return;
+ }
+ }
+
+
+} //end clitk
+
+#endif //#define clitkPermuteAxesGenericFilter_cxx
--- /dev/null
+/*=========================================================================
+ 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 clitkPermuteAxesGenericFilter_h
+#define clitkPermuteAxesGenericFilter_h
+
+/* =================================================
+ * @file clitkPermuteAxesGenericFilter.h
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+// clitk include
+#include "clitkIO.h"
+#include "clitkCommon.h"
+#include "clitkImageCommon.h"
+#include "clitkPermuteAxes_ggo.h"
+
+//itk include
+#include "itkLightObject.h"
+#include "itkPermuteAxesImageFilter.h"
+
+namespace clitk
+{
+
+
+ class ITK_EXPORT PermuteAxesGenericFilter : public itk::LightObject
+ {
+ public:
+ //----------------------------------------
+ // ITK
+ //----------------------------------------
+ typedef PermuteAxesGenericFilter Self;
+ typedef itk::LightObject Superclass;
+ typedef itk::SmartPointer<Self> Pointer;
+ typedef itk::SmartPointer<const Self> ConstPointer;
+
+ // Method for creation through the object factory
+ itkNewMacro(Self);
+
+ // Run-time type information (and related methods)
+ itkTypeMacro( PermuteAxesGenericFilter, LightObject );
+
+
+ //----------------------------------------
+ // Typedefs
+ //----------------------------------------
+
+
+ //----------------------------------------
+ // Set & Get
+ //----------------------------------------
+ void SetArgsInfo(const args_info_clitkPermuteAxes & a)
+ {
+ m_ArgsInfo=a;
+ m_Verbose=m_ArgsInfo.verbose_flag;
+ m_InputFileName=m_ArgsInfo.input_arg;
+ }
+
+
+ //----------------------------------------
+ // Update
+ //----------------------------------------
+ void Update();
+
+ protected:
+
+ //----------------------------------------
+ // Constructor & Destructor
+ //----------------------------------------
+ PermuteAxesGenericFilter();
+ ~PermuteAxesGenericFilter() {};
+
+
+ //----------------------------------------
+ // Templated members
+ //----------------------------------------
+ template <unsigned int Dimension> void UpdateWithDim(std::string PixelType);
+ template <unsigned int Dimension, class PixelType> void UpdateWithDimAndPixelType();
+
+
+ //----------------------------------------
+ // Data members
+ //----------------------------------------
+ args_info_clitkPermuteAxes m_ArgsInfo;
+ bool m_Verbose;
+ std::string m_InputFileName;
+
+ };
+
+
+} // end namespace clitk
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#include "clitkPermuteAxesGenericFilter.txx"
+#endif
+
+#endif // #define clitkPermuteAxesGenericFilter_h
--- /dev/null
+/*=========================================================================
+ 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 clitkPermuteAxesGenericFilter_txx
+#define clitkPermuteAxesGenericFilter_txx
+
+/* =================================================
+ * @file clitkPermuteAxesGenericFilter.txx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+namespace clitk
+{
+
+ //-------------------------------------------------------------------
+ // Update with the number of dimensions
+ //-------------------------------------------------------------------
+ template<unsigned int Dimension>
+ void
+ PermuteAxesGenericFilter::UpdateWithDim(std::string PixelType)
+ {
+ if (m_Verbose) std::cout << "Image was detected to be "<<Dimension<<"D and "<< PixelType<<"..."<<std::endl;
+
+ if(PixelType == "short"){
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed short..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, signed short>();
+ }
+ // else if(PixelType == "unsigned_short"){
+ // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_short..." << std::endl;
+ // UpdateWithDimAndPixelType<Dimension, unsigned short>();
+ // }
+
+ else if (PixelType == "unsigned_char"){
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_char..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, unsigned char>();
+ }
+
+ // else if (PixelType == "char"){
+ // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed_char..." << std::endl;
+ // UpdateWithDimAndPixelType<Dimension, signed char>();
+ // }
+ else {
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and float..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, float>();
+ }
+ }
+
+
+ //-------------------------------------------------------------------
+ // Update with the number of dimensions and the pixeltype
+ //-------------------------------------------------------------------
+ template <unsigned int Dimension, class PixelType>
+ void
+ PermuteAxesGenericFilter::UpdateWithDimAndPixelType()
+ {
+
+ // ImageTypes
+ typedef itk::Image<PixelType, Dimension> InputImageType;
+ typedef itk::Image<PixelType, Dimension> OutputImageType;
+
+ // Read the input
+ typedef itk::ImageFileReader<InputImageType> InputReaderType;
+ typename InputReaderType::Pointer reader = InputReaderType::New();
+ reader->SetFileName( m_InputFileName);
+ reader->Update();
+ typename InputImageType::Pointer input= reader->GetOutput();
+
+ // Filter
+ typedef itk::PermuteAxesImageFilter<InputImageType> PermuteFilterType;
+ typename PermuteFilterType::Pointer permuteFilter=PermuteFilterType::New();
+ permuteFilter->SetInput(input);
+ typename PermuteFilterType::PermuteOrderArrayType order;
+
+ if(m_ArgsInfo.order_given != Dimension)
+ {
+ std::cerr<<"Error: Number of order parameters is different from image dimension!"<<std::endl;
+ return;
+ }
+
+
+ for (unsigned int i=0;i<Dimension; i++)
+ order[i]=m_ArgsInfo.order_arg[i];
+
+ permuteFilter->SetOrder(order);
+ permuteFilter->Update();
+ typename OutputImageType::Pointer output =permuteFilter->GetOutput();
+
+ // Output
+ typedef itk::ImageFileWriter<OutputImageType> WriterType;
+ typename WriterType::Pointer writer = WriterType::New();
+ writer->SetFileName(m_ArgsInfo.output_arg);
+ writer->SetInput(output);
+ writer->Update();
+
+ }
+
+
+}//end clitk
+
+#endif //#define clitkPermuteAxesGenericFilter_txx
--- /dev/null
+/*=========================================================================
+ 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 clitkSetDirection.cxx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+// clitk
+#include "clitkSetDirection_ggo.h"
+#include "clitkIO.h"
+#include "clitkSetDirectionGenericFilter.h"
+
+
+//--------------------------------------------------------------------
+int main(int argc, char * argv[]) {
+
+ // Init command line
+ GGO(clitkSetDirection, args_info);
+ CLITK_INIT;
+
+ // Filter
+ clitk::SetDirectionGenericFilter::Pointer genericFilter=clitk::SetDirectionGenericFilter::New();
+
+ genericFilter->SetArgsInfo(args_info);
+ genericFilter->Update();
+
+ return EXIT_SUCCESS;
+}// end main
+
+//--------------------------------------------------------------------
--- /dev/null
+#File clitkSetDirection.ggo
+Package "clitkSetDirection"
+version "1.0"
+purpose ""
+
+option "config" - "Config file" string no
+option "verbose" v "Verbose" flag off
+
+option "input" i "Input image filename" string yes
+option "output" o "Output image filename" string yes
+option "direction" d "Direction cosine matrix (defaults to identity)" double multiple no
+
--- /dev/null
+/*=========================================================================
+ 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 clitkSetDirectionGenericFilter_cxx
+#define clitkSetDirectionGenericFilter_cxx
+
+/* =================================================
+ * @file clitkSetDirectionGenericFilter.cxx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+#include "clitkSetDirectionGenericFilter.h"
+
+
+namespace clitk
+{
+
+
+ //-----------------------------------------------------------
+ // Constructor
+ //-----------------------------------------------------------
+ SetDirectionGenericFilter::SetDirectionGenericFilter()
+ {
+ m_Verbose=false;
+ m_InputFileName="";
+ }
+
+
+ //-----------------------------------------------------------
+ // Update
+ //-----------------------------------------------------------
+ void SetDirectionGenericFilter::Update()
+ {
+ // Read the Dimension and PixelType
+ int Dimension;
+ std::string PixelType;
+ ReadImageDimensionAndPixelType(m_InputFileName, Dimension, PixelType);
+
+
+ // Call UpdateWithDim
+ if(Dimension==2) UpdateWithDim<2>(PixelType);
+ else if(Dimension==3) UpdateWithDim<3>(PixelType);
+ else if (Dimension==4)UpdateWithDim<4>(PixelType);
+ else
+ {
+ std::cout<<"Error, Only for 2,3 or 4 Dimensions!!!"<<std::endl ;
+ return;
+ }
+ }
+
+
+} //end clitk
+
+#endif //#define clitkSetDirectionGenericFilter_cxx
--- /dev/null
+/*=========================================================================
+ 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 clitkSetDirectionGenericFilter_h
+#define clitkSetDirectionGenericFilter_h
+
+/* =================================================
+ * @file clitkSetDirectionGenericFilter.h
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+// clitk include
+#include "clitkIO.h"
+#include "clitkCommon.h"
+#include "clitkImageCommon.h"
+#include "clitkSetDirection_ggo.h"
+
+//itk include
+#include "itkLightObject.h"
+
+namespace clitk
+{
+
+
+ class ITK_EXPORT SetDirectionGenericFilter : public itk::LightObject
+ {
+ public:
+ //----------------------------------------
+ // ITK
+ //----------------------------------------
+ typedef SetDirectionGenericFilter Self;
+ typedef itk::LightObject Superclass;
+ typedef itk::SmartPointer<Self> Pointer;
+ typedef itk::SmartPointer<const Self> ConstPointer;
+
+ // Method for creation through the object factory
+ itkNewMacro(Self);
+
+ // Run-time type information (and related methods)
+ itkTypeMacro( SetDirectionGenericFilter, LightObject );
+
+
+ //----------------------------------------
+ // Typedefs
+ //----------------------------------------
+
+
+ //----------------------------------------
+ // Set & Get
+ //----------------------------------------
+ void SetArgsInfo(const args_info_clitkSetDirection & a)
+ {
+ m_ArgsInfo=a;
+ m_Verbose=m_ArgsInfo.verbose_flag;
+ m_InputFileName=m_ArgsInfo.input_arg;
+ }
+
+
+ //----------------------------------------
+ // Update
+ //----------------------------------------
+ void Update();
+
+ protected:
+
+ //----------------------------------------
+ // Constructor & Destructor
+ //----------------------------------------
+ SetDirectionGenericFilter();
+ ~SetDirectionGenericFilter() {};
+
+
+ //----------------------------------------
+ // Templated members
+ //----------------------------------------
+ template <unsigned int Dimension> void UpdateWithDim(std::string PixelType);
+ template <unsigned int Dimension, class PixelType> void UpdateWithDimAndPixelType();
+
+
+ //----------------------------------------
+ // Data members
+ //----------------------------------------
+ args_info_clitkSetDirection m_ArgsInfo;
+ bool m_Verbose;
+ std::string m_InputFileName;
+
+ };
+
+
+} // end namespace clitk
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#include "clitkSetDirectionGenericFilter.txx"
+#endif
+
+#endif // #define clitkSetDirectionGenericFilter_h
--- /dev/null
+/*=========================================================================
+ 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 clitkSetDirectionGenericFilter_txx
+#define clitkSetDirectionGenericFilter_txx
+
+/* =================================================
+ * @file clitkSetDirectionGenericFilter.txx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+namespace clitk
+{
+
+ //-------------------------------------------------------------------
+ // Update with the number of dimensions
+ //-------------------------------------------------------------------
+ template<unsigned int Dimension>
+ void
+ SetDirectionGenericFilter::UpdateWithDim(std::string PixelType)
+ {
+ if (m_Verbose) std::cout << "Image was detected to be "<<Dimension<<"D and "<< PixelType<<"..."<<std::endl;
+
+ if(PixelType == "short"){
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed short..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, signed short>();
+ }
+ // else if(PixelType == "unsigned_short"){
+ // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_short..." << std::endl;
+ // UpdateWithDimAndPixelType<Dimension, unsigned short>();
+ // }
+
+ else if (PixelType == "unsigned_char"){
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_char..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, unsigned char>();
+ }
+
+ // else if (PixelType == "char"){
+ // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed_char..." << std::endl;
+ // UpdateWithDimAndPixelType<Dimension, signed char>();
+ // }
+ else {
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and float..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, float>();
+ }
+ }
+
+
+ //-------------------------------------------------------------------
+ // Update with the number of dimensions and the pixeltype
+ //-------------------------------------------------------------------
+ template <unsigned int Dimension, class PixelType>
+ void
+ SetDirectionGenericFilter::UpdateWithDimAndPixelType()
+ {
+
+ // ImageTypes
+ typedef itk::Image<PixelType, Dimension> InputImageType;
+ typedef itk::Image<PixelType, Dimension> OutputImageType;
+
+ // Read the input
+ typedef itk::ImageFileReader<InputImageType> InputReaderType;
+ typename InputReaderType::Pointer reader = InputReaderType::New();
+ reader->SetFileName( m_InputFileName);
+ reader->Update();
+ typename InputImageType::Pointer input= reader->GetOutput();
+
+ // Filter
+ typename InputImageType::DirectionType direction;
+ direction.SetIdentity();
+ if(m_ArgsInfo.direction_given==Dimension*Dimension)
+ for (unsigned int i=0;i<Dimension;i++)
+ for (unsigned int j=0;j<Dimension;j++)
+ direction[i][j]=m_ArgsInfo.direction_arg[i+j];
+ input->SetDirection(direction);
+
+ // Output
+ typedef itk::ImageFileWriter<OutputImageType> WriterType;
+ typename WriterType::Pointer writer = WriterType::New();
+ writer->SetFileName(m_ArgsInfo.output_arg);
+ writer->SetInput(input);
+ writer->Update();
+
+ }
+
+
+}//end clitk
+
+#endif //#define clitkSetDirectionGenericFilter_txx
--- /dev/null
+/*=========================================================================
+ 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 clitkSetOrigin.cxx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+// clitk
+#include "clitkSetOrigin_ggo.h"
+#include "clitkIO.h"
+#include "clitkSetOriginGenericFilter.h"
+
+
+//--------------------------------------------------------------------
+int main(int argc, char * argv[]) {
+
+ // Init command line
+ GGO(clitkSetOrigin, args_info);
+ CLITK_INIT;
+
+ // Filter
+ clitk::SetOriginGenericFilter::Pointer genericFilter=clitk::SetOriginGenericFilter::New();
+
+ genericFilter->SetArgsInfo(args_info);
+ genericFilter->Update();
+
+ return EXIT_SUCCESS;
+}// end main
+
+//--------------------------------------------------------------------
--- /dev/null
+#File clitkSetOrigin.ggo
+Package "clitkSetOrigin"
+version "1.0"
+purpose "Set the origin field of a generic image"
+
+option "config" - "Config file" string no
+option "verbose" v "Verbose" flag off
+
+option "input" i "Input image filename" string yes
+option "output" o "Output image filename" string yes
+option "like" l "Like image filename" string no
+option "origin" - "Origin" double multiple no default="0"
--- /dev/null
+/*=========================================================================
+ 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 clitkSetOriginGenericFilter_cxx
+#define clitkSetOriginGenericFilter_cxx
+
+/* =================================================
+ * @file clitkSetOriginGenericFilter.cxx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+#include "clitkSetOriginGenericFilter.h"
+
+
+namespace clitk
+{
+
+
+ //-----------------------------------------------------------
+ // Constructor
+ //-----------------------------------------------------------
+ SetOriginGenericFilter::SetOriginGenericFilter()
+ {
+ m_Verbose=false;
+ m_InputFileName="";
+ }
+
+
+ //-----------------------------------------------------------
+ // Update
+ //-----------------------------------------------------------
+ void SetOriginGenericFilter::Update()
+ {
+ // Read the Dimension and PixelType
+ int Dimension, Components;
+ std::string PixelType;
+ ReadImageDimensionAndPixelType(m_InputFileName, Dimension, PixelType, Components);
+
+
+ // Call UpdateWithDim
+ if(Dimension==2) UpdateWithDim<2>(PixelType, Components);
+ else if(Dimension==3) UpdateWithDim<3>(PixelType, Components);
+ else if (Dimension==4)UpdateWithDim<4>(PixelType, Components);
+ else
+ {
+ std::cout<<"Error, Only for 2, 3 or 4 Dimensions!!!"<<std::endl ;
+ return;
+ }
+ }
+
+
+} //end clitk
+
+#endif //#define clitkSetOriginGenericFilter_cxx
--- /dev/null
+/*=========================================================================
+ 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 clitkSetOriginGenericFilter_h
+#define clitkSetOriginGenericFilter_h
+
+/* =================================================
+ * @file clitkSetOriginGenericFilter.h
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+// clitk include
+#include "clitkIO.h"
+#include "clitkCommon.h"
+#include "clitkImageCommon.h"
+#include "clitkSetOrigin_ggo.h"
+
+//itk include
+#include "itkLightObject.h"
+
+namespace clitk
+{
+
+
+ class ITK_EXPORT SetOriginGenericFilter : public itk::LightObject
+ {
+ public:
+ //----------------------------------------
+ // ITK
+ //----------------------------------------
+ typedef SetOriginGenericFilter Self;
+ typedef itk::LightObject Superclass;
+ typedef itk::SmartPointer<Self> Pointer;
+ typedef itk::SmartPointer<const Self> ConstPointer;
+
+ // Method for creation through the object factory
+ itkNewMacro(Self);
+
+ // Run-time type information (and related methods)
+ itkTypeMacro( SetOriginGenericFilter, LightObject );
+
+
+ //----------------------------------------
+ // Typedefs
+ //----------------------------------------
+
+
+ //----------------------------------------
+ // Set & Get
+ //----------------------------------------
+ void SetArgsInfo(const args_info_clitkSetOrigin & a)
+ {
+ m_ArgsInfo=a;
+ m_Verbose=m_ArgsInfo.verbose_flag;
+ m_InputFileName=m_ArgsInfo.input_arg;
+ }
+
+
+ //----------------------------------------
+ // Update
+ //----------------------------------------
+ void Update();
+
+ protected:
+
+ //----------------------------------------
+ // Constructor & Destructor
+ //----------------------------------------
+ SetOriginGenericFilter();
+ ~SetOriginGenericFilter() {};
+
+
+ //----------------------------------------
+ // Templated members
+ //----------------------------------------
+ template <unsigned int Dimension> void UpdateWithDim(std::string PixelType, int Components);
+ template <unsigned int Dimension, class PixelType> void UpdateWithDimAndPixelType();
+
+
+ //----------------------------------------
+ // Data members
+ //----------------------------------------
+ args_info_clitkSetOrigin m_ArgsInfo;
+ bool m_Verbose;
+ std::string m_InputFileName;
+
+ };
+
+
+} // end namespace clitk
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#include "clitkSetOriginGenericFilter.txx"
+#endif
+
+#endif // #define clitkSetOriginGenericFilter_h
--- /dev/null
+/*=========================================================================
+ 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 clitkSetOriginGenericFilter_txx
+#define clitkSetOriginGenericFilter_txx
+
+/* =================================================
+ * @file clitkSetOriginGenericFilter.txx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+namespace clitk
+{
+
+ //-------------------------------------------------------------------
+ // Update with the number of dimensions
+ //-------------------------------------------------------------------
+ template<unsigned int Dimension>
+ void
+ SetOriginGenericFilter::UpdateWithDim(std::string PixelType, int Components)
+ {
+ if (m_Verbose) std::cout << "Image was detected to be "<<Dimension<<"D and "<<Components<<" component(s) of "<< PixelType<<"..."<<std::endl;
+
+ if (Components==1)
+ {
+ if(PixelType == "short"){
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed short..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, signed short>();
+ }
+ // else if(PixelType == "unsigned_short"){
+ // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_short..." << std::endl;
+ // UpdateWithDimAndPixelType<Dimension, unsigned short>();
+ // }
+
+ else if (PixelType == "unsigned_char"){
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_char..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, unsigned char>();
+ }
+
+ // else if (PixelType == "char"){
+ // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed_char..." << std::endl;
+ // UpdateWithDimAndPixelType<Dimension, signed char>();
+ // }
+ else {
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and float..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, float>();
+ }
+ }
+
+ else if (Components==3)
+ {
+ if (m_Verbose) std::cout << "Launching transform in "<< Dimension <<"D and 3D float (DVF)" << std::endl;
+ UpdateWithDimAndPixelType<Dimension, itk::Vector<float, 3> >();
+ }
+
+ else std::cerr<<"Number of components is "<<Components<<", not supported!"<<std::endl;
+
+ }
+
+
+ //-------------------------------------------------------------------
+ // Update with the number of dimensions and the pixeltype
+ //-------------------------------------------------------------------
+ template <unsigned int Dimension, class PixelType>
+ void
+ SetOriginGenericFilter::UpdateWithDimAndPixelType()
+ {
+
+ // ImageTypes
+ typedef itk::Image<PixelType, Dimension> InputImageType;
+ typedef itk::Image<PixelType, Dimension> OutputImageType;
+
+ // Read the input
+ typedef itk::ImageFileReader<InputImageType> InputReaderType;
+ typename InputReaderType::Pointer reader = InputReaderType::New();
+ reader->SetFileName( m_InputFileName);
+ reader->Update();
+ typename InputImageType::Pointer input= reader->GetOutput();
+
+ // Origin
+ typename InputImageType::PointType origin;
+ origin.Fill(0.0);
+
+ // Like?
+ if (m_ArgsInfo.like_given)
+ {
+ typedef itk::ImageFileReader<InputImageType> InputReaderType;
+ typename InputReaderType::Pointer likeReader = InputReaderType::New();
+ likeReader->SetFileName( m_ArgsInfo.like_arg);
+ likeReader->Update();
+ typename InputImageType::Pointer like= likeReader->GetOutput();
+ origin=like->GetOrigin();
+ }
+ else
+ {
+ if (m_ArgsInfo.origin_given==Dimension)
+ for(unsigned int i=0; i<Dimension;i++)
+ origin[i]=m_ArgsInfo.origin_arg[i];
+ else
+ for(unsigned int i=0; i<Dimension;i++)
+ origin[i]=m_ArgsInfo.origin_arg[0];
+ }
+ input->SetOrigin(origin);
+
+ // Output
+ typedef itk::ImageFileWriter<OutputImageType> WriterType;
+ typename WriterType::Pointer writer = WriterType::New();
+ writer->SetFileName(m_ArgsInfo.output_arg);
+ writer->SetInput(input);
+ writer->Update();
+
+ }
+
+
+}//end clitk
+
+#endif //#define clitkSetOriginGenericFilter_txx
--- /dev/null
+/*=========================================================================
+ 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 clitkSetSpacing.cxx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+// clitk
+#include "clitkSetSpacing_ggo.h"
+#include "clitkIO.h"
+#include "clitkSetSpacingGenericFilter.h"
+
+
+//--------------------------------------------------------------------
+int main(int argc, char * argv[]) {
+
+ // Init command line
+ GGO(clitkSetSpacing, args_info);
+ CLITK_INIT;
+
+ // Filter
+ clitk::SetSpacingGenericFilter::Pointer genericFilter=clitk::SetSpacingGenericFilter::New();
+
+ genericFilter->SetArgsInfo(args_info);
+ genericFilter->Update();
+
+ return EXIT_SUCCESS;
+}// end main
+
+//--------------------------------------------------------------------
--- /dev/null
+#File clitkSetSpacing.ggo
+Package "clitkSetSpacing"
+version "1.0"
+purpose ""
+
+option "config" - "Config file" string no
+option "verbose" v "Verbose" flag off
+
+option "input" i "Input image filename" string yes
+option "output" o "Output image filename" string yes
+option "like" l "Like image filename" string no
+option "spacing" s "Spacing" double no multiple default="1"
+
+
--- /dev/null
+/*=========================================================================
+ 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 clitkSetSpacingGenericFilter_cxx
+#define clitkSetSpacingGenericFilter_cxx
+
+/* =================================================
+ * @file clitkSetSpacingGenericFilter.cxx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+#include "clitkSetSpacingGenericFilter.h"
+
+
+namespace clitk
+{
+
+
+ //-----------------------------------------------------------
+ // Constructor
+ //-----------------------------------------------------------
+ SetSpacingGenericFilter::SetSpacingGenericFilter()
+ {
+ m_Verbose=false;
+ m_InputFileName="";
+ }
+
+
+ //-----------------------------------------------------------
+ // Update
+ //-----------------------------------------------------------
+ void SetSpacingGenericFilter::Update()
+ {
+ // Read the Dimension and PixelType
+ int Dimension, Components;
+ std::string PixelType;
+ ReadImageDimensionAndPixelType(m_InputFileName, Dimension, PixelType, Components);
+
+
+ // Call UpdateWithDim
+ if(Dimension==2) UpdateWithDim<2>(PixelType, Components);
+ else if(Dimension==3) UpdateWithDim<3>(PixelType, Components);
+ else if (Dimension==4)UpdateWithDim<4>(PixelType, Components);
+ else
+ {
+ std::cout<<"Error, Only for 2, 3 or 4 Dimensions!!!"<<std::endl ;
+ return;
+ }
+ }
+
+
+} //end clitk
+
+#endif //#define clitkSetSpacingGenericFilter_cxx
--- /dev/null
+/*=========================================================================
+ 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 clitkSetSpacingGenericFilter_h
+#define clitkSetSpacingGenericFilter_h
+
+/* =================================================
+ * @file clitkSetSpacingGenericFilter.h
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+// clitk include
+#include "clitkIO.h"
+#include "clitkCommon.h"
+#include "clitkImageCommon.h"
+#include "clitkSetSpacing_ggo.h"
+
+//itk include
+#include "itkLightObject.h"
+
+namespace clitk
+{
+
+
+ class ITK_EXPORT SetSpacingGenericFilter : public itk::LightObject
+ {
+ public:
+ //----------------------------------------
+ // ITK
+ //----------------------------------------
+ typedef SetSpacingGenericFilter Self;
+ typedef itk::LightObject Superclass;
+ typedef itk::SmartPointer<Self> Pointer;
+ typedef itk::SmartPointer<const Self> ConstPointer;
+
+ // Method for creation through the object factory
+ itkNewMacro(Self);
+
+ // Run-time type information (and related methods)
+ itkTypeMacro( SetSpacingGenericFilter, LightObject );
+
+
+ //----------------------------------------
+ // Typedefs
+ //----------------------------------------
+
+
+ //----------------------------------------
+ // Set & Get
+ //----------------------------------------
+ void SetArgsInfo(const args_info_clitkSetSpacing & a)
+ {
+ m_ArgsInfo=a;
+ m_Verbose=m_ArgsInfo.verbose_flag;
+ m_InputFileName=m_ArgsInfo.input_arg;
+ }
+
+
+ //----------------------------------------
+ // Update
+ //----------------------------------------
+ void Update();
+
+ protected:
+
+ //----------------------------------------
+ // Constructor & Destructor
+ //----------------------------------------
+ SetSpacingGenericFilter();
+ ~SetSpacingGenericFilter() {};
+
+
+ //----------------------------------------
+ // Templated members
+ //----------------------------------------
+ template <unsigned int Dimension> void UpdateWithDim(std::string PixelType, unsigned int Components);
+ template <unsigned int Dimension, class PixelType> void UpdateWithDimAndPixelType();
+
+ //----------------------------------------
+ // Data members
+ //----------------------------------------
+ args_info_clitkSetSpacing m_ArgsInfo;
+ bool m_Verbose;
+ std::string m_InputFileName;
+
+ };
+
+
+} // end namespace clitk
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#include "clitkSetSpacingGenericFilter.txx"
+#endif
+
+#endif // #define clitkSetSpacingGenericFilter_h
--- /dev/null
+/*=========================================================================
+ 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 clitkSetSpacingGenericFilter_txx
+#define clitkSetSpacingGenericFilter_txx
+
+/* =================================================
+ * @file clitkSetSpacingGenericFilter.txx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+namespace clitk
+{
+
+ //-------------------------------------------------------------------
+ // Update with the number of dimensions
+ //-------------------------------------------------------------------
+ template<unsigned int Dimension>
+ void
+ SetSpacingGenericFilter::UpdateWithDim(std::string PixelType , unsigned int Components)
+ {
+ if (m_Verbose) std::cout << "Image was detected to be "<<Dimension<<"D and "<<Components<<" component(s) of "<< PixelType<<"..."<<std::endl;
+
+ if (Components==1)
+ {
+ if(PixelType == "short"){
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed short..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, signed short>();
+ }
+ // else if(PixelType == "unsigned_short"){
+ // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_short..." << std::endl;
+ // UpdateWithDimAndPixelType<Dimension, unsigned short>();
+ // }
+
+ else if (PixelType == "unsigned_char"){
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_char..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, unsigned char>();
+ }
+
+ // else if (PixelType == "char"){
+ // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed_char..." << std::endl;
+ // UpdateWithDimAndPixelType<Dimension, signed char>();
+ // }
+ else {
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and float..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, float>();
+ }
+ }
+
+ else if (Components==3)
+ {
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and 3D float (DVF)" << std::endl;
+ UpdateWithDimAndPixelType<Dimension, itk::Vector<float, 3> >();
+ }
+
+ else std::cerr<<"Number of components is "<<Components<<", not supported!"<<std::endl;
+ }
+
+
+
+ //-------------------------------------------------------------------
+ // Update with the number of dimensions and the pixeltype
+ //-------------------------------------------------------------------
+ template <unsigned int Dimension, class PixelType>
+ void
+ SetSpacingGenericFilter::UpdateWithDimAndPixelType()
+ {
+
+ // ImageTypes
+ typedef itk::Image<PixelType, Dimension> InputImageType;
+ typedef itk::Image<PixelType, Dimension> OutputImageType;
+
+ // Read the input
+ typedef itk::ImageFileReader<InputImageType> InputReaderType;
+ typename InputReaderType::Pointer reader = InputReaderType::New();
+ reader->SetFileName( m_InputFileName);
+ reader->Update();
+ typename InputImageType::Pointer input= reader->GetOutput();
+
+ // Filter
+ typename InputImageType::SpacingType spacing;
+ spacing.Fill(1.0);
+
+ // Like?
+ if (m_ArgsInfo.like_given)
+ {
+ typedef itk::ImageFileReader<InputImageType> InputReaderType;
+ typename InputReaderType::Pointer likeReader = InputReaderType::New();
+ likeReader->SetFileName( m_ArgsInfo.like_arg);
+ likeReader->Update();
+ typename InputImageType::Pointer like= likeReader->GetOutput();
+ spacing=like->GetSpacing();
+ }
+ else
+ {
+ if (m_ArgsInfo.spacing_given==Dimension)
+ for(unsigned int i=0; i<Dimension;i++)
+ spacing[i]=m_ArgsInfo.spacing_arg[i];
+ else
+ for(unsigned int i=0; i<Dimension;i++)
+ spacing[i]=m_ArgsInfo.spacing_arg[0];
+ }
+ input->SetSpacing(spacing);
+
+ // Output
+ typedef itk::ImageFileWriter<OutputImageType> WriterType;
+ typename WriterType::Pointer writer = WriterType::New();
+ writer->SetFileName(m_ArgsInfo.output_arg);
+ writer->SetInput(input);
+ writer->Update();
+
+ }
+
+
+}//end clitk
+
+#endif //#define clitkSetSpacingGenericFilter_txx
-------------------------------------------------------------------*/
// clitk include
+#include "clitkIO.h"
#include "clitkCommon.h"
#include "clitkImageCommon.h"
#include "clitkImageToImageGenericFilter.h"
--- /dev/null
+/*=========================================================================
+ 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 clitkVFConvert.cxx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+// clitk
+#include "clitkVFConvert_ggo.h"
+#include "clitkIO.h"
+#include "clitkVFConvertGenericFilter.h"
+
+
+//--------------------------------------------------------------------
+int main(int argc, char * argv[]) {
+
+ // Init command line
+ GGO(clitkVFConvert, args_info);
+ CLITK_INIT;
+
+ // Filter
+ clitk::VFConvertGenericFilter::Pointer genericFilter=clitk::VFConvertGenericFilter::New();
+
+ genericFilter->SetArgsInfo(args_info);
+ genericFilter->Update();
+
+ return EXIT_SUCCESS;
+}// end main
+
+//--------------------------------------------------------------------
--- /dev/null
+#File clitkVFConvert.ggo
+Package "clitkVFConvert"
+version "1.0"
+purpose "Convert file format"
+
+option "config" - "Config file" string no
+option "verbose" v "Verbose" flag off
+
+option "input" i "Input image filename" string yes
+option "output" o "Output image filename" string yes
+
+
--- /dev/null
+/*=========================================================================
+ 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 clitkVFConvertGenericFilter_cxx
+#define clitkVFConvertGenericFilter_cxx
+
+/* =================================================
+ * @file clitkVFConvertGenericFilter.cxx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+#include "clitkVFConvertGenericFilter.h"
+
+
+namespace clitk
+{
+
+
+ //-----------------------------------------------------------
+ // Constructor
+ //-----------------------------------------------------------
+ VFConvertGenericFilter::VFConvertGenericFilter()
+ {
+ m_Verbose=false;
+ m_InputFileName="";
+ }
+
+
+ //-----------------------------------------------------------
+ // Update
+ //-----------------------------------------------------------
+ void VFConvertGenericFilter::Update()
+ {
+ // Read the Dimension and PixelType
+ int Dimension, Components;
+ std::string PixelType;
+ ReadImageDimensionAndPixelType(m_InputFileName, Dimension, PixelType, Components);
+
+
+ // Call UpdateWithDim
+ if(Dimension==2) UpdateWithDim<2>(PixelType,Components);
+ else if(Dimension==3) UpdateWithDim<3>(PixelType,Components);
+ else if (Dimension==4)UpdateWithDim<4>(PixelType,Components);
+ else
+ {
+ std::cout<<"Error, Only for 2, 3 or 4 Dimensions!!!"<<std::endl ;
+ return;
+ }
+ }
+
+
+} //end clitk
+
+#endif //#define clitkVFConvertGenericFilter_cxx
--- /dev/null
+/*=========================================================================
+ 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 clitkVFConvertGenericFilter_h
+#define clitkVFConvertGenericFilter_h
+
+/* =================================================
+ * @file clitkVFConvertGenericFilter.h
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+// clitk include
+#include "clitkIO.h"
+#include "clitkCommon.h"
+#include "clitkImageCommon.h"
+#include "clitkVFConvert_ggo.h"
+
+//itk include
+#include "itkLightObject.h"
+
+namespace clitk
+{
+
+
+ class ITK_EXPORT VFConvertGenericFilter : public itk::LightObject
+ {
+ public:
+ //----------------------------------------
+ // ITK
+ //----------------------------------------
+ typedef VFConvertGenericFilter Self;
+ typedef itk::LightObject Superclass;
+ typedef itk::SmartPointer<Self> Pointer;
+ typedef itk::SmartPointer<const Self> ConstPointer;
+
+ // Method for creation through the object factory
+ itkNewMacro(Self);
+
+ // Run-time type information (and related methods)
+ itkTypeMacro( VFConvertGenericFilter, LightObject );
+
+
+ //----------------------------------------
+ // Typedefs
+ //----------------------------------------
+
+
+ //----------------------------------------
+ // Set & Get
+ //----------------------------------------
+ void SetArgsInfo(const args_info_clitkVFConvert & a)
+ {
+ m_ArgsInfo=a;
+ m_Verbose=m_ArgsInfo.verbose_flag;
+ m_InputFileName=m_ArgsInfo.input_arg;
+ }
+
+
+ //----------------------------------------
+ // Update
+ //----------------------------------------
+ void Update();
+
+ protected:
+
+ //----------------------------------------
+ // Constructor & Destructor
+ //----------------------------------------
+ VFConvertGenericFilter();
+ ~VFConvertGenericFilter() {};
+
+
+ //----------------------------------------
+ // Templated members
+ //----------------------------------------
+ template <unsigned int Dimension> void UpdateWithDim(std::string PixelType, unsigned int Components);
+ template <unsigned int Dimension, class PixelType> void UpdateWithDimAndPixelType();
+
+
+ //----------------------------------------
+ // Data members
+ //----------------------------------------
+ args_info_clitkVFConvert m_ArgsInfo;
+ bool m_Verbose;
+ std::string m_InputFileName;
+
+ };
+
+
+} // end namespace clitk
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#include "clitkVFConvertGenericFilter.txx"
+#endif
+
+#endif // #define clitkVFConvertGenericFilter_h
--- /dev/null
+/*=========================================================================
+ 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 clitkVFConvertGenericFilter_txx
+#define clitkVFConvertGenericFilter_txx
+
+/* =================================================
+ * @file clitkVFConvertGenericFilter.txx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+namespace clitk
+{
+
+ //-------------------------------------------------------------------
+ // Update with the number of dimensions
+ //-------------------------------------------------------------------
+ template<unsigned int Dimension>
+ void
+ VFConvertGenericFilter::UpdateWithDim(std::string PixelType, unsigned int Components)
+ {
+ if (m_Verbose) std::cout << "Image was detected to be "<<Dimension<<"D with "<< Components <<" components of "<< PixelType<<"..."<<std::endl;
+
+ if (Components==2)
+ {
+ if (PixelType == "double"){
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D with "<< Components <<" components of double..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, itk::Vector<double, 2> >();
+ }
+ else {
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D with "<< Components <<" components of float..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, itk::Vector<float, 2> >();
+ }
+ }
+ else if (Components==3)
+ {
+ if (PixelType == "double"){
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D with "<< Components <<" components of double..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, itk::Vector<double, 3> >();
+ }
+ else {
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D with "<< Components <<" components of float..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, itk::Vector<float, 3> >();
+ }
+ }
+ else if (Components==4)
+ {
+ if (PixelType == "double"){
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D with "<< Components <<" components of double..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, itk::Vector<double, 4> >();
+ }
+ else {
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D with "<< Components <<" components of float..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, itk::Vector<float, 4> >();
+ }
+ }
+ else std::cerr<<"Only 2,3 and 4 components!"<<std::endl;
+ }
+
+
+ //-------------------------------------------------------------------
+ // Update with the number of dimensions and the pixeltype
+ //-------------------------------------------------------------------
+ template <unsigned int Dimension, class PixelType>
+ void
+ VFConvertGenericFilter::UpdateWithDimAndPixelType()
+ {
+
+ // ImageTypes
+ typedef itk::Image<PixelType, Dimension> InputImageType;
+ typedef itk::Image<PixelType, Dimension> OutputImageType;
+
+ // Read the input
+ typedef itk::ImageFileReader<InputImageType> InputReaderType;
+ typename InputReaderType::Pointer reader = InputReaderType::New();
+ reader->SetFileName( m_InputFileName);
+ reader->Update();
+ typename InputImageType::Pointer input= reader->GetOutput();
+
+ // Output
+ typedef itk::ImageFileWriter<OutputImageType> WriterType;
+ typename WriterType::Pointer writer = WriterType::New();
+ writer->SetFileName(m_ArgsInfo.output_arg);
+ writer->SetInput(input);
+ writer->Update();
+
+ }
+
+
+}//end clitk
+
+#endif //#define clitkVFConvertGenericFilter_txx
#define CLITKVFRESAMPLE_CXX
/**
------------------------------------------------=
- * @file clitkImageResample.cxx
+ * @file clitkVFResample.cxx
* @author David Sarrut <David.Sarrut@creatis.insa-lyon.fr>
* @date 23 Feb 2008 08:37:53
------------------------------------------------=*/
--- /dev/null
+/*=========================================================================
+ 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 clitkValuesToBSplineCoefficients.cxx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+// clitk
+#include "clitkValuesToBSplineCoefficients_ggo.h"
+#include "clitkIO.h"
+#include "clitkValuesToBSplineCoefficientsGenericFilter.h"
+
+
+//--------------------------------------------------------------------
+int main(int argc, char * argv[]) {
+
+ // Init command line
+ GGO(clitkValuesToBSplineCoefficients, args_info);
+ CLITK_INIT;
+
+ // Filter
+ clitk::ValuesToBSplineCoefficientsGenericFilter::Pointer genericFilter=clitk::ValuesToBSplineCoefficientsGenericFilter::New();
+
+ genericFilter->SetArgsInfo(args_info);
+ genericFilter->Update();
+
+ return EXIT_SUCCESS;
+}// end main
+
+//--------------------------------------------------------------------
--- /dev/null
+#File clitkValuesToBSplineCoefficients.ggo
+Package "clitkValuesToBSplineCoefficients"
+version "1.0"
+purpose ""
+
+option "config" - "Config file" string no
+option "verbose" v "Verbose" flag off
+
+option "input" i "Input image filename" string yes
+option "output" o "Output image filename" string yes
+
+option "order" - "Order of the BSpline coefficients" int no default="3"
--- /dev/null
+/*=========================================================================
+ 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 clitkValuesToBSplineCoefficientsGenericFilter_cxx
+#define clitkValuesToBSplineCoefficientsGenericFilter_cxx
+
+/* =================================================
+ * @file clitkValuesToBSplineCoefficientsGenericFilter.cxx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+#include "clitkValuesToBSplineCoefficientsGenericFilter.h"
+
+
+namespace clitk
+{
+
+
+ //-----------------------------------------------------------
+ // Constructor
+ //-----------------------------------------------------------
+ ValuesToBSplineCoefficientsGenericFilter::ValuesToBSplineCoefficientsGenericFilter()
+ {
+ m_Verbose=false;
+ m_InputFileName="";
+ }
+
+
+ //-----------------------------------------------------------
+ // Update
+ //-----------------------------------------------------------
+ void ValuesToBSplineCoefficientsGenericFilter::Update()
+ {
+ // Read the Dimension and PixelType
+ int Dimension, Components;
+ std::string PixelType;
+ ReadImageDimensionAndPixelType(m_InputFileName, Dimension, PixelType, Components);
+
+
+ // Call UpdateWithDim
+ if(Dimension==2) UpdateWithDim<2>(PixelType, Components);
+ else if(Dimension==3) UpdateWithDim<3>(PixelType, Components);
+ else if (Dimension==4)UpdateWithDim<4>(PixelType, Components);
+ else
+ {
+ std::cout<<"Error, Only for 2, 3 or 4 Dimensions!!!"<<std::endl ;
+ return;
+ }
+ }
+
+
+} //end clitk
+
+#endif //#define clitkValuesToBSplineCoefficientsGenericFilter_cxx
--- /dev/null
+/*=========================================================================
+ 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 clitkValuesToBSplineCoefficientsGenericFilter_h
+#define clitkValuesToBSplineCoefficientsGenericFilter_h
+
+/* =================================================
+ * @file clitkValuesToBSplineCoefficientsGenericFilter.h
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+// clitk include
+#include "clitkIO.h"
+#include "clitkCommon.h"
+#include "clitkImageCommon.h"
+#include "clitkValuesToBSplineCoefficients_ggo.h"
+
+//itk include
+#include "itkLightObject.h"
+#include "itkBSplineDecompositionImageFilter.h"
+#include "clitkVectorBSplineDecompositionImageFilter.h"
+
+namespace clitk
+{
+
+
+ class ITK_EXPORT ValuesToBSplineCoefficientsGenericFilter : public itk::LightObject
+ {
+ public:
+ //----------------------------------------
+ // ITK
+ //----------------------------------------
+ typedef ValuesToBSplineCoefficientsGenericFilter Self;
+ typedef itk::LightObject Superclass;
+ typedef itk::SmartPointer<Self> Pointer;
+ typedef itk::SmartPointer<const Self> ConstPointer;
+
+ // Method for creation through the object factory
+ itkNewMacro(Self);
+
+ // Run-time type information (and related methods)
+ itkTypeMacro( ValuesToBSplineCoefficientsGenericFilter, LightObject );
+
+
+ //----------------------------------------
+ // Typedefs
+ //----------------------------------------
+
+
+ //----------------------------------------
+ // Set & Get
+ //----------------------------------------
+ void SetArgsInfo(const args_info_clitkValuesToBSplineCoefficients & a)
+ {
+ m_ArgsInfo=a;
+ m_Verbose=m_ArgsInfo.verbose_flag;
+ m_InputFileName=m_ArgsInfo.input_arg;
+ }
+
+
+ //----------------------------------------
+ // Update
+ //----------------------------------------
+ void Update();
+
+ protected:
+
+ //----------------------------------------
+ // Constructor & Destructor
+ //----------------------------------------
+ ValuesToBSplineCoefficientsGenericFilter();
+ ~ValuesToBSplineCoefficientsGenericFilter() {};
+
+
+ //----------------------------------------
+ // Templated members
+ //----------------------------------------
+ template <unsigned int Dimension> void UpdateWithDim(std::string PixelType, unsigned int Components);
+ template <unsigned int Dimension, class PixelType> void UpdateWithDimAndPixelType();
+ template <unsigned int Dimension, class PixelType> void UpdateWithDimAndVectorType();
+
+
+ //----------------------------------------
+ // Data members
+ //----------------------------------------
+ args_info_clitkValuesToBSplineCoefficients m_ArgsInfo;
+ bool m_Verbose;
+ std::string m_InputFileName;
+
+ };
+
+
+} // end namespace clitk
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#include "clitkValuesToBSplineCoefficientsGenericFilter.txx"
+#endif
+
+#endif // #define clitkValuesToBSplineCoefficientsGenericFilter_h
--- /dev/null
+/*=========================================================================
+ 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 clitkValuesToBSplineCoefficientsGenericFilter_txx
+#define clitkValuesToBSplineCoefficientsGenericFilter_txx
+
+/* =================================================
+ * @file clitkValuesToBSplineCoefficientsGenericFilter.txx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+namespace clitk
+{
+
+ //-------------------------------------------------------------------
+ // Update with the number of dimensions
+ //-------------------------------------------------------------------
+ template<unsigned int Dimension>
+ void
+ ValuesToBSplineCoefficientsGenericFilter::UpdateWithDim(std::string PixelType, unsigned int Components)
+ {
+ if (m_Verbose) std::cout << "Image was detected to be "<<Dimension<<"D and "<<Components<<" component(s) of "<< PixelType<<"..."<<std::endl;
+
+ if (Components==1)
+ {
+ if(PixelType == "short"){
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed short..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, signed short>();
+ }
+ // else if(PixelType == "unsigned_short"){
+ // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_short..." << std::endl;
+ // UpdateWithDimAndPixelType<Dimension, unsigned short>();
+ // }
+
+ else if (PixelType == "unsigned_char"){
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_char..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, unsigned char>();
+ }
+
+ // else if (PixelType == "char"){
+ // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed_char..." << std::endl;
+ // UpdateWithDimAndPixelType<Dimension, signed char>();
+ // }
+ else {
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and float..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, float>();
+ }
+ }
+
+ else if (Components==3)
+ {
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and 3D float (DVF)" << std::endl;
+ UpdateWithDimAndVectorType<Dimension, itk::Vector<float, 3> >();
+ }
+
+ else std::cerr<<"Number of components is "<<Components<<", not supported!"<<std::endl;
+ }
+
+
+ //-------------------------------------------------------------------
+ // Update with the number of dimensions and the pixeltype
+ //-------------------------------------------------------------------
+ template <unsigned int Dimension, class PixelType>
+ void
+ ValuesToBSplineCoefficientsGenericFilter::UpdateWithDimAndPixelType()
+ {
+
+ // ImageTypes
+ typedef itk::Image<PixelType, Dimension> InputImageType;
+ typedef itk::Image<PixelType, Dimension> OutputImageType;
+
+ // Read the input
+ typedef itk::ImageFileReader<InputImageType> InputReaderType;
+ typename InputReaderType::Pointer reader = InputReaderType::New();
+ reader->SetFileName( m_InputFileName);
+ reader->Update();
+ typename InputImageType::Pointer input= reader->GetOutput();
+
+ // Filter
+ typedef itk::BSplineDecompositionImageFilter<InputImageType, OutputImageType> FilterType;
+ typename FilterType::Pointer filter=FilterType::New();
+ filter->SetInput(input);
+ filter->SetSplineOrder(m_ArgsInfo.order_arg);
+ filter->Update();
+ typename OutputImageType::Pointer output=filter->GetOutput();
+
+ // Output
+ typedef itk::ImageFileWriter<OutputImageType> WriterType;
+ typename WriterType::Pointer writer = WriterType::New();
+ writer->SetFileName(m_ArgsInfo.output_arg);
+ writer->SetInput(output);
+ writer->Update();
+
+ }
+
+
+ //-------------------------------------------------------------------
+ // Update with the number of dimensions and the Vectortype
+ //-------------------------------------------------------------------
+ template <unsigned int Dimension, class PixelType>
+ void
+ ValuesToBSplineCoefficientsGenericFilter::UpdateWithDimAndVectorType()
+ {
+
+ // ImageTypes
+ typedef itk::Image<PixelType, Dimension> InputImageType;
+ typedef itk::Image<PixelType, Dimension> OutputImageType;
+
+ // Read the input
+ typedef itk::ImageFileReader<InputImageType> InputReaderType;
+ typename InputReaderType::Pointer reader = InputReaderType::New();
+ reader->SetFileName( m_InputFileName);
+ reader->Update();
+ typename InputImageType::Pointer input= reader->GetOutput();
+
+ // Filter
+ typedef clitk::VectorBSplineDecompositionImageFilter<InputImageType, OutputImageType> FilterType;
+ typename FilterType::Pointer filter=FilterType::New();
+ filter->SetInput(input);
+ filter->SetSplineOrder(m_ArgsInfo.order_arg);
+ filter->Update();
+ typename OutputImageType::Pointer output=filter->GetOutput();
+
+ // Output
+ typedef itk::ImageFileWriter<OutputImageType> WriterType;
+ typename WriterType::Pointer writer = WriterType::New();
+ writer->SetFileName(m_ArgsInfo.output_arg);
+ writer->SetInput(output);
+ writer->Update();
+
+ }
+
+
+}//end clitk
+
+#endif //#define clitkValuesToBSplineCoefficientsGenericFilter_txx
--- /dev/null
+/*=========================================================================
+ 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 clitkVectorImageToImage.cxx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+// clitk
+#include "clitkVectorImageToImage_ggo.h"
+#include "clitkIO.h"
+#include "clitkVectorImageToImageGenericFilter.h"
+
+
+//--------------------------------------------------------------------
+int main(int argc, char * argv[]) {
+
+ // Init command line
+ GGO(clitkVectorImageToImage, args_info);
+ CLITK_INIT;
+
+ // Filter
+ clitk::VectorImageToImageGenericFilter::Pointer genericFilter=clitk::VectorImageToImageGenericFilter::New();
+
+ genericFilter->SetArgsInfo(args_info);
+ genericFilter->Update();
+
+ return EXIT_SUCCESS;
+}// end main
+
+//--------------------------------------------------------------------
--- /dev/null
+#File clitkVectorImageToImage.ggo
+Package "clitkVectorImageToImage"
+version "1.0"
+purpose "Extract a component image from a vector image"
+
+option "config" - "Config file" string no
+option "verbose" v "Verbose" flag off
+
+option "input" i "Input image filename" string yes
+option "output" o "Output image filename" string yes
+option "componentIndex" c "Component index to extract" int no default="0"
+
--- /dev/null
+/*=========================================================================
+ 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 clitkVectorImageToImageGenericFilter_cxx
+#define clitkVectorImageToImageGenericFilter_cxx
+
+/* =================================================
+ * @file clitkVectorImageToImageGenericFilter.cxx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+#include "clitkVectorImageToImageGenericFilter.h"
+
+
+namespace clitk
+{
+
+
+ //-----------------------------------------------------------
+ // Constructor
+ //-----------------------------------------------------------
+ VectorImageToImageGenericFilter::VectorImageToImageGenericFilter()
+ {
+ m_Verbose=false;
+ m_InputFileName="";
+ }
+
+
+ //-----------------------------------------------------------
+ // Update
+ //-----------------------------------------------------------
+ void VectorImageToImageGenericFilter::Update()
+ {
+ // Read the Dimension and PixelType
+ int Dimension, Components;
+ std::string PixelType;
+ ReadImageDimensionAndPixelType(m_InputFileName, Dimension, PixelType, Components);
+
+
+ // Call UpdateWithDim
+ if(Dimension==2) UpdateWithDim<2>(PixelType, Components);
+ else if(Dimension==3) UpdateWithDim<3>(PixelType, Components);
+ else if (Dimension==4)UpdateWithDim<4>(PixelType, Components);
+ else
+ {
+ std::cout<<"Error, Only for 2, 3 or 4 Dimensions!!!"<<std::endl ;
+ return;
+ }
+ }
+
+
+} //end clitk
+
+#endif //#define clitkVectorImageToImageGenericFilter_cxx
--- /dev/null
+/*=========================================================================
+ 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 clitkVectorImageToImageGenericFilter_h
+#define clitkVectorImageToImageGenericFilter_h
+
+/* =================================================
+ * @file clitkVectorImageToImageGenericFilter.h
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+// clitk include
+#include "clitkIO.h"
+#include "clitkCommon.h"
+#include "clitkImageCommon.h"
+#include "clitkVectorImageToImage_ggo.h"
+#include "clitkVectorImageToImageFilter.h"
+
+//itk include
+#include "itkLightObject.h"
+
+namespace clitk
+{
+
+
+ class ITK_EXPORT VectorImageToImageGenericFilter : public itk::LightObject
+ {
+ public:
+ //----------------------------------------
+ // ITK
+ //----------------------------------------
+ typedef VectorImageToImageGenericFilter Self;
+ typedef itk::LightObject Superclass;
+ typedef itk::SmartPointer<Self> Pointer;
+ typedef itk::SmartPointer<const Self> ConstPointer;
+
+ // Method for creation through the object factory
+ itkNewMacro(Self);
+
+ // Run-time type information (and related methods)
+ itkTypeMacro( VectorImageToImageGenericFilter, LightObject );
+
+
+ //----------------------------------------
+ // Typedefs
+ //----------------------------------------
+
+
+ //----------------------------------------
+ // Set & Get
+ //----------------------------------------
+ void SetArgsInfo(const args_info_clitkVectorImageToImage & a)
+ {
+ m_ArgsInfo=a;
+ m_Verbose=m_ArgsInfo.verbose_flag;
+ m_InputFileName=m_ArgsInfo.input_arg;
+ }
+
+
+ //----------------------------------------
+ // Update
+ //----------------------------------------
+ void Update();
+
+ protected:
+
+ //----------------------------------------
+ // Constructor & Destructor
+ //----------------------------------------
+ VectorImageToImageGenericFilter();
+ ~VectorImageToImageGenericFilter() {};
+
+
+ //----------------------------------------
+ // Templated members
+ //----------------------------------------
+ template <unsigned int Dimension> void UpdateWithDim(std::string PixelType, unsigned int Components);
+ template <unsigned int Dimension, class PixelType> void UpdateWithDimAndPixelType();
+
+
+ //----------------------------------------
+ // Data members
+ //----------------------------------------
+ args_info_clitkVectorImageToImage m_ArgsInfo;
+ bool m_Verbose;
+ std::string m_InputFileName;
+
+ };
+
+
+} // end namespace clitk
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#include "clitkVectorImageToImageGenericFilter.txx"
+#endif
+
+#endif // #define clitkVectorImageToImageGenericFilter_h
--- /dev/null
+/*=========================================================================
+ 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 clitkVectorImageToImageGenericFilter_txx
+#define clitkVectorImageToImageGenericFilter_txx
+
+/* =================================================
+ * @file clitkVectorImageToImageGenericFilter.txx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+namespace clitk
+{
+
+ //-------------------------------------------------------------------
+ // Update with the number of dimensions
+ //-------------------------------------------------------------------
+ template<unsigned int Dimension>
+ void
+ VectorImageToImageGenericFilter::UpdateWithDim(std::string PixelType, unsigned int Components)
+ {
+ if (m_Verbose) std::cout << "Image was detected to be "<<Dimension<<"D and "<< PixelType<<"..."<<std::endl;
+
+ if (Components==3)
+ {
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and 3D float..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, itk::Vector<float, 3> >();
+ }
+ else std::cerr<<"Number of components is "<<Components<<", not supported!"<<std::endl;
+ }
+
+
+ //-------------------------------------------------------------------
+ // Update with the number of dimensions and the pixeltype
+ //-------------------------------------------------------------------
+ template <unsigned int Dimension, class PixelType>
+ void
+ VectorImageToImageGenericFilter::UpdateWithDimAndPixelType()
+ {
+ // ImageTypes
+ typedef itk::Image<PixelType, Dimension> InputImageType;
+ typedef typename PixelType::ComponentType ComponentType;
+ typedef itk::Image<ComponentType, Dimension> OutputImageType;
+
+ // Read the input
+ typedef itk::ImageFileReader<InputImageType> InputReaderType;
+ typename InputReaderType::Pointer reader = InputReaderType::New();
+ reader->SetFileName( m_InputFileName);
+ reader->Update();
+ typename InputImageType::Pointer input= reader->GetOutput();
+
+ // Filter
+ typedef clitk::VectorImageToImageFilter<InputImageType, OutputImageType> FilterType;
+ typename FilterType::Pointer filter=FilterType::New();
+ filter->SetInput(input);
+ filter->SetComponentIndex(m_ArgsInfo.componentIndex_arg);
+ filter->Update();
+ typename OutputImageType::Pointer output=filter->GetOutput();
+
+ // Output
+ typedef itk::ImageFileWriter<OutputImageType> WriterType;
+ typename WriterType::Pointer writer = WriterType::New();
+ writer->SetFileName(m_ArgsInfo.output_arg);
+ writer->SetInput(output);
+ writer->Update();
+
+ }
+
+
+}//end clitk
+
+#endif //#define clitkVectorImageToImageGenericFilter_txx