ITK  5.2.0
Insight Toolkit
itkBinaryThresholdImageFunction.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 itkBinaryThresholdImageFunction_h
19 #define itkBinaryThresholdImageFunction_h
20 
21 #include "itkImageFunction.h"
22 
23 namespace itk
24 {
43 template <typename TInputImage, typename TCoordRep = float>
44 class ITK_TEMPLATE_EXPORT BinaryThresholdImageFunction : public ImageFunction<TInputImage, bool, TCoordRep>
45 {
46 public:
47  ITK_DISALLOW_COPY_AND_MOVE(BinaryThresholdImageFunction);
48 
54 
57 
59  itkNewMacro(Self);
60 
62  using InputImageType = typename Superclass::InputImageType;
63 
65  using PixelType = typename TInputImage::PixelType;
66 
68  static constexpr unsigned int ImageDimension = Superclass::ImageDimension;
69 
71  using PointType = typename Superclass::PointType;
72 
74  using IndexType = typename Superclass::IndexType;
75 
77  using ContinuousIndexType = typename Superclass::ContinuousIndexType;
78 
88  bool
89  Evaluate(const PointType & point) const override
90  {
91  IndexType index;
92 
93  this->ConvertPointToNearestIndex(point, index);
94  return (this->EvaluateAtIndex(index));
95  }
96 
105  bool
106  EvaluateAtContinuousIndex(const ContinuousIndexType & index) const override
107  {
108  IndexType nindex;
109 
110  this->ConvertContinuousIndexToNearestIndex(index, nindex);
111  return this->EvaluateAtIndex(nindex);
112  }
113 
122  bool
123  EvaluateAtIndex(const IndexType & index) const override
124  {
125  PixelType value = this->GetInputImage()->GetPixel(index);
126 
127  return (m_Lower <= value && value <= m_Upper);
128  }
129 
131  itkGetConstReferenceMacro(Lower, PixelType);
132 
134  itkGetConstReferenceMacro(Upper, PixelType);
135 
137  void
138  ThresholdAbove(PixelType thresh);
139 
141  void
142  ThresholdBelow(PixelType thresh);
143 
145  void
146  ThresholdBetween(PixelType lower, PixelType upper);
147 
148 protected:
150  ~BinaryThresholdImageFunction() override = default;
151  void
152  PrintSelf(std::ostream & os, Indent indent) const override;
153 
154 private:
157 };
158 } // end namespace itk
159 
160 #ifndef ITK_MANUAL_INSTANTIATION
161 # include "itkBinaryThresholdImageFunction.hxx"
162 #endif
163 
164 #endif
itkImageFunction.h
itk::BinaryThresholdImageFunction::PointType
typename Superclass::PointType PointType
Definition: itkBinaryThresholdImageFunction.h:71
itk::BinaryThresholdImageFunction::IndexType
typename Superclass::IndexType IndexType
Definition: itkBinaryThresholdImageFunction.h:74
itk::BinaryThresholdImageFunction::PixelType
typename TInputImage::PixelType PixelType
Definition: itkBinaryThresholdImageFunction.h:65
itk::GTest::TypedefsAndConstructors::Dimension2::PointType
ImageBaseType::PointType PointType
Definition: itkGTestTypedefsAndConstructors.h:51
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::BinaryThresholdImageFunction::InputImageType
typename Superclass::InputImageType InputImageType
Definition: itkBinaryThresholdImageFunction.h:62
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::BinaryThresholdImageFunction
Returns true is the value of an image lies within a range of thresholds This ImageFunction returns tr...
Definition: itkBinaryThresholdImageFunction.h:44
itk::BinaryThresholdImageFunction::m_Upper
PixelType m_Upper
Definition: itkBinaryThresholdImageFunction.h:156
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::BinaryThresholdImageFunction::ContinuousIndexType
typename Superclass::ContinuousIndexType ContinuousIndexType
Definition: itkBinaryThresholdImageFunction.h:77
itk::BinaryThresholdImageFunction::Evaluate
bool Evaluate(const PointType &point) const override
Definition: itkBinaryThresholdImageFunction.h:89
itk::BinaryThresholdImageFunction::EvaluateAtIndex
bool EvaluateAtIndex(const IndexType &index) const override
Definition: itkBinaryThresholdImageFunction.h:123
itk::BinaryThresholdImageFunction::m_Lower
PixelType m_Lower
Definition: itkBinaryThresholdImageFunction.h:155
itk::BinaryThresholdImageFunction::EvaluateAtContinuousIndex
bool EvaluateAtContinuousIndex(const ContinuousIndexType &index) const override
Definition: itkBinaryThresholdImageFunction.h:106