Orfeo Toolbox  4.0
itkImageFunction.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 __itkImageFunction_h
19 #define __itkImageFunction_h
20 
21 #include "itkFunctionBase.h"
22 #include "itkIndex.h"
23 #include "itkImageBase.h"
24 
25 namespace itk
26 {
53 template<
54  typename TInputImage,
55  typename TOutput,
56  typename TCoordRep = float
57  >
59  public FunctionBase< Point< TCoordRep, TInputImage::ImageDimension >, TOutput >
60 {
61 public:
63  itkStaticConstMacro(ImageDimension, unsigned int,
64  TInputImage::ImageDimension);
65 
68 
69  typedef FunctionBase<
70  Point< TCoordRep,
71  itkGetStaticConstMacro(ImageDimension) >,
72  TOutput > Superclass;
73 
76 
78  itkTypeMacro(ImageFunction, FunctionBase);
79 
81  typedef TInputImage InputImageType;
82 
85 
87  typedef typename InputImageType::ConstPointer InputImageConstPointer;
88 
90  typedef TOutput OutputType;
91 
93  typedef TCoordRep CoordRepType;
94 
98 
100  typedef ContinuousIndex< TCoordRep,
101  itkGetStaticConstMacro(ImageDimension) > ContinuousIndexType;
102 
105 
110  virtual void SetInputImage(const InputImageType *ptr);
111 
114  { return m_Image.GetPointer(); }
115 
118  virtual TOutput Evaluate(const PointType & point) const = 0;
119 
122  virtual TOutput EvaluateAtIndex(const IndexType & index) const = 0;
123 
126  virtual TOutput EvaluateAtContinuousIndex(
127  const ContinuousIndexType & index) const = 0;
128 
135  virtual bool IsInsideBuffer(const IndexType & index) const
136  {
137  for ( unsigned int j = 0; j < ImageDimension; j++ )
138  {
139  if ( index[j] < m_StartIndex[j] )
140  {
141  return false;
142  }
143  if ( index[j] > m_EndIndex[j] )
144  {
145  return false;
146  }
147  }
148  return true;
149  }
150 
154  virtual bool IsInsideBuffer(const ContinuousIndexType & index) const
155  {
156  for ( unsigned int j = 0; j < ImageDimension; j++ )
157  {
158  /* Test for negative of a positive so we can catch NaN's. */
159  if ( ! (index[j] >= m_StartContinuousIndex[j] &&
160  index[j] < m_EndContinuousIndex[j] ) )
161  {
162  return false;
163  }
164  }
165  return true;
166  }
167 
171  virtual bool IsInsideBuffer(const PointType & point) const
172  {
173  ContinuousIndexType index;
174  m_Image->TransformPhysicalPointToContinuousIndex(point, index);
175  /* Call IsInsideBuffer to test against BufferedRegion bounds.
176  * TransformPhysicalPointToContinuousIndex tests against
177  * LargestPossibleRegion */
178  bool isInside = IsInsideBuffer( index );
179  return isInside;
180  }
181 
184  IndexType & index) const
185  {
186  ContinuousIndexType cindex;
187 
188  m_Image->TransformPhysicalPointToContinuousIndex(point, cindex);
189  this->ConvertContinuousIndexToNearestIndex(cindex, index);
190  }
191 
194  ContinuousIndexType & cindex) const
195  {
196  m_Image->TransformPhysicalPointToContinuousIndex(point, cindex);
197  }
198 
201  const ContinuousIndexType & cindex,
202  IndexType & index) const
203  {
204  index.CopyWithRound(cindex);
205  }
206 
207  itkGetConstReferenceMacro(StartIndex, IndexType);
208  itkGetConstReferenceMacro(EndIndex, IndexType);
209 
210  itkGetConstReferenceMacro(StartContinuousIndex, ContinuousIndexType);
211  itkGetConstReferenceMacro(EndContinuousIndex, ContinuousIndexType);
212 
213 protected:
214  ImageFunction();
216  void PrintSelf(std::ostream & os, Indent indent) const;
217 
220 
224 
227 
228 private:
229  ImageFunction(const Self &); //purposely not implemented
230  void operator=(const Self &); //purposely not implemented
231 };
232 } // end namespace itk
233 
234 #ifndef ITK_MANUAL_INSTANTIATION
235 #include "itkImageFunction.hxx"
236 #endif
237 
238 #endif

Generated at Sat Mar 8 2014 14:50:09 for Orfeo Toolbox with doxygen 1.8.3.1