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: 2009-02-05 19:04:56 $
00007   Version:   $Revision: 1.40 $
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, OutputImageType::ImageDimension);
00142 
00144   typedef typename TOutputImage::PixelType    OutputPixelType;
00145   typedef typename TInputImage::PixelType     InputPixelType;
00146   typedef OutputPixelType                     PixelType;
00147 
00149   typedef typename NumericTraits< OutputPixelType >::ValueType OutputPixelValueType;
00150   typedef typename NumericTraits< InputPixelType >::ValueType  InputPixelValueType;
00151 
00155   typedef FiniteDifferenceFunction<TOutputImage> FiniteDifferenceFunctionType;
00156   typedef typename FiniteDifferenceFunctionType::TimeStepType TimeStepType;
00157 
00158   typedef typename FiniteDifferenceFunctionType::RadiusType RadiusType;
00159   typedef typename FiniteDifferenceFunctionType::NeighborhoodScalesType NeighborhoodScalesType;
00160 
00161   typedef enum { UNINITIALIZED = 0, INITIALIZED = 1 } FilterStateType;
00162   
00164   itkGetConstReferenceMacro(ElapsedIterations, unsigned int);
00165 
00169   itkGetConstReferenceObjectMacro(DifferenceFunction,
00170                                   FiniteDifferenceFunctionType );
00171 
00175   itkSetObjectMacro(DifferenceFunction, FiniteDifferenceFunctionType );
00176 
00177 
00179   itkSetMacro(NumberOfIterations, unsigned int);
00180   itkGetConstReferenceMacro(NumberOfIterations, unsigned int);
00182 
00185   itkSetMacro(UseImageSpacing,bool);
00186   itkBooleanMacro(UseImageSpacing);
00187   itkGetConstReferenceMacro(UseImageSpacing, bool);
00189 
00192   itkSetMacro(MaximumRMSError, double);
00193   itkGetConstReferenceMacro(MaximumRMSError, double);
00195 
00198   itkSetMacro(RMSChange, double);
00199   itkGetConstReferenceMacro(RMSChange, double);
00201 
00203   void SetStateToInitialized()
00204     {
00205     this->SetState(INITIALIZED);
00206     }
00207 
00209   void SetStateToUninitialized()
00210     {
00211     this->SetState(UNINITIALIZED);
00212     }
00213 
00215 #if !defined(CABLE_CONFIGURATION)
00216   itkSetMacro(State, FilterStateType);
00217   itkGetConstReferenceMacro(State, FilterStateType);
00218 #endif
00219 
00220 
00223   itkSetMacro(ManualReinitialization, bool);
00224   itkGetConstReferenceMacro(ManualReinitialization, bool);
00225   itkBooleanMacro(ManualReinitialization);
00227 
00228 #ifdef ITK_USE_STRICT_CONCEPT_CHECKING
00229 
00230   itkConceptMacro(OutputPixelIsFloatingPointCheck,
00231     (Concept::IsFloatingPoint<OutputPixelValueType>));
00232 
00234 #endif
00235 
00236 protected:
00237   FiniteDifferenceImageFilter()
00238     {
00239     m_UseImageSpacing    = false;
00240     m_ElapsedIterations  = 0;
00241     m_DifferenceFunction = 0;
00242     m_NumberOfIterations = NumericTraits<unsigned int>::max();
00243     m_MaximumRMSError = 0.0;
00244     m_RMSChange = 0.0;
00245     m_State = UNINITIALIZED;
00246     m_ManualReinitialization = false;
00247     this->InPlaceOff();
00248     }
00249   ~FiniteDifferenceImageFilter() {}
00250   void PrintSelf(std::ostream& os, Indent indent) const;
00251 
00253   virtual void AllocateUpdateBuffer() = 0;
00254 
00258   virtual void ApplyUpdate(TimeStepType dt) = 0;
00259 
00265   virtual TimeStepType CalculateChange() = 0;
00266 
00270   virtual void CopyInputToOutput() = 0;
00271 
00275   virtual void GenerateData();
00276 
00288   virtual void GenerateInputRequestedRegion();
00289 
00292   virtual bool Halt();
00293 
00303   virtual bool ThreadedHalt(void *itkNotUsed(threadInfo)) { return this->Halt(); }
00304 
00310   virtual void Initialize() { };
00311 
00318   virtual void InitializeIteration()
00319     { m_DifferenceFunction->InitializeIteration(); }
00320 
00334   virtual TimeStepType ResolveTimeStep(const TimeStepType* timeStepList, 
00335                                        const bool* valid,int size);
00336 
00338   itkSetMacro(ElapsedIterations, unsigned int);
00339 
00342   virtual void PostProcessOutput() {}
00343 
00345   unsigned int  m_NumberOfIterations;
00346 
00349   unsigned int m_ElapsedIterations;
00350 
00353   bool m_ManualReinitialization;
00354 
00355   double m_RMSChange;  
00356   double m_MaximumRMSError;
00357 
00358 private:
00359   FiniteDifferenceImageFilter(const Self&); //purposely not implemented
00360   void operator=(const Self&); //purposely not implemented
00361 
00362 
00365   bool m_UseImageSpacing;
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 Thu May 28 09:57:02 2009 for ITK by doxygen 1.5.5 written by Dimitri van Heesch, © 1997-2000