ITK  5.4.0
Insight Toolkit
itkSumOfSquaresImageFunction.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
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 * https://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"
23#include "itkNumericTraits.h"
24#include "itkOffset.h"
25
26#include <vector>
27
28namespace itk
29{
46template <typename TInputImage, typename TCoordRep = float>
47class ITK_TEMPLATE_EXPORT SumOfSquaresImageFunction
48 : public ImageFunction<TInputImage, typename NumericTraits<typename TInputImage::PixelType>::RealType, TCoordRep>
49{
50public:
51 ITK_DISALLOW_COPY_AND_MOVE(SumOfSquaresImageFunction);
52
55 using Superclass =
57
60
62 itkOverrideGetNameOfClassMacro(SumOfSquaresImageFunction);
63
65 itkNewMacro(Self);
66
68 using InputImageType = TInputImage;
69
71 using typename Superclass::InputPixelType;
72
74 using typename Superclass::OutputType;
75
77 using typename Superclass::IndexType;
78
80 using typename Superclass::ContinuousIndexType;
81
83 using typename Superclass::PointType;
84
87
89 static constexpr unsigned int ImageDimension = InputImageType::ImageDimension;
90
93
96 EvaluateAtIndex(const IndexType & index) const override;
97
100 Evaluate(const PointType & point) const override
101 {
102 IndexType index;
103
104 this->ConvertPointToNearestIndex(point, index);
105 return this->EvaluateAtIndex(index);
106 }
107
108 RealType
109 EvaluateAtContinuousIndex(const ContinuousIndexType & cindex) const override
110 {
111 IndexType index;
112
113 this->ConvertContinuousIndexToNearestIndex(cindex, index);
114 return this->EvaluateAtIndex(index);
115 }
116
119 itkGetConstReferenceMacro(NeighborhoodRadius, unsigned int);
120
121 void
122 SetNeighborhoodRadius(unsigned int radius)
123 {
124 m_NeighborhoodOffsets = GenerateRectangularImageNeighborhoodOffsets(ImageSizeType::Filled(radius));
125 m_NeighborhoodRadius = radius;
126 m_NeighborhoodSize = m_NeighborhoodOffsets.size();
127 }
128
129 itkGetConstReferenceMacro(NeighborhoodSize, unsigned int);
130
131protected:
133 ~SumOfSquaresImageFunction() override = default;
134 void
135 PrintSelf(std::ostream & os, Indent indent) const override;
136
137private:
138 unsigned int m_NeighborhoodRadius{};
139 unsigned int m_NeighborhoodSize{};
140
141 std::vector<Offset<ImageDimension>> m_NeighborhoodOffsets{ GenerateRectangularImageNeighborhoodOffsets(
142 ImageSizeType::Filled(1)) };
143};
144} // end namespace itk
145
146#ifndef ITK_MANUAL_INSTANTIATION
147# include "itkSumOfSquaresImageFunction.hxx"
148#endif
149
150#endif
Evaluates a function of an image at specified position.
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Light weight base class for most itk classes.
A templated class holding a geometric point in n-Dimensional space.
Definition: itkPoint.h:54
Calculate the sum of squares in the neighborhood of a pixel.
RealType EvaluateAtContinuousIndex(const ContinuousIndexType &cindex) const override
void SetNeighborhoodRadius(unsigned int radius)
RealType Evaluate(const PointType &point) const override
void PrintSelf(std::ostream &os, Indent indent) const override
RealType EvaluateAtIndex(const IndexType &index) const override
typename NumericTraits< typename InputImageType::PixelType >::RealType RealType
~SumOfSquaresImageFunction() override=default
typename InputImageType::SizeType ImageSizeType
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
std::vector< Offset< VImageDimension > > GenerateRectangularImageNeighborhoodOffsets(const Size< VImageDimension > &radius)
*par Constraints *The filter image with at least two dimensions and a vector *length of at least The theory supports extension to scalar but *the implementation of the itk vector classes do not **The template parameter TRealType must be floating point(float or double) or *a user-defined "real" numerical type with arithmetic operations defined *sufficient to compute derivatives. **\par Performance *This filter will automatically multithread if run with *SetUsePrincipleComponents