ITK  4.2.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 // Define instantiation macro for this template.
156 #define ITK_TEMPLATE_BinaryThresholdImageFunction(_, EXPORT, TypeX, TypeY) \
157  namespace itk \
158  { \
159  _( 2 ( class EXPORT BinaryThresholdImageFunction< ITK_TEMPLATE_2 TypeX > ) ) \
160  namespace Templates \
161  { \
162  typedef BinaryThresholdImageFunction< ITK_TEMPLATE_2 TypeX > \
163  BinaryThresholdImageFunction##TypeY; \
164  } \
165  }
166 
167 #if ITK_TEMPLATE_EXPLICIT
168 #include "Templates/itkBinaryThresholdImageFunction+-.h"
169 #endif
170 
171 #if ITK_TEMPLATE_TXX
172 #include "itkBinaryThresholdImageFunction.hxx"
173 #endif
174 
175 #endif
176