ITK  6.0.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 
28 namespace itk
29 {
46 template <typename TInputImage, typename TCoordinate = float>
47 class ITK_TEMPLATE_EXPORT SumOfSquaresImageFunction
48  : public ImageFunction<TInputImage, typename NumericTraits<typename TInputImage::PixelType>::RealType, TCoordinate>
49 {
50 public:
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 
95  RealType
96  EvaluateAtIndex(const IndexType & index) const override;
97 
99  RealType
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 
131 protected:
133  ~SumOfSquaresImageFunction() override = default;
134  void
135  PrintSelf(std::ostream & os, Indent indent) const override;
136 
137 private:
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
itk::SumOfSquaresImageFunction::Evaluate
RealType Evaluate(const PointType &point) const override
Definition: itkSumOfSquaresImageFunction.h:100
itkImageFunction.h
itkImageNeighborhoodOffsets.h
itk::SumOfSquaresImageFunction::RealType
typename NumericTraits< typename InputImageType::PixelType >::RealType RealType
Definition: itkSumOfSquaresImageFunction.h:92
itk::SumOfSquaresImageFunction::InputImageType
TInputImage InputImageType
Definition: itkSumOfSquaresImageFunction.h:68
itkOffset.h
itk::GTest::TypedefsAndConstructors::Dimension2::PointType
ImageBaseType::PointType PointType
Definition: itkGTestTypedefsAndConstructors.h:51
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::SumOfSquaresImageFunction::ImageSizeType
typename InputImageType::SizeType ImageSizeType
Definition: itkSumOfSquaresImageFunction.h:86
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::ImageFunction
Evaluates a function of an image at specified position.
Definition: itkImageFunction.h:55
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itk::GenerateRectangularImageNeighborhoodOffsets
std::vector< Offset< VImageDimension > > GenerateRectangularImageNeighborhoodOffsets(const Size< VImageDimension > &radius)
Definition: itkImageNeighborhoodOffsets.h:43
itk::point
*par Constraints *The filter requires an 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
itk::SumOfSquaresImageFunction
Calculate the sum of squares in the neighborhood of a pixel.
Definition: itkSumOfSquaresImageFunction.h:47
itk::SumOfSquaresImageFunction::SetNeighborhoodRadius
void SetNeighborhoodRadius(unsigned int radius)
Definition: itkSumOfSquaresImageFunction.h:122
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::ContinuousIndex< TCoordinate, Self::ImageDimension >
itkNumericTraits.h
itk::Point
A templated class holding a geometric point in n-Dimensional space.
Definition: itkPoint.h:53
itk::NumericTraits::RealType
double RealType
Definition: itkNumericTraits.h:86
itk::SumOfSquaresImageFunction::EvaluateAtContinuousIndex
RealType EvaluateAtContinuousIndex(const ContinuousIndexType &cindex) const override
Definition: itkSumOfSquaresImageFunction.h:109
itk::ImageFunction< TInputImage, NumericTraits< TInputImage::PixelType >::RealType, TCoordinate >::IndexType
typename InputImageType::IndexType IndexType
Definition: itkImageFunction.h:94