NifTK  16.4.1 - 0798f20
CMIC's Translational Medical Imaging Platform
itkBinaryThresholdSurfaceVoxelImageFunction.h
Go to the documentation of this file.
1 /*=============================================================================
2 
3  NifTK: A software platform for medical image computing.
4 
5  Copyright (c) University College London (UCL). All rights reserved.
6 
7  This software is distributed WITHOUT ANY WARRANTY; without even
8  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
9  PURPOSE.
10 
11  See LICENSE.txt in the top level directory for details.
12 
13 =============================================================================*/
14 
15 #ifndef itkBinaryThresholdSurfaceVoxelImageFunction_h
16 #define itkBinaryThresholdSurfaceVoxelImageFunction_h
17 
18 #include <itkImageFunction.h>
19 
20 namespace itk
21 {
22 
39 template <class TInputImage, class TCoordRep = float>
41  public ImageFunction<TInputImage,bool,TCoordRep>
42 {
43 public:
46  typedef ImageFunction<TInputImage,bool,TCoordRep> Superclass;
47  typedef SmartPointer<Self> Pointer;
48  typedef SmartPointer<const Self> ConstPointer;
49 
51  itkTypeMacro(BinaryThresholdSurfaceVoxelImageFunction, ImageFunction);
52 
54  itkNewMacro(Self);
55 
57  typedef typename Superclass::InputImageType InputImageType;
58 
61 
63  itkStaticConstMacro(ImageDimension, unsigned int,Superclass::ImageDimension);
64 
66  typedef typename Superclass::PointType PointType;
67 
69  typedef typename Superclass::IndexType IndexType;
70 
73 
75  typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
76 
86  virtual bool Evaluate( const PointType& point ) const
87  {
88  IndexType index;
89  this->ConvertPointToNearestIndex( point, index );
90  return ( this->EvaluateAtIndex( index ) );
91  }
92 
102  const ContinuousIndexType & index ) const
103  {
104  IndexType nindex;
105 
106  this->ConvertContinuousIndexToNearestIndex (index, nindex);
107  return this->EvaluateAtIndex(nindex);
108  }
109 
118  virtual bool EvaluateAtIndex( const IndexType & index ) const
119  {
120  PixelType value = this->GetInputImage()->GetPixel(index);
121 
122  RegionType region = this->GetInputImage()->GetBufferedRegion();
123  if ( m_Lower <= value && value <= m_Upper) {
124 
125  IndexType indexAbove = index;
126  indexAbove[1]--;
127 
128  if ( region.IsInside( indexAbove ) ) {
129  PixelType valueAbove = this->GetInputImage()->GetPixel(indexAbove);
130 
131  if ( ! ( m_Lower <= valueAbove && valueAbove <= m_Upper ) )
132  return true;
133  }
134 #if 0
135  int i;
136  for (i=-1; i<=1; i+=2) {
137  indexAbove = index;
138  indexAbove[0] = index[0] + i;
139  indexAbove[1]--;
140 
141  if ( region.IsInside( indexAbove ) ) {
142  PixelType valueAbove = this->GetInputImage()->GetPixel(indexAbove);
143 
144  if ( ! ( m_Lower <= valueAbove && valueAbove <= m_Upper ) )
145  return true;
146  }
147  }
148 
149  for (i=-1; i<=1; i+=2) {
150  indexAbove = index;
151  indexAbove[1]--;
152  indexAbove[2] = index[2] + i;
153 
154  if ( region.IsInside( indexAbove ) ) {
155  PixelType valueAbove = this->GetInputImage()->GetPixel(indexAbove);
156 
157  if ( ! ( m_Lower <= valueAbove && valueAbove <= m_Upper ) )
158  return true;
159  }
160  }
161 #endif
162  }
163  return false;
164  }
165 
167  itkGetConstReferenceMacro(Lower,PixelType);
168 
170  itkGetConstReferenceMacro(Upper,PixelType);
171 
173  void ThresholdAbove(PixelType thresh);
174 
176  void ThresholdBelow(PixelType thresh);
177 
179  void ThresholdBetween(PixelType lower, PixelType upper);
180 
181 protected:
184  void PrintSelf(std::ostream& os, Indent indent) const;
185 
186 private:
187  BinaryThresholdSurfaceVoxelImageFunction( const Self& ); //purposely not implemented
188  void operator=( const Self& ); //purposely not implemented
189 
190  PixelType m_Lower;
191  PixelType m_Upper;
192 };
193 
194 } // end namespace itk
195 
196 
197 // Define instantiation macro for this template.
198 #define ITK_TEMPLATE_BinaryThresholdSurfaceVoxelImageFunction(_, EXPORT, x, y) namespace itk { \
199  _(2(class EXPORT BinaryThresholdSurfaceVoxelImageFunction< ITK_TEMPLATE_2 x >)) \
200  namespace Templates { typedef BinaryThresholdSurfaceVoxelImageFunction< ITK_TEMPLATE_2 x > \
201  BinaryThresholdSurfaceVoxelImageFunction##y; } \
202  }
203 
204 #if ITK_TEMPLATE_EXPLICIT
205 # include "Templates/itkBinaryThresholdSurfaceVoxelImageFunction+-.h"
206 #endif
207 
208 #if ITK_TEMPLATE_TXX
209 # include "itkBinaryThresholdSurfaceVoxelImageFunction.txx"
210 #endif
211 
212 #endif
SmartPointer< const Self > ConstPointer
Definition: itkBinaryThresholdSurfaceVoxelImageFunction.h:48
Superclass::InputImageType InputImageType
Definition: itkBinaryThresholdSurfaceVoxelImageFunction.h:54
Definition: niftkITKAffineResampleImage.cxx:74
ImageType::IndexType IndexType
Definition: niftkMakeLapUSProbeBasicModel.cxx:32
Superclass::PointType PointType
Definition: itkBinaryThresholdSurfaceVoxelImageFunction.h:66
TInputImage::PixelType PixelType
Definition: itkBinaryThresholdSurfaceVoxelImageFunction.h:60
GLsizei const GLfloat * value
Definition: glew.h:1833
SmartPointer< Self > Pointer
Definition: itkBinaryThresholdSurfaceVoxelImageFunction.h:47
float PixelType
Definition: niftkBreastDCEandADC.cxx:88
Superclass::IndexType IndexType
Definition: itkBinaryThresholdSurfaceVoxelImageFunction.h:69
Returns true is the value of an image lies within a range of thresholds This ImageFunction returns tr...
Definition: itkBinaryThresholdSurfaceVoxelImageFunction.h:40
ImageType::RegionType RegionType
Definition: niftkMakeLapUSProbeBasicModel.cxx:30
GLuint index
Definition: glew.h:1798
virtual bool EvaluateAtContinuousIndex(const ContinuousIndexType &index) const
Definition: itkBinaryThresholdSurfaceVoxelImageFunction.h:101
virtual bool EvaluateAtIndex(const IndexType &index) const
Definition: itkBinaryThresholdSurfaceVoxelImageFunction.h:118
virtual bool Evaluate(const PointType &point) const
Definition: itkBinaryThresholdSurfaceVoxelImageFunction.h:86
ImageFunction< TInputImage, bool, TCoordRep > Superclass
Definition: itkBinaryThresholdSurfaceVoxelImageFunction.h:46
InputImageType::RegionType RegionType
Definition: itkBinaryThresholdSurfaceVoxelImageFunction.h:72
BinaryThresholdSurfaceVoxelImageFunction Self
Definition: itkBinaryThresholdSurfaceVoxelImageFunction.h:45
Superclass::ContinuousIndexType ContinuousIndexType
Definition: itkBinaryThresholdSurfaceVoxelImageFunction.h:75
~BinaryThresholdSurfaceVoxelImageFunction()
Definition: itkBinaryThresholdSurfaceVoxelImageFunction.h:183