ITK  4.3.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< class TInputImage, class TCoordRep = float >
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
87  {
88  IndexType index;
89 
90  this->ConvertPointToNearestIndex(point, index);
91  return ( this->EvaluateAtIndex(index) );
92  }
93 
102  virtual bool EvaluateAtContinuousIndex(
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
160