Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkFiniteDifferenceImageFilter.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkFiniteDifferenceImageFilter.h,v $
00005   Language:  C++
00006   Date:      $Date: 2008-03-03 13:58:50 $
00007   Version:   $Revision: 1.37 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even 
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00014      PURPOSE.  See the above copyright notices for more information.
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 typename FiniteDifferenceFunctionType::RadiusType RadiusType;
00160   typedef typename FiniteDifferenceFunctionType::NeighborhoodScalesType NeighborhoodScalesType;
00161 
00162   typedef enum { UNINITIALIZED = 0, INITIALIZED = 1 } FilterStateType;
00163   
00165   itkGetConstReferenceMacro(ElapsedIterations, unsigned int);
00166 
00170   itkGetConstReferenceObjectMacro(DifferenceFunction,
00171                                   FiniteDifferenceFunctionType );
00172 
00176   itkSetObjectMacro(DifferenceFunction, FiniteDifferenceFunctionType );
00177 
00178 
00180   itkSetMacro(NumberOfIterations, unsigned int);
00181   itkGetConstReferenceMacro(NumberOfIterations, unsigned int);
00183 
00186   itkSetMacro(UseImageSpacing,bool);
00187   itkBooleanMacro(UseImageSpacing);
00188   itkGetConstReferenceMacro(UseImageSpacing, bool);
00190 
00193   itkSetMacro(MaximumRMSError, double);
00194   itkGetConstReferenceMacro(MaximumRMSError, double);
00196 
00199   itkSetMacro(RMSChange, double);
00200   itkGetConstReferenceMacro(RMSChange, double);
00202 
00204   void SetStateToInitialized()
00205   {
00206     this->SetState(INITIALIZED);
00207   }
00208 
00210   void SetStateToUninitialized()
00211   {
00212     this->SetState(UNINITIALIZED);
00213   }
00214 
00216 #if !defined(CABLE_CONFIGURATION)
00217   itkSetMacro(State, FilterStateType);
00218   itkGetConstReferenceMacro(State, FilterStateType);
00219 #endif
00220 
00221 
00224   itkSetMacro(ManualReinitialization, bool);
00225   itkGetConstReferenceMacro(ManualReinitialization, bool);
00226   itkBooleanMacro(ManualReinitialization);
00228 
00229 #ifdef ITK_USE_STRICT_CONCEPT_CHECKING
00230 
00231   itkConceptMacro(OutputPixelIsFloatingPointCheck,
00232     (Concept::IsFloatingPoint<OutputPixelValueType>));
00233 
00235 #endif
00236 
00237 protected:
00238   FiniteDifferenceImageFilter()
00239   {
00240     m_UseImageSpacing    = false;
00241     m_ElapsedIterations  = 0;
00242     m_DifferenceFunction = 0;
00243     m_NumberOfIterations = NumericTraits<unsigned int>::max();
00244     m_MaximumRMSError = 0.0;
00245     m_RMSChange = 0.0;
00246     m_State = UNINITIALIZED;
00247     m_ManualReinitialization = false;
00248     this->InPlaceOff();
00249   }
00250   ~FiniteDifferenceImageFilter() {}
00251   void PrintSelf(std::ostream& os, Indent indent) const;
00252 
00254   virtual void AllocateUpdateBuffer() = 0;
00255 
00259   virtual void ApplyUpdate(TimeStepType dt) = 0;
00260 
00266   virtual TimeStepType CalculateChange() = 0;
00267 
00271   virtual void CopyInputToOutput() = 0;
00272 
00276   virtual void GenerateData();
00277 
00289   virtual void GenerateInputRequestedRegion();
00290 
00293   virtual bool Halt();
00294 
00304   virtual bool ThreadedHalt(void *itkNotUsed(threadInfo)) { return this->Halt(); }
00305 
00311   virtual void Initialize() { };
00312 
00319   virtual void InitializeIteration()
00320     { m_DifferenceFunction->InitializeIteration(); }
00321 
00335   virtual TimeStepType ResolveTimeStep(const TimeStepType* timeStepList, 
00336                                        const bool* valid,int size);
00337 
00339   itkSetMacro(ElapsedIterations, unsigned int);
00340 
00343   virtual void PostProcessOutput() {}
00344 
00346   unsigned int  m_NumberOfIterations;
00347 
00348   double m_RMSChange;  
00349   double m_MaximumRMSError;
00350 
00351 private:
00352   FiniteDifferenceImageFilter(const Self&); //purposely not implemented
00353   void operator=(const Self&); //purposely not implemented
00354 
00357   unsigned int m_ElapsedIterations;
00358 
00361   bool m_UseImageSpacing;
00362 
00365   bool m_ManualReinitialization;
00366 
00368   typename FiniteDifferenceFunctionType::Pointer m_DifferenceFunction;
00369 
00371   FilterStateType m_State;
00372 };
00373 
00374 }// end namespace itk
00375 
00376 // Define instantiation macro for this template.
00377 #define ITK_TEMPLATE_FiniteDifferenceImageFilter(_, EXPORT, x, y) namespace itk { \
00378   _(2(class EXPORT FiniteDifferenceImageFilter< ITK_TEMPLATE_2 x >)) \
00379   namespace Templates { typedef FiniteDifferenceImageFilter< ITK_TEMPLATE_2 x > \
00380                                             FiniteDifferenceImageFilter##y; } \
00381   }
00382 
00383 #if ITK_TEMPLATE_EXPLICIT
00384 # include "Templates/itkFiniteDifferenceImageFilter+-.h"
00385 #endif
00386 
00387 #if ITK_TEMPLATE_TXX
00388 # include "itkFiniteDifferenceImageFilter.txx"
00389 #endif
00390 
00391 #endif
00392 

Generated at Tue Jul 29 20:01:21 2008 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000