ITK  5.0.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 >
44 class ITK_TEMPLATE_EXPORT SumOfSquaresImageFunction:
45  public ImageFunction< TInputImage, typename NumericTraits< typename TInputImage::PixelType >::RealType,
46  TCoordRep >
47 {
48 public:
49  ITK_DISALLOW_COPY_AND_ASSIGN(SumOfSquaresImageFunction);
50 
54  TCoordRep >;
55 
58 
61 
63  itkNewMacro(Self);
64 
66  using InputImageType = TInputImage;
67 
69  using OutputType = typename Superclass::OutputType;
70 
72  using IndexType = typename Superclass::IndexType;
73 
75  using ContinuousIndexType = typename Superclass::ContinuousIndexType;
76 
78  using PointType = typename Superclass::PointType;
79 
81  static constexpr unsigned int ImageDimension = InputImageType::ImageDimension;
82 
85 
87  RealType EvaluateAtIndex(const IndexType & index) const override;
88 
90  RealType Evaluate(const PointType & point) const override
91  {
92  IndexType index;
93 
94  this->ConvertPointToNearestIndex(point, index);
95  return this->EvaluateAtIndex(index);
96  }
97 
99  const ContinuousIndexType & cindex) const override
100  {
101  IndexType index;
102 
103  this->ConvertContinuousIndexToNearestIndex(cindex, index);
104  return this->EvaluateAtIndex(index);
105  }
106 
109  itkGetConstReferenceMacro(NeighborhoodRadius, unsigned int);
110 
111  void SetNeighborhoodRadius(unsigned int radius)
112  {
113  m_NeighborhoodRadius = radius;
114 
115  m_NeighborhoodSize = 1;
116  long twoRPlus1 = 2 * m_NeighborhoodRadius + 1;
117  for ( unsigned int i = 0; i < ImageDimension; i++ )
118  {
119  m_NeighborhoodSize *= twoRPlus1;
120  }
121  }
122 
123  itkGetConstReferenceMacro(NeighborhoodSize, unsigned int);
124 
125 protected:
127  ~SumOfSquaresImageFunction() override = default;
128  void PrintSelf(std::ostream & os, Indent indent) const override;
129 
130 private:
131  unsigned int m_NeighborhoodRadius;
132  unsigned int m_NeighborhoodSize;
133 };
134 } // end namespace itk
135 
136 #ifndef ITK_MANUAL_INSTANTIATION
137 #include "itkSumOfSquaresImageFunction.hxx"
138 #endif
139 
140 #endif
typename 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.
RealType Evaluate(const PointType &point) const override
Define numeric traits for std::vector.
RealType EvaluateAtContinuousIndex(const ContinuousIndexType &cindex) const override
typename Superclass::PointType PointType
typename Superclass::OutputType OutputType
typename Superclass::IndexType IndexType
Control indentation during Print() invocation.
Definition: itkIndent.h:49
typename Superclass::ContinuousIndexType ContinuousIndexType
Evaluates a function of an image at specified position.
void SetNeighborhoodRadius(unsigned int radius)