ITK  5.2.0
Insight Toolkit
itkMedianImageFunction.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  * 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"
23 #include "itkNumericTraits.h"
24 #include "itkOffset.h"
25 
26 namespace itk
27 {
48 template <typename TInputImage, typename TCoordRep = float>
49 class ITK_TEMPLATE_EXPORT MedianImageFunction
50  : public ImageFunction<TInputImage, typename TInputImage::PixelType, TCoordRep>
51 {
52 public:
53  ITK_DISALLOW_COPY_AND_MOVE(MedianImageFunction);
54 
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 
86 
88  static constexpr unsigned int ImageDimension = InputImageType::ImageDimension;
89 
92  EvaluateAtIndex(const IndexType & index) const override;
93 
96  Evaluate(const PointType & point) const override
97  {
98  IndexType index;
99 
100  this->ConvertPointToNearestIndex(point, index);
101  return this->EvaluateAtIndex(index);
102  }
103 
104  OutputType
105  EvaluateAtContinuousIndex(const ContinuousIndexType & cindex) const override
106  {
107  IndexType index;
108 
109  this->ConvertContinuousIndexToNearestIndex(cindex, index);
110  return this->EvaluateAtIndex(index);
111  }
112 
115  void
116  SetNeighborhoodRadius(unsigned int);
117  itkGetConstReferenceMacro(NeighborhoodRadius, unsigned int);
119 
120 protected:
122  ~MedianImageFunction() override = default;
123  void
124  PrintSelf(std::ostream & os, Indent indent) const override;
125 
126 private:
127  unsigned int m_NeighborhoodRadius{ 1 };
128 
129  std::vector<Offset<ImageDimension>> m_NeighborhoodOffsets{ GenerateRectangularImageNeighborhoodOffsets(
130  ImageSizeType::Filled(1)) };
131 };
132 } // end namespace itk
133 
134 #ifndef ITK_MANUAL_INSTANTIATION
135 # include "itkMedianImageFunction.hxx"
136 #endif
137 
138 #endif
itkImageFunction.h
itkImageNeighborhoodOffsets.h
itk::MedianImageFunction::OutputType
typename Superclass::OutputType OutputType
Definition: itkMedianImageFunction.h:73
itk::MedianImageFunction::EvaluateAtContinuousIndex
OutputType EvaluateAtContinuousIndex(const ContinuousIndexType &cindex) const override
Definition: itkMedianImageFunction.h:105
itk::MedianImageFunction::InputPixelType
typename Superclass::InputPixelType InputPixelType
Definition: itkMedianImageFunction.h:70
itk::MedianImageFunction::ImageSizeType
typename InputImageType::SizeType ImageSizeType
Definition: itkMedianImageFunction.h:85
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::MedianImageFunction::PointType
typename Superclass::PointType PointType
Definition: itkMedianImageFunction.h:82
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:59
itk::MedianImageFunction::Evaluate
OutputType Evaluate(const PointType &point) const override
Definition: itkMedianImageFunction.h:96
itk::GenerateRectangularImageNeighborhoodOffsets
std::vector< Offset< VImageDimension > > GenerateRectangularImageNeighborhoodOffsets(const Size< VImageDimension > &radius)
Definition: itkImageNeighborhoodOffsets.h:43
itk::MedianImageFunction::ContinuousIndexType
typename Superclass::ContinuousIndexType ContinuousIndexType
Definition: itkMedianImageFunction.h:79
itk::MedianImageFunction::IndexType
typename Superclass::IndexType IndexType
Definition: itkMedianImageFunction.h:76
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itkNumericTraits.h
itk::MedianImageFunction::InputImageType
TInputImage InputImageType
Definition: itkMedianImageFunction.h:69
itk::MedianImageFunction
Calculate the median value in the neighborhood of a pixel.
Definition: itkMedianImageFunction.h:49