00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkFiniteDifferenceImageFilter_h_
00018 #define __itkFiniteDifferenceImageFilter_h_
00019
00020 #include "itkInPlaceImageFilter.h"
00021 #include "itkFiniteDifferenceFunction.h"
00022
00023 namespace itk {
00024
00121 template <class TInputImage, class TOutputImage>
00122 class ITK_EXPORT FiniteDifferenceImageFilter
00123 : public InPlaceImageFilter<TInputImage, TOutputImage>
00124 {
00125 public:
00126
00128 typedef FiniteDifferenceImageFilter Self;
00129 typedef InPlaceImageFilter<TInputImage, TOutputImage> Superclass;
00130 typedef SmartPointer<Self> Pointer;
00131 typedef SmartPointer<const Self> ConstPointer;
00132
00134 itkTypeMacro(FiniteDifferenceImageFilter, InPlaceImageFilter );
00135
00137 typedef TInputImage InputImageType;
00138 typedef TOutputImage OutputImageType;
00139
00141 itkStaticConstMacro(ImageDimension, unsigned int,
00142 OutputImageType::ImageDimension);
00143
00145 typedef typename TOutputImage::PixelType OutputPixelType;
00146 typedef typename TInputImage::PixelType InputPixelType;
00147 typedef OutputPixelType PixelType;
00148
00150 typedef typename NumericTraits< OutputPixelType >::ValueType OutputPixelValueType;
00151 typedef typename NumericTraits< InputPixelType >::ValueType InputPixelValueType;
00152
00156 typedef FiniteDifferenceFunction<TOutputImage> FiniteDifferenceFunctionType;
00157 typedef typename FiniteDifferenceFunctionType::TimeStepType TimeStepType;
00158
00159 typedef enum { UNINITIALIZED = 0, INITIALIZED = 1 } FilterStateType;
00160
00162 itkGetConstReferenceMacro(ElapsedIterations, unsigned int);
00163
00167 itkGetConstReferenceObjectMacro(DifferenceFunction,
00168 FiniteDifferenceFunctionType );
00169
00173 itkSetObjectMacro(DifferenceFunction, FiniteDifferenceFunctionType );
00174
00175
00177 itkSetMacro(NumberOfIterations, unsigned int);
00178 itkGetConstReferenceMacro(NumberOfIterations, unsigned int);
00180
00183 itkSetMacro(UseImageSpacing,bool);
00184 itkBooleanMacro(UseImageSpacing);
00185 itkGetConstReferenceMacro(UseImageSpacing, bool);
00187
00190 itkSetMacro(MaximumRMSError, double);
00191 itkGetConstReferenceMacro(MaximumRMSError, double);
00193
00196 itkSetMacro(RMSChange, double);
00197 itkGetConstReferenceMacro(RMSChange, double);
00199
00201 void SetStateToInitialized()
00202 {
00203 this->SetState(INITIALIZED);
00204 }
00205
00207 void SetStateToUninitialized()
00208 {
00209 this->SetState(UNINITIALIZED);
00210 }
00211
00213 itkSetMacro(State, FilterStateType);
00214 itkGetConstReferenceMacro(State, FilterStateType);
00216
00219 itkSetMacro(ManualReinitialization, bool);
00220 itkGetConstReferenceMacro(ManualReinitialization, bool);
00221 itkBooleanMacro(ManualReinitialization);
00223
00224 #ifdef ITK_USE_STRICT_CONCEPT_CHECKING
00225
00226 itkConceptMacro(OutputPixelIsFloatingPointCheck,
00227 (Concept::IsFloatingPoint<OutputPixelValueType>));
00228
00230 #endif
00231
00232 protected:
00233 FiniteDifferenceImageFilter()
00234 {
00235 m_UseImageSpacing = false;
00236 m_ElapsedIterations = 0;
00237 m_DifferenceFunction = 0;
00238 m_NumberOfIterations = NumericTraits<unsigned int>::max();
00239 m_MaximumRMSError = 0.0;
00240 m_RMSChange = 0.0;
00241 m_State = UNINITIALIZED;
00242 m_ManualReinitialization = false;
00243 this->InPlaceOff();
00244 }
00245 ~FiniteDifferenceImageFilter() {}
00246 void PrintSelf(std::ostream& os, Indent indent) const;
00247
00249 virtual void AllocateUpdateBuffer() = 0;
00250
00254 virtual void ApplyUpdate(TimeStepType dt) = 0;
00255
00261 virtual TimeStepType CalculateChange() = 0;
00262
00266 virtual void CopyInputToOutput() = 0;
00267
00271 virtual void GenerateData();
00272
00284 virtual void GenerateInputRequestedRegion();
00285
00288 virtual bool Halt();
00289
00299 virtual bool ThreadedHalt(void *itkNotUsed(threadInfo)) { return this->Halt(); }
00300
00306 virtual void Initialize() { };
00307
00314 virtual void InitializeIteration()
00315 { m_DifferenceFunction->InitializeIteration(); }
00316
00330 virtual TimeStepType ResolveTimeStep(const TimeStepType* timeStepList,
00331 const bool* valid,int size);
00332
00334 itkSetMacro(ElapsedIterations, unsigned int);
00335
00338 virtual void PostProcessOutput() {}
00339
00341 unsigned int m_NumberOfIterations;
00342
00343 double m_RMSChange;
00344 double m_MaximumRMSError;
00345
00346 private:
00347 FiniteDifferenceImageFilter(const Self&);
00348 void operator=(const Self&);
00349
00352 unsigned int m_ElapsedIterations;
00353
00356 bool m_UseImageSpacing;
00357
00360 bool m_ManualReinitialization;
00361
00363 typename FiniteDifferenceFunctionType::Pointer m_DifferenceFunction;
00364
00366 FilterStateType m_State;
00367 };
00368
00369 }
00370
00371
00372 #define ITK_TEMPLATE_FiniteDifferenceImageFilter(_, EXPORT, x, y) namespace itk { \
00373 _(2(class EXPORT FiniteDifferenceImageFilter< ITK_TEMPLATE_2 x >)) \
00374 namespace Templates { typedef FiniteDifferenceImageFilter< ITK_TEMPLATE_2 x > \
00375 FiniteDifferenceImageFilter##y; } \
00376 }
00377
00378 #if ITK_TEMPLATE_EXPLICIT
00379 # include "Templates/itkFiniteDifferenceImageFilter+-.h"
00380 #endif
00381
00382 #if ITK_TEMPLATE_TXX
00383 # include "itkFiniteDifferenceImageFilter.txx"
00384 #endif
00385
00386 #endif
00387