Orfeo Toolbox  3.16
itkImageFunction.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkImageFunction.h,v $
5  Language: C++
6  Date: $Date: 2009-10-29 11:18:33 $
7  Version: $Revision: 1.50 $
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 #ifndef __itkImageFunction_h
18 #define __itkImageFunction_h
19 
20 #include "itkFunctionBase.h"
21 #include "itkPoint.h"
22 #include "itkIndex.h"
23 #include "itkContinuousIndex.h"
24 #include "itkImageBase.h"
25 
26 namespace itk
27 {
28 
29 
55 template <
56 class TInputImage,
57 class TOutput,
58 class TCoordRep = float
59 >
61  public FunctionBase< Point<TCoordRep,
62  ::itk::GetImageDimension<TInputImage>::ImageDimension>,
63  TOutput >
64 {
65 public:
67  itkStaticConstMacro(ImageDimension, unsigned int,
68  TInputImage::ImageDimension);
69 
72  typedef FunctionBase<
74  TOutput > Superclass;
77 
79  itkTypeMacro(ImageFunction, FunctionBase);
80 
82  typedef TInputImage InputImageType;
83 
86 
89 
91  typedef TOutput OutputType;
92 
94  typedef TCoordRep CoordRepType;
95 
97  typedef typename InputImageType::IndexType IndexType;
99 
103 
106 
111  virtual void SetInputImage( const InputImageType * ptr );
112 
114  const InputImageType * GetInputImage() const
115  { return m_Image.GetPointer(); }
116 
119  virtual TOutput Evaluate( const PointType& point ) const = 0;
120 
123  virtual TOutput EvaluateAtIndex( const IndexType & index ) const = 0;
124 
127  virtual TOutput EvaluateAtContinuousIndex(
128  const ContinuousIndexType & index ) const = 0;
129 
137  virtual bool IsInsideBuffer( const IndexType & index ) const
138  {
139  for( unsigned int j = 0; j < ImageDimension; j++ )
140  {
141  if( index[j] < m_StartIndex[j] )
142  {
143  return false;
144  }
145  if( index[j] > m_EndIndex[j] )
146  {
147  return false;
148  }
149  }
150  return true;
151  }
152 
156  virtual bool IsInsideBuffer( const ContinuousIndexType & index ) const
157  {
158  for( unsigned int j = 0; j < ImageDimension; j++ )
159  {
160  if( index[j] < m_StartContinuousIndex[j] )
161  {
162  return false;
163  }
164 #ifdef ITK_USE_CENTERED_PIXEL_COORDINATES_CONSISTENTLY
165  if( index[j] >= m_EndContinuousIndex[j] )
166 #else
167  if( index[j] > m_EndContinuousIndex[j] )
168 #endif
169  {
170  return false;
171  }
172  }
173  return true;
174  }
175 
179  virtual bool IsInsideBuffer( const PointType & point ) const
180  {
181  ContinuousIndexType index;
182  m_Image->TransformPhysicalPointToContinuousIndex( point, index );
183  return this->IsInsideBuffer( index );
184  }
185 
187  void ConvertPointToNearestIndex( const PointType & point,
188  IndexType & index ) const
189  {
190  ContinuousIndexType cindex;
191  m_Image->TransformPhysicalPointToContinuousIndex( point, cindex );
192  this->ConvertContinuousIndexToNearestIndex( cindex, index );
193  }
194 
196  void ConvertPointToContinousIndex( const PointType & point,
197  ContinuousIndexType & cindex ) const
198  {
199  itkWarningMacro("Please change your code to use ConvertPointToContinuousIndex "
200  << "rather than ConvertPointToContinousIndex. The latter method name was "
201  << "mispelled and the ITK developers failed to correct it before it was released."
202  << "The mispelled method name is retained in order to maintain backward compatibility.");
203  this->ConvertPointToContinuousIndex( point, cindex );
204  }
205 
207  void ConvertPointToContinuousIndex( const PointType & point,
208  ContinuousIndexType & cindex ) const
209  {
210  m_Image->TransformPhysicalPointToContinuousIndex( point, cindex );
211  }
212 
214  inline void ConvertContinuousIndexToNearestIndex( const ContinuousIndexType & cindex,
215  IndexType & index ) const
216  {
217  index.CopyWithRound( cindex );
218  }
219 
220  itkGetConstReferenceMacro(StartIndex, IndexType);
221  itkGetConstReferenceMacro(EndIndex, IndexType);
222 
223  itkGetConstReferenceMacro(StartContinuousIndex, ContinuousIndexType);
224  itkGetConstReferenceMacro(EndContinuousIndex, ContinuousIndexType);
225 
226 protected:
227  ImageFunction();
229  void PrintSelf(std::ostream& os, Indent indent) const;
230 
233 
239 
240 private:
241  ImageFunction(const Self&); //purposely not implemented
242  void operator=(const Self&); //purposely not implemented
243 
244 };
245 
246 }// end namespace itk
247 
248 
249 // Define instantiation macro for this template.
250 #define ITK_TEMPLATE_ImageFunction(_, EXPORT, x, y) namespace itk { \
251  _(3(class EXPORT ImageFunction< ITK_TEMPLATE_3 x >)) \
252  namespace Templates { typedef ImageFunction< ITK_TEMPLATE_3 x > ImageFunction##y; } \
253  }
254 
255 #if ITK_TEMPLATE_EXPLICIT
256 # include "Templates/itkImageFunction+-.h"
257 #endif
258 
259 #if ITK_TEMPLATE_TXX
260 # include "itkImageFunction.txx"
261 #endif
262 
263 #endif

Generated at Sat Feb 2 2013 23:42:46 for Orfeo Toolbox with doxygen 1.8.1.1