ITK  4.2.0
Insight Segmentation and Registration Toolkit
itkVarianceImageFunction.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef __itkVarianceImageFunction_h
19 #define __itkVarianceImageFunction_h
20 
21 #include "itkImageFunction.h"
22 #include "itkNumericTraits.h"
23 
24 namespace itk
25 {
42 template< class TInputImage, class TCoordRep = float >
43 class ITK_EXPORT VarianceImageFunction:
44  public ImageFunction< TInputImage, typename NumericTraits< typename TInputImage::PixelType >::RealType,
45  TCoordRep >
46 {
47 public:
48 
52  TCoordRep > Superclass;
53 
56 
58  itkTypeMacro(VarianceImageFunction, ImageFunction);
59 
61  itkNewMacro(Self);
62 
64  typedef TInputImage InputImageType;
65 
67  typedef typename Superclass::OutputType OutputType;
68 
70  typedef typename Superclass::IndexType IndexType;
71 
73  typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
74 
76  typedef typename Superclass::PointType PointType;
77 
79  itkStaticConstMacro(ImageDimension, unsigned int,
80  InputImageType::ImageDimension);
81 
85 
87  virtual RealType EvaluateAtIndex(const IndexType & index) const;
88 
90  virtual RealType Evaluate(const PointType & point) const
91  {
92  IndexType index;
93 
94  this->ConvertPointToNearestIndex(point, index);
95  return this->EvaluateAtIndex(index);
96  }
97 
98  virtual RealType EvaluateAtContinuousIndex(
99  const ContinuousIndexType & cindex) const
100  {
101  IndexType index;
102 
103  this->ConvertContinuousIndexToNearestIndex(cindex, index);
104  return this->EvaluateAtIndex(index);
105  }
106 
109  itkSetMacro(NeighborhoodRadius, unsigned int);
110  itkGetConstReferenceMacro(NeighborhoodRadius, unsigned int);
111 protected:
114  void PrintSelf(std::ostream & os, Indent indent) const;
116 
117 private:
118  VarianceImageFunction(const Self &); //purposely not implemented
119  void operator=(const Self &); //purposely not implemented
120 
121  unsigned int m_NeighborhoodRadius;
122 };
123 } // end namespace itk
124 
125 // Define instantiation macro for this template.
126 #define ITK_TEMPLATE_VarianceImageFunction(_, EXPORT, TypeX, TypeY) \
127  namespace itk \
128  { \
129  _( 2 ( class EXPORT VarianceImageFunction< ITK_TEMPLATE_2 TypeX > ) ) \
130  namespace Templates \
131  { \
132  typedef VarianceImageFunction< ITK_TEMPLATE_2 TypeX > \
133  VarianceImageFunction##TypeY; \
134  } \
135  }
136 
137 #if ITK_TEMPLATE_EXPLICIT
138 #include "Templates/itkVarianceImageFunction+-.h"
139 #endif
140 
141 #if ITK_TEMPLATE_TXX
142 #include "itkVarianceImageFunction.hxx"
143 #endif
144 
145 #endif
146