ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkMedianImageFunction.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 itkMedianImageFunction_h
19 #define itkMedianImageFunction_h
20 
21 #include "itkImageFunction.h"
22 #include "itkNumericTraits.h"
23 
24 namespace itk
25 {
46 template< typename TInputImage, typename TCoordRep = float >
47 class ITK_TEMPLATE_EXPORT MedianImageFunction:
48  public ImageFunction< TInputImage, typename TInputImage::PixelType,
49  TCoordRep >
50 {
51 public:
52  ITK_DISALLOW_COPY_AND_ASSIGN(MedianImageFunction);
53 
56  using Superclass = ImageFunction< TInputImage, typename TInputImage::PixelType,
57  TCoordRep >;
58 
61 
63  itkTypeMacro(MedianImageFunction, ImageFunction);
64 
66  itkNewMacro(Self);
67 
69  using InputImageType = TInputImage;
70  using InputPixelType = typename Superclass::InputPixelType;
71 
73  using OutputType = typename Superclass::OutputType;
74 
76  using IndexType = typename Superclass::IndexType;
77 
79  using ContinuousIndexType = typename Superclass::ContinuousIndexType;
80 
82  using PointType = typename Superclass::PointType;
83 
85  static constexpr unsigned int ImageDimension = InputImageType::ImageDimension;
86 
88  OutputType EvaluateAtIndex(const IndexType & index) const override;
89 
91  OutputType Evaluate(const PointType & point) const override
92  {
93  IndexType index;
94 
95  this->ConvertPointToNearestIndex(point, index);
96  return this->EvaluateAtIndex(index);
97  }
98 
100  const ContinuousIndexType & cindex) const override
101  {
102  IndexType index;
103 
104  this->ConvertContinuousIndexToNearestIndex(cindex, index);
105  return this->EvaluateAtIndex(index);
106  }
107 
110  itkSetMacro( NeighborhoodRadius, unsigned int );
111  itkGetConstReferenceMacro( NeighborhoodRadius, unsigned int );
113 
114 protected:
116  ~MedianImageFunction() override = default;
117  void PrintSelf(std::ostream & os, Indent indent) const override;
118 
119 private:
120  unsigned int m_NeighborhoodRadius{1};
121 
122 };
123 } // end namespace itk
124 
125 #ifndef ITK_MANUAL_INSTANTIATION
126 #include "itkMedianImageFunction.hxx"
127 #endif
128 
129 #endif
Light weight base class for most itk classes.
typename Superclass::InputPixelType InputPixelType
typename Superclass::OutputType OutputType
typename Superclass::PointType PointType
typename Superclass::ContinuousIndexType ContinuousIndexType
Calculate the median value in the neighborhood of a pixel.
typename Superclass::IndexType IndexType
Control indentation during Print() invocation.
Definition: itkIndent.h:49
OutputType EvaluateAtContinuousIndex(const ContinuousIndexType &cindex) const override
OutputType Evaluate(const PointType &point) const override
Evaluates a function of an image at specified position.