ITK  4.8.0
Insight Segmentation and Registration Toolkit
itkSumOfSquaresImageFunction.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 itkSumOfSquaresImageFunction_h
19 #define itkSumOfSquaresImageFunction_h
20 
21 #include "itkImageFunction.h"
22 #include "itkNumericTraits.h"
23 #include "itkNeighborhood.h"
24 
25 namespace itk
26 {
43 template< typename TInputImage, typename TCoordRep = float >
45  public ImageFunction< TInputImage, typename NumericTraits< typename TInputImage::PixelType >::RealType,
46  TCoordRep >
47 {
48 public:
49 
53  TCoordRep > Superclass;
54 
57 
60 
62  itkNewMacro(Self);
63 
65  typedef TInputImage InputImageType;
66 
69 
71  typedef typename Superclass::IndexType IndexType;
72 
75 
77  typedef typename Superclass::PointType PointType;
78 
80  itkStaticConstMacro(ImageDimension, unsigned int,
81  InputImageType::ImageDimension);
82 
86 
88  virtual RealType EvaluateAtIndex(const IndexType & index) const ITK_OVERRIDE;
89 
91  virtual RealType Evaluate(const PointType & point) const ITK_OVERRIDE
92  {
93  IndexType index;
94 
95  this->ConvertPointToNearestIndex(point, index);
96  return this->EvaluateAtIndex(index);
97  }
98 
100  const ContinuousIndexType & cindex) const ITK_OVERRIDE
101  {
102  IndexType index;
103 
104  this->ConvertContinuousIndexToNearestIndex(cindex, index);
105  return this->EvaluateAtIndex(index);
106  }
107 
110  itkGetConstReferenceMacro(NeighborhoodRadius, unsigned int);
111 
112  void SetNeighborhoodRadius(unsigned int radius)
113  {
114  m_NeighborhoodRadius = radius;
115 
116  m_NeighborhoodSize = 1;
117  long twoRPlus1 = 2 * m_NeighborhoodRadius + 1;
118  for ( unsigned int i = 0; i < ImageDimension; i++ )
119  {
120  m_NeighborhoodSize *= twoRPlus1;
121  }
122  }
123 
124  itkGetConstReferenceMacro(NeighborhoodSize, unsigned int);
125 
126 protected:
129  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
130 
131 private:
132  SumOfSquaresImageFunction(const Self &); //purposely not implemented
133  void operator=(const Self &); //purposely not implemented
134 
135  unsigned int m_NeighborhoodRadius;
136  unsigned int m_NeighborhoodSize;
137 };
138 } // end namespace itk
139 
140 #ifndef ITK_MANUAL_INSTANTIATION
141 #include "itkSumOfSquaresImageFunction.hxx"
142 #endif
143 
144 #endif
NumericTraits< typename InputImageType::PixelType >::RealType RealType
Calculate the sum of squares in the neighborhood of a pixel.
Light weight base class for most itk classes.
Point< TCoordRep, itkGetStaticConstMacro(ImageDimension) > PointType
virtual RealType EvaluateAtContinuousIndex(const ContinuousIndexType &cindex) const override
Superclass::ContinuousIndexType ContinuousIndexType
virtual RealType EvaluateAtIndex(const IndexType &index) const override
ImageFunction< TInputImage, typename NumericTraits< typename TInputImage::PixelType >::RealType, TCoordRep > Superclass
InputImageType::IndexType IndexType
ContinuousIndex< TCoordRep, itkGetStaticConstMacro(ImageDimension) > ContinuousIndexType
void operator=(const Self &)
Control indentation during Print() invocation.
Definition: itkIndent.h:49
void ConvertContinuousIndexToNearestIndex(const ContinuousIndexType &cindex, IndexType &index) const
void PrintSelf(std::ostream &os, Indent indent) const override
Evaluates a function of an image at specified position.
virtual RealType Evaluate(const PointType &point) const override
void SetNeighborhoodRadius(unsigned int radius)