1 /*=========================================================================
2 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
5 - University of LYON http://www.universite-lyon.fr/
6 - Léon Bérard cancer center http://www.centreleonberard.fr
7 - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
9 This software is distributed WITHOUT ANY WARRANTY; without even
10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 PURPOSE. See the copyright notices for more information.
13 It is distributed under dual licence
15 - BSD See included LICENSE.txt file
16 - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ===========================================================================**/
18 #ifndef __clitkSpatioTemporalMultiResolutionPyramidImageFilter_h
19 #define __clitkSpatioTemporalMultiResolutionPyramidImageFilter_h
20 #include "itkImageToImageFilter.h"
21 #include "itkArray2D.h"
26 template < class TInputImage, class TOutputImage >
27 class ITK_EXPORT SpatioTemporalMultiResolutionPyramidImageFilter :
28 public itk::ImageToImageFilter< TInputImage, TOutputImage >
32 /** Standard class typedefs. */
33 typedef SpatioTemporalMultiResolutionPyramidImageFilter Self;
34 typedef itk::ImageToImageFilter<TInputImage,TOutputImage> Superclass;
35 typedef itk::SmartPointer<Self> Pointer;
36 typedef itk::SmartPointer<const Self> ConstPointer;
38 /** Method for creation through the object factory. */
41 /** Run-time type information (and related methods). */
42 itkTypeMacro(SpatioTemporalMultiResolutionPyramidImageFilter, ImageToImageFilter);
44 /** ScheduleType typedef support. */
45 typedef itk::Array2D<unsigned int> ScheduleType;
47 /** ImageDimension enumeration. */
48 itkStaticConstMacro(ImageDimension, unsigned int,
49 TInputImage::ImageDimension);
50 itkStaticConstMacro(OutputImageDimension, unsigned int,
51 TOutputImage::ImageDimension);
53 /** Inherit types from Superclass. */
54 typedef typename Superclass::InputImageType InputImageType;
55 typedef typename Superclass::OutputImageType OutputImageType;
56 typedef typename Superclass::InputImagePointer InputImagePointer;
57 typedef typename Superclass::OutputImagePointer OutputImagePointer;
58 typedef typename Superclass::InputImageConstPointer InputImageConstPointer;
60 /** Set the number of multi-resolution levels. The matrix containing the
61 * schedule will be resized accordingly. The schedule is populated with
62 * default values. At the coarset (0) level, the shrink factors are set
63 * 2^(nlevel - 1) for all dimension. These shrink factors are halved for
64 * subsequent levels. The number of levels is clamped to a minimum value
65 * of 1. All shrink factors are also clamped to a minimum value of 1. */
66 virtual void SetNumberOfLevels(unsigned int num);
68 /** Get the number of multi-resolution levels. */
69 itkGetConstMacro(NumberOfLevels, unsigned int);
71 /** Set a multi-resolution schedule. The input schedule must have only
72 * ImageDimension number of columns and NumberOfLevels number of rows. For
73 * each dimension, the shrink factor must be non-increasing with respect to
74 * subsequent levels. This function will clamp shrink factors to satisify
75 * this condition. All shrink factors less than one will also be clamped
76 * to the value of 1. */
77 virtual void SetSchedule( const ScheduleType& schedule );
79 /** Get the multi-resolution schedule. */
80 itkGetConstReferenceMacro(Schedule, ScheduleType);
82 /** Set the starting shrink factor for the coarset (0) resolution
83 * level. The schedule is then populated with defaults values obtained by
84 * halving the factors at the previous level. All shrink factors are
85 * clamped to a minimum value of 1. */
86 virtual void SetStartingShrinkFactors( unsigned int factor );
87 virtual void SetStartingShrinkFactors( unsigned int* factors );
89 /** Get the starting shrink factors */
90 const unsigned int * GetStartingShrinkFactors() const;
92 /** Test if the schedule is downward divisible. This method returns true if
93 * at every level, the shrink factors are divisble by the shrink factors at
95 static bool IsScheduleDownwardDivisible( const ScheduleType& schedule );
97 /** MultiResolutionPyramidImageFilter produces images which are of
98 * different resolution and different pixel spacing than its input image.
99 * As such, MultiResolutionPyramidImageFilter needs to provide an
100 * implementation for GenerateOutputInformation() in order to inform the
101 * pipeline execution model. The original documentation of this method is
102 * below. \sa ProcessObject::GenerateOutputInformaton() */
103 virtual void GenerateOutputInformation();
105 /** Given one output whose requested region has been set, this method sets
106 * the requested region for the remaining output images. The original
107 * documentation of this method is below. \sa
108 * ProcessObject::GenerateOutputRequestedRegion(); */
109 virtual void GenerateOutputRequestedRegion(itk::DataObject *output);
111 /** MultiResolutionPyramidImageFilter requires a larger input requested
112 * region than the output requested regions to accomdate the shrinkage and
113 * smoothing operations. As such, MultiResolutionPyramidImageFilter needs
114 * to provide an implementation for GenerateInputRequestedRegion(). The
115 * original documentation of this method is below. \sa
116 * ProcessObject::GenerateInputRequestedRegion() */
117 virtual void GenerateInputRequestedRegion();
119 itkSetMacro(MaximumError,double);
120 itkGetConstReferenceMacro(MaximumError,double);
122 itkSetMacro(UseShrinkImageFilter,bool);
123 itkGetConstMacro(UseShrinkImageFilter,bool);
124 itkBooleanMacro(UseShrinkImageFilter);
127 #ifdef ITK_USE_CONCEPT_CHECKING
128 /** Begin concept checking */
129 itkConceptMacro(SameDimensionCheck,
130 (itk::Concept::SameDimension<ImageDimension, OutputImageDimension>));
131 itkConceptMacro(OutputHasNumericTraitsCheck,
132 (itk::Concept::HasNumericTraits<typename TOutputImage::PixelType>));
133 /** End concept checking */
137 SpatioTemporalMultiResolutionPyramidImageFilter();
138 ~SpatioTemporalMultiResolutionPyramidImageFilter() {};
139 void PrintSelf(std::ostream&os, itk::Indent indent) const;
141 /** Generate the output data. */
144 double m_MaximumError;
145 unsigned int m_NumberOfLevels;
146 ScheduleType m_Schedule;
147 bool m_UseShrinkImageFilter;
150 SpatioTemporalMultiResolutionPyramidImageFilter(const Self&); //purposely not implemented
151 void operator=(const Self&); //purposely not implemented
158 #ifndef ITK_MANUAL_INSTANTIATION
159 #include "clitkSpatioTemporalMultiResolutionPyramidImageFilter.txx"