ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkVarianceImageFunction.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 itkVarianceImageFunction_h
19 #define itkVarianceImageFunction_h
20 
21 #include "itkImageFunction.h"
22 #include "itkNumericTraits.h"
23 
24 namespace itk
25 {
42 template< typename TInputImage, typename TCoordRep = float >
43 class ITK_TEMPLATE_EXPORT VarianceImageFunction:
44  public ImageFunction< TInputImage, typename NumericTraits< typename TInputImage::PixelType >::RealType,
45  TCoordRep >
46 {
47 public:
48  ITK_DISALLOW_COPY_AND_ASSIGN(VarianceImageFunction);
49 
53  TCoordRep >;
54 
57 
59  itkTypeMacro(VarianceImageFunction, ImageFunction);
60 
62  itkNewMacro(Self);
63 
65  using InputImageType = TInputImage;
66 
68  using OutputType = typename Superclass::OutputType;
69 
71  using IndexType = typename Superclass::IndexType;
72 
74  using ContinuousIndexType = typename Superclass::ContinuousIndexType;
75 
77  using PointType = typename Superclass::PointType;
78 
80  static constexpr unsigned int ImageDimension = InputImageType::ImageDimension;
81 
83  using RealType = typename NumericTraits<
84  typename InputImageType::PixelType >::RealType;
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  itkSetMacro(NeighborhoodRadius, unsigned int);
110  itkGetConstReferenceMacro(NeighborhoodRadius, unsigned int);
112 
113 protected:
115  ~VarianceImageFunction() override = default;
116  void PrintSelf(std::ostream & os, Indent indent) const override;
117 
118 private:
119  unsigned int m_NeighborhoodRadius;
120 };
121 } // end namespace itk
122 
123 #ifndef ITK_MANUAL_INSTANTIATION
124 #include "itkVarianceImageFunction.hxx"
125 #endif
126 
127 #endif
typename NumericTraits< typename InputImageType::PixelType >::RealType RealType
Light weight base class for most itk classes.
Define numeric traits for std::vector.
typename Superclass::OutputType OutputType
typename Superclass::IndexType IndexType
Calculate the variance in the neighborhood of a pixel.
typename Superclass::ContinuousIndexType ContinuousIndexType
RealType Evaluate(const PointType &point) const override
RealType EvaluateAtContinuousIndex(const ContinuousIndexType &cindex) const override
typename Superclass::PointType PointType
Control indentation during Print() invocation.
Definition: itkIndent.h:49
Evaluates a function of an image at specified position.