KWStyle - itkFiniteDifferenceSparseImageFunction.h
 
Matrix View
Description

1 /*=========================================================================
2
3   Program:   Insight Segmentation & Registration Toolkit
4   Module:    $RCSfile: itkFiniteDifferenceSparseImageFunction.h.html,v $
5   Language:  C++
6   Date:      $Date: 2006/01/17 19:15:35 $
7   Version:   $Revision: 1.4 $
8
9   Copyright (c) Insight Software Consortium. All rights reserved.
10   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11
12      This software is distributed WITHOUT ANY WARRANTY; without even 
13      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
14      PURPOSE.  See the above copyright notices for more information.
15
16 =========================================================================*/
17 DEF #ifndef __itkFiniteDifferenceSparseImageFunction_h_
18 DEF #define __itkFiniteDifferenceSparseImageFunction_h_
19
20 #include "itkFiniteDifferenceFunction.h"
21
22 namespace itk {
23
24 /**
25  * \class FiniteDifferenceSparseImageFunction
26  *
27  * \brief This is the base class for function classes that can be used with 
28  * filters derived from FiniteDifferenceSparseImageFilter.
29  *
30  * \par This class is derived from FiniteDifferenceFunction. It is designed to
31  *work with neighborhoods of pointers instead of actual data. Towards this
32  *purpose ComputeUpdate method is no longer used and is replaced by the
33  *ComputeSparseUpdate method. ComputeSparseUpdate assumes that the pointers are
34  *associated with structures that have the member variable m_Data. The pointers
35  *would normally originate from a SparseImage object.
36  *
37  * \par The PrecomputeSparseUpdate method can be defined to do a first pass of
38  *computations which then can be used by ComputeSparseUpdate. If
39  *PrecomputeSparseUpdate is used then the m_PrecomputeFlag should be set in the
40  *FiniteDifferenceSparseImageFilter class. The precomputation step can be used
41  *to speed up computation by avoiding repetitions. See the
42  *NormalVectorDiffusionFunction for an example. 
43  */
44 template <class TSparseImageType>
45 class ITK_EXPORT FiniteDifferenceSparseImageFunction
46 IND **:public FiniteDifferenceFunction <TSparseImageType>
47 {
48 public:
49   /** Standard class typedef. */
50   typedef FiniteDifferenceSparseImageFunction Self;
51 TDA   typedef FiniteDifferenceFunction<TSparseImageType> Superclass;
52 TDA   typedef SmartPointer<Self> Pointer;
53 TDA   typedef SmartPointer<const Self> ConstPointer;
54
55   /** Run-time type information (and related methods) */
56   itkTypeMacro( FiniteDifferenceSparseImageFunction, FiniteDifferenceFunction );
57    
58   /** The image dimension. */
59   itkStaticConstMacro(ImageDimension, unsigned int, Superclass::ImageDimension);
60   
61   /** Typedefs from the superclass. */
62   typedef typename Superclass::PixelType        PixelType;
63   typedef typename Superclass::TimeStepType     TimeStepType;
64   typedef typename Superclass::RadiusType       RadiusType;
65   typedef typename Superclass::NeighborhoodType NeighborhoodType;
66   typedef typename Superclass::FloatOffsetType  FloatOffsetType;
67   typedef typename Superclass::ImageType        SparseImageType;
68
69   /** The index type for the sparse image. */
70   typedef typename SparseImageType::IndexType   IndexType;
71
72   /** The actual type of nodes stored the sparse image.*/
73   typedef typename SparseImageType::NodeType NodeType;
74
75   /** The type for the variables of NodeType. Scalar or vector. */
76   typedef typename NodeType::NodeDataType    NodeDataType;
77   
78   /** This function is not called from the FiniteDifferenceSparseImageFilter
79    *  class because we need to work with neighborhoods of pointers to data
80    *  variables instead of neighborhoods of data directly. This function is
81    *  replaced by the ComputeSparseUpdate function. */
82   virtual PixelType ComputeUpdate(const NeighborhoodType&,
83                                   void*,
84                                   const FloatOffsetType&)
85 IND **{
86     return static_cast<PixelType>(0);
87 IND **}
88
89   /** The update called from the FiniteDifferenceSparseImageFilter. This
90 IND ******function replaces the ComputeUpdate function. */
91   virtual NodeDataType
92   ComputeSparseUpdate(NeighborhoodType &neighborhood,
93                       void *globalData,
94                       const FloatOffsetType &offset = FloatOffsetType(0.0))
95 IND ****const = 0;
96
97   /** This function provides support for a 2 step update computation that
98    *  avoids repetitive computation. FiniteDifferenceSparseImageFilter first
99    *  calls this function for all active pixels in the SparseImage class, then
100    *  calls ComputeSparseUpdate for the same set of pixels. This is used in
101    *  NormalVectorDiffusionFunction to calculate flux variables which are then
102    *  used to compute the updates. Intermediate variables such as the flux in
103    *  the above examples are stored in the nodes of the SparseImage
104    *  itself. Therefore, this function will have to know about the NodeType it
105    *  is dealing with. This function does nothing by default. */
106   virtual void PrecomputeSparseUpdate( NeighborhoodType& ) const {};
107
108 protected:
109   FiniteDifferenceSparseImageFunction() {};
110   ~FiniteDifferenceSparseImageFunction() {};
111   void PrintSelf(std::ostream& os, Indent indent) const;
112   
113 private:
114   FiniteDifferenceSparseImageFunction(const Self&); //purposely not implemented
115   void operator=(const Self&); //purposely not implemented
116 };
117
118 // end namespace itk
119
120 #ifndef ITK_MANUAL_INSTANTIATION
121 #include "itkFiniteDifferenceSparseImageFunction.txx"
122 #endif
123
124 #endif
125

Generated by KWStyle 1.0b on Tuesday January,17 at 02:14:08PM
© Kitware Inc.