KWStyle - itkBinaryThresholdImageFunction.h
 
Matrix View
Description

1 /*=========================================================================
2
3   Program:   Insight Segmentation & Registration Toolkit
4   Module:    $RCSfile: itkBinaryThresholdImageFunction.h.html,v $
5   Language:  C++
6   Date:      $Date: 2006/01/17 19:15:33 $
7   Version:   $Revision: 1.4 $
8
9   Copyright (c) Insight Software Consortium. All rights reserved.
10   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11
12      This software is distributed WITHOUT ANY WARRANTY; without even 
13      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
14      PURPOSE.  See the above copyright notices for more information.
15
16 =========================================================================*/
17 DEF #ifndef _itkBinaryThresholdImageFunction_h
18 DEF #define _itkBinaryThresholdImageFunction_h
19
20 #include "itkImageFunction.h"
21
22 namespace itk
23 {
24
25 /** \class BinaryThresholdImageFunction
26 LEN  * \brief Returns true is the value of an image lies within a range of thresholds
27 This ImageFunction returns true (or false) if the pixel value lies
28 within (outside) a lower and upper threshold value. The threshold
29 range can be set with the ThresholdBelow, ThresholdBetween or
30 ThresholdAbove methods.  The input image is set via method
31 SetInputImage().
32
33 Methods Evaluate, EvaluateAtIndex and EvaluateAtContinuousIndex
34 respectively evaluate the function at an geometric point, image index
35 and continuous image index.
36
37  * \ingroup ImageFunctions
38  * 
39  * */
40 template <class TInputImage, class TCoordRep = float>
41 class ITK_EXPORT BinaryThresholdImageFunction : 
42 IND **public ImageFunction<TInputImage,bool,TCoordRep> 
43 {
44 public:
45   /** Standard class typedefs. */
46   typedef BinaryThresholdImageFunction Self;
47 TDA   typedef ImageFunction<TInputImage,bool,TCoordRep> Superclass;
48 TDA   typedef SmartPointer<Self> Pointer;
49 TDA   typedef SmartPointer<const Self>  ConstPointer;
50   
51   /** Run-time type information (and related methods). */
52   itkTypeMacro(BinaryThresholdImageFunction, ImageFunction);
53
54   /** Method for creation through the object factory. */
55   itkNewMacro(Self);
56
57   /** InputImageType typedef support. */
58   typedef typename Superclass::InputImageType InputImageType;
59   
60   /** Typedef to describe the type of pixel. */
61   typedef typename TInputImage::PixelType PixelType;
62
63   /** Dimension underlying input image. */
64   itkStaticConstMacro(ImageDimension, unsigned int,Superclass::ImageDimension);
65
66   /** Point typedef support. */
67   typedef typename Superclass::PointType PointType;
68
69   /** Index typedef support. */
70   typedef typename Superclass::IndexType IndexType;
71
72   /** ContinuousIndex typedef support. */
73   typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
74
75   /** BinaryThreshold the image at a point position
76    *
77    * Returns true if the image intensity at the specified point position
78    * satisfies the threshold criteria.  The point is assumed to lie within
79    * the image buffer.
80    *
81    * ImageFunction::IsInsideBuffer() can be used to check bounds before
82    * calling the method. */
83
84   virtual bool Evaluate( const PointType& point ) const
85     {
86     IndexType index;
87     this->ConvertPointToNearestIndex( point, index );
88     return ( this->EvaluateAtIndex( index ) );
89     }
90
91   /** BinaryThreshold the image at a continuous index position
92    *
93    * Returns true if the image intensity at the specified point position
94    * satisfies the threshold criteria.  The point is assumed to lie within
95    * the image buffer.
96    *
97    * ImageFunction::IsInsideBuffer() can be used to check bounds before
98    * calling the method. */
99   virtual bool EvaluateAtContinuousIndex( 
100     const ContinuousIndexType & index ) const
101     {
102 IND ******IndexType nindex;
103
104 IND ******this->ConvertContinuousIndexToNearestIndex (index, nindex);
105 IND ******return this->EvaluateAtIndex(nindex);
106     }
107
108   /** BinaryThreshold the image at an index position.
109    *
110    * Returns true if the image intensity at the specified point position
111    * satisfies the threshold criteria.  The point is assumed to lie within
112    * the image buffer.
113    *
114    * ImageFunction::IsInsideBuffer() can be used to check bounds before
115    * calling the method. */
116   virtual bool EvaluateAtIndex( const IndexType & index ) const
117     {
118     PixelType value = this->GetInputImage()->GetPixel(index);
119     return ( m_Lower <= value && value <= m_Upper);
120     }
121
122   /** Get the lower threshold value. */
123   itkGetConstReferenceMacro(Lower,PixelType);
124
125   /** Get the upper threshold value. */
126   itkGetConstReferenceMacro(Upper,PixelType);
127
128   /** Values greater than or equal to the value are inside. */
129   void ThresholdAbove(PixelType thresh);
130   
131   /** Values less than or equal to the value are inside. */
132   void ThresholdBelow(PixelType thresh);
133
134   /** Values that lie between lower and upper inclusive are inside. */
135   void ThresholdBetween(PixelType lower, PixelType upper);
136
137 protected:
138   BinaryThresholdImageFunction();
139   ~BinaryThresholdImageFunction(){};
140   void PrintSelf(std::ostream& os, Indent indent) const;
141
142 private:
143   BinaryThresholdImageFunction( const Self& ); //purposely not implemented
144   void operator=( const Self& ); //purposely not implemented
145
146   PixelType m_Lower;
147   PixelType m_Upper;
148 };
149
150 // namespace itk
151
152 #ifndef ITK_MANUAL_INSTANTIATION
153 #include "itkBinaryThresholdImageFunction.txx"
154 #endif
155
156 #endif
157

Generated by KWStyle 1.0b on Tuesday January,17 at 02:14:00PM
© Kitware Inc.