ITK  6.0.0
Insight Toolkit
itkMeanImageFunction.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 itkMeanImageFunction_h
19 #define itkMeanImageFunction_h
20 
21 #include "itkImageFunction.h"
23 #include "itkNumericTraits.h"
24 #include "itkOffset.h"
25 
26 #include <vector>
27 
28 namespace itk
29 {
48 template <typename TInputImage, typename TCoordRep = float>
49 class ITK_TEMPLATE_EXPORT MeanImageFunction
50  : public ImageFunction<TInputImage, typename NumericTraits<typename TInputImage::PixelType>::RealType, TCoordRep>
51 {
52 public:
53  ITK_DISALLOW_COPY_AND_MOVE(MeanImageFunction);
54 
57  using Superclass =
59 
62 
64  itkOverrideGetNameOfClassMacro(MeanImageFunction);
65 
67  itkNewMacro(Self);
68 
70  using InputImageType = TInputImage;
71 
73  using typename Superclass::InputPixelType;
74 
76  using typename Superclass::OutputType;
77 
79  using typename Superclass::IndexType;
80 
82  using typename Superclass::ContinuousIndexType;
83 
85  using typename Superclass::PointType;
86 
89 
91  static constexpr unsigned int ImageDimension = InputImageType::ImageDimension;
92 
95 
97  RealType
98  EvaluateAtIndex(const IndexType & index) const override;
99 
101  RealType
102  Evaluate(const PointType & point) const override
103  {
104  IndexType index;
105 
106  this->ConvertPointToNearestIndex(point, index);
107  return this->EvaluateAtIndex(index);
108  }
109 
110  RealType
111  EvaluateAtContinuousIndex(const ContinuousIndexType & cindex) const override
112  {
113  IndexType index;
114 
115  this->ConvertContinuousIndexToNearestIndex(cindex, index);
116  return this->EvaluateAtIndex(index);
117  }
118 
121  void
122  SetNeighborhoodRadius(unsigned int);
123  itkGetConstReferenceMacro(NeighborhoodRadius, unsigned int);
126 protected:
128  ~MeanImageFunction() override = default;
129  void
130  PrintSelf(std::ostream & os, Indent indent) const override;
131 
132 private:
133  unsigned int m_NeighborhoodRadius{ 1 };
134 
135  std::vector<Offset<ImageDimension>> m_NeighborhoodOffsets{ GenerateRectangularImageNeighborhoodOffsets(
136  ImageSizeType::Filled(1)) };
137 };
138 } // end namespace itk
139 
140 #ifndef ITK_MANUAL_INSTANTIATION
141 # include "itkMeanImageFunction.hxx"
142 #endif
143 
144 #endif
itkImageFunction.h
itkImageNeighborhoodOffsets.h
itk::MeanImageFunction::Evaluate
RealType Evaluate(const PointType &point) const override
Definition: itkMeanImageFunction.h:102
itk::MeanImageFunction::InputImageType
TInputImage InputImageType
Definition: itkMeanImageFunction.h:70
itk::MeanImageFunction::RealType
typename NumericTraits< typename InputImageType::PixelType >::RealType RealType
Definition: itkMeanImageFunction.h:94
itkOffset.h
itk::ImageFunction< TInputImage, NumericTraits< TInputImage::PixelType >::RealType, TCoordRep >::IndexType
typename InputImageType::IndexType IndexType
Definition: itkImageFunction.h:90
itk::MeanImageFunction
Calculate the mean value in the neighborhood of a pixel.
Definition: itkMeanImageFunction.h:49
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::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::MeanImageFunction::EvaluateAtContinuousIndex
RealType EvaluateAtContinuousIndex(const ContinuousIndexType &cindex) const override
Definition: itkMeanImageFunction.h:111
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::ContinuousIndex< TCoordRep, Self::ImageDimension >
itkNumericTraits.h
itk::MeanImageFunction::ImageSizeType
typename InputImageType::SizeType ImageSizeType
Definition: itkMeanImageFunction.h:88
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