ITK  4.2.0
Insight Segmentation and Registration Toolkit
itkWindowedSincInterpolateImageFunction.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 __itkWindowedSincInterpolateImageFunction_h
19 #define __itkWindowedSincInterpolateImageFunction_h
20 
24 
25 namespace itk
26 {
27 namespace Function
28 {
36 template< unsigned int VRadius,
37  class TInput = double, class TOutput = double >
39 {
40 public:
41  inline TOutput operator()(const TInput & A) const
42  { return (TOutput)vcl_cos(A * m_Factor); }
43 private:
44 
46  static const double m_Factor;
47 };
48 
56 template< unsigned int VRadius,
57  class TInput = double, class TOutput = double >
59 {
60 public:
61  inline TOutput operator()(const TInput & A) const
62  { return (TOutput)0.54 + 0.46 * vcl_cos(A * m_Factor); }
63 private:
64 
66  static const double m_Factor;
67 };
68 
76 template< unsigned int VRadius,
77  class TInput = double, class TOutput = double >
79 {
80 public:
81  inline TOutput operator()(const TInput & A) const
82  { return (TOutput)( 1.0 - A * m_Factor * A ); }
83 private:
84 
86  static const double m_Factor;
87 };
88 
98 template< unsigned int VRadius,
99  class TInput = double, class TOutput = double >
101 {
102 public:
103  inline TOutput operator()(const TInput & A) const
104  {
105  if ( A == 0.0 ) { return (TOutput)1.0; }
106  double z = m_Factor * A;
107  return (TOutput)( vcl_sin(z) / z );
108  }
110 
111 private:
113  static const double m_Factor;
114 };
115 
123 template< unsigned int VRadius,
124  class TInput = double, class TOutput = double >
126 {
127 public:
128  inline TOutput operator()(const TInput & A) const
129  {
130  return (TOutput)
131  ( 0.42 + 0.5 * vcl_cos(A * m_Factor1) + 0.08 * vcl_cos(A * m_Factor2) );
132  }
134 
135 private:
137  static const double m_Factor1;
138 
140  static const double m_Factor2;
141 };
142 } // namespace Function
143 
254 template<
255  class TInputImage,
256  unsigned int VRadius,
257  class TWindowFunction = Function::HammingWindowFunction< VRadius >,
258  class TBoundaryCondition = ConstantBoundaryCondition< TInputImage >,
259  class TCoordRep = double >
261  public InterpolateImageFunction< TInputImage, TCoordRep >
262 {
263 public:
264 
268 
271 
275 
277  itkNewMacro(Self);
278 
280  typedef typename Superclass::OutputType OutputType;
281 
283  typedef typename Superclass::InputImageType InputImageType;
284 
286  typedef typename Superclass::RealType RealType;
287 
289  itkStaticConstMacro(ImageDimension, unsigned int, Superclass::ImageDimension);
290 
292  typedef typename Superclass::IndexType IndexType;
294 
296  typedef TInputImage ImageType;
297 
299  typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
300 
301  virtual void SetInputImage(const ImageType *image);
302 
309  virtual OutputType EvaluateAtContinuousIndex(
310  const ContinuousIndexType & index) const;
311 
312 protected:
315  void PrintSelf(std::ostream & os, Indent indent) const;
316 
317 private:
318  WindowedSincInterpolateImageFunction(const Self &); //not implemented
319  void operator=(const Self &); //purposely not
320  // implemented
321 
322  // Internal typedefs
324  ImageType, TBoundaryCondition > IteratorType;
325 
326  // Constant to store twice the radius
327  static const unsigned int m_WindowSize;
328 
330  TWindowFunction m_WindowFunction;
331 
334  unsigned int *m_OffsetTable;
335 
337  unsigned int m_OffsetTableSize;
338 
340  unsigned int **m_WeightOffsetTable;
341 
343  inline double Sinc(double x) const
344  {
345  double px = vnl_math::pi * x;
346 
347  return ( x == 0.0 ) ? 1.0 : vcl_sin(px) / px;
348  }
349 };
350 } // namespace itk
351 
352 #ifndef ITK_MANUAL_INSTANTIATION
353 #include "itkWindowedSincInterpolateImageFunction.hxx"
354 #endif
355 
356 #endif // _itkWindowedSincInterpolateImageFunction_h
357