ITK  4.6.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
87  {
88  IndexType index;
89 
90  this->ConvertPointToNearestIndex(point, index);
91  return ( this->EvaluateAtIndex(index) );
92  }
93 
103  const ContinuousIndexType & index) const
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
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;
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)
void PrintSelf(std::ostream &os, Indent indent) const
Light weight base class for most itk classes.
Point< TCoordRep, itkGetStaticConstMacro(ImageDimension) > PointType
virtual bool EvaluateAtIndex(const IndexType &index) const
void ThresholdBelow(PixelType thresh)
void ConvertPointToNearestIndex(const PointType &point, IndexType &index) const
virtual bool Evaluate(const PointType &point) const
Superclass::ContinuousIndexType ContinuousIndexType
ContinuousIndex< TCoordRep, itkGetStaticConstMacro(ImageDimension) > ContinuousIndexType
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
Evaluates a function of an image at specified position.
virtual bool EvaluateAtContinuousIndex(const ContinuousIndexType &index) const
ImageFunction< TInputImage, bool, TCoordRep > Superclass
void ThresholdAbove(PixelType thresh)