ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkMeanImageFunction.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 itkMeanImageFunction_h
19 #define itkMeanImageFunction_h
20 
21 #include "itkImageFunction.h"
22 #include "itkNumericTraits.h"
23 
24 namespace itk
25 {
44 template< typename TInputImage, typename TCoordRep = float >
45 class ITK_TEMPLATE_EXPORT MeanImageFunction:
46  public ImageFunction< TInputImage,
47  typename NumericTraits< typename TInputImage::PixelType >::RealType,
48  TCoordRep >
49 {
50 public:
51  ITK_DISALLOW_COPY_AND_ASSIGN(MeanImageFunction);
52 
55  using Superclass = ImageFunction< TInputImage,
57  TCoordRep >;
58 
61 
63  itkTypeMacro(MeanImageFunction, ImageFunction);
64 
66  itkNewMacro(Self);
67 
69  using InputImageType = TInputImage;
70 
72  using OutputType = typename Superclass::OutputType;
73 
75  using IndexType = typename Superclass::IndexType;
76 
78  using ContinuousIndexType = typename Superclass::ContinuousIndexType;
79 
81  using PointType = typename Superclass::PointType;
82 
84  static constexpr unsigned int ImageDimension = InputImageType::ImageDimension;
85 
88 
90  RealType EvaluateAtIndex(const IndexType & index) const override;
91 
93  RealType Evaluate(const PointType & point) const override
94  {
95  IndexType index;
96 
97  this->ConvertPointToNearestIndex(point, index);
98  return this->EvaluateAtIndex(index);
99  }
100 
102  const ContinuousIndexType & cindex) const override
103  {
104  IndexType index;
105 
106  this->ConvertContinuousIndexToNearestIndex(cindex, index);
107  return this->EvaluateAtIndex(index);
108  }
109 
112  itkSetMacro(NeighborhoodRadius, unsigned int);
113  itkGetConstReferenceMacro(NeighborhoodRadius, unsigned int);
115 
116 protected:
118  ~MeanImageFunction() override = default;
119  void PrintSelf(std::ostream & os, Indent indent) const override;
120 
121 private:
122  unsigned int m_NeighborhoodRadius{ 1 };
123 };
124 } // end namespace itk
125 
126 #ifndef ITK_MANUAL_INSTANTIATION
127 #include "itkMeanImageFunction.hxx"
128 #endif
129 
130 #endif
Light weight base class for most itk classes.
Calculate the mean value in the neighborhood of a pixel.
Define numeric traits for std::vector.
typename Superclass::OutputType OutputType
typename Superclass::PointType PointType
typename Superclass::IndexType IndexType
RealType Evaluate(const PointType &point) const override
typename Superclass::ContinuousIndexType ContinuousIndexType
typename NumericTraits< typename InputImageType::PixelType >::RealType RealType
Control indentation during Print() invocation.
Definition: itkIndent.h:49
RealType EvaluateAtContinuousIndex(const ContinuousIndexType &cindex) const override
Evaluates a function of an image at specified position.