ITK  4.8.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 >
44  public ImageFunction< TInputImage, bool, TCoordRep >
45 {
46 public:
52 
55 
57  itkNewMacro(Self);
58 
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 
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  BinaryThresholdImageFunction(const Self &); //purposely not implemented
148  void operator=(const Self &); //purposely not implemented
149 
152 };
153 } // end namespace itk
154 
155 #ifndef ITK_MANUAL_INSTANTIATION
156 #include "itkBinaryThresholdImageFunction.hxx"
157 #endif
158 
159 #endif
void ThresholdBetween(PixelType lower, PixelType upper)
Light weight base class for most itk classes.
Point< TCoordRep, itkGetStaticConstMacro(ImageDimension) > PointType
void ThresholdBelow(PixelType thresh)
void ConvertPointToNearestIndex(const PointType &point, IndexType &index) const
Superclass::ContinuousIndexType ContinuousIndexType
virtual bool Evaluate(const PointType &point) const override
ContinuousIndex< TCoordRep, itkGetStaticConstMacro(ImageDimension) > ContinuousIndexType
void PrintSelf(std::ostream &os, Indent indent) 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...
void ConvertContinuousIndexToNearestIndex(const ContinuousIndexType &cindex, IndexType &index) const
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
void ThresholdAbove(PixelType thresh)