ITK  4.13.0
Insight Segmentation and Registration Toolkit
itkBinaryThresholdImageFunction.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 itkBinaryThresholdImageFunction_h
19 #define itkBinaryThresholdImageFunction_h
20 
21 #include "itkImageFunction.h"
22 
23 namespace itk
24 {
42 template< typename TInputImage, typename TCoordRep = float >
43 class ITK_TEMPLATE_EXPORT BinaryThresholdImageFunction:
44  public ImageFunction< TInputImage, bool, TCoordRep >
45 {
46 public:
52 
55 
57  itkNewMacro(Self);
58 
60  typedef typename Superclass::InputImageType InputImageType;
61 
63  typedef typename TInputImage::PixelType PixelType;
64 
66  itkStaticConstMacro(ImageDimension, unsigned int, Superclass::ImageDimension);
67 
69  typedef typename Superclass::PointType PointType;
70 
72  typedef typename Superclass::IndexType IndexType;
73 
75  typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
76 
86  virtual bool Evaluate(const PointType & point) const ITK_OVERRIDE
87  {
88  IndexType index;
89 
90  this->ConvertPointToNearestIndex(point, index);
91  return ( this->EvaluateAtIndex(index) );
92  }
93 
103  const ContinuousIndexType & index) const ITK_OVERRIDE
104  {
105  IndexType nindex;
106 
107  this->ConvertContinuousIndexToNearestIndex (index, nindex);
108  return this->EvaluateAtIndex(nindex);
109  }
110 
119  virtual bool EvaluateAtIndex(const IndexType & index) const ITK_OVERRIDE
120  {
121  PixelType value = this->GetInputImage()->GetPixel(index);
122 
123  return ( m_Lower <= value && value <= m_Upper );
124  }
125 
127  itkGetConstReferenceMacro(Lower, PixelType);
128 
130  itkGetConstReferenceMacro(Upper, PixelType);
131 
133  void ThresholdAbove(PixelType thresh);
134 
136  void ThresholdBelow(PixelType thresh);
137 
139  void ThresholdBetween(PixelType lower, PixelType upper);
140 
141 protected:
144  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
145 
146 private:
147  ITK_DISALLOW_COPY_AND_ASSIGN(BinaryThresholdImageFunction);
148 
151 };
152 } // end namespace itk
153 
154 #ifndef ITK_MANUAL_INSTANTIATION
155 #include "itkBinaryThresholdImageFunction.hxx"
156 #endif
157 
158 #endif
Light weight base class for most itk classes.
Superclass::ContinuousIndexType ContinuousIndexType
virtual bool Evaluate(const PointType &point) const override
Control indentation during Print() invocation.
Definition: itkIndent.h:49
Returns true is the value of an image lies within a range of thresholds This ImageFunction returns tr...
virtual bool EvaluateAtIndex(const IndexType &index) const override
Evaluates a function of an image at specified position.
virtual bool EvaluateAtContinuousIndex(const ContinuousIndexType &index) const override
ImageFunction< TInputImage, bool, TCoordRep > Superclass