aimstil  5.0.5
RF1CubicSpline.h
Go to the documentation of this file.
1 #ifndef TIL_RECURSIVE_FILTER_CUBIC_SPLINE_H
2 #define TIL_RECURSIVE_FILTER_CUBIC_SPLINE_H
3 
4 // includes from STL
5 #include <cmath> // sqrt
6 
7 // includes from TIL library
8 #include "til/til_common.h"
9 #include "til/rf1.h"
10 
11 
12 namespace til {
13 
17  // TODO: so far there is no choice in extrapolation. However recursive
18  // filters propose a small choice. We could enable this choice, but then the
19  // size of im might change! Might be a problem here...
20  // Maybe a wrapper on an image class with templating on the shift might just
21  // help, WindowedImage<TImage, x0,y0,z0,x1,y1,z1>?
22  // We may also enable to be able to translate from the standard image extrapolation
23  // classes. In this case I see yet another trait coming...
24  template < typename TImage >
25  void cubicSplineCoefficients(const TImage &im, TImage &coeffs)
26  {
27  typedef typename TImage::value_type value_type;
28  const value_type z1 = ::sqrt(3.0) - 2;
29 
30  // Check that im and coeffs are allocated and have the same size
31  similarityCheck(im, coeffs);
32 
34  RecursiveFilter<value_type, -1, 1> filter2;
35 
36  filter1.setFilter(1, -z1);
37  filter2.setFilter(-z1, -z1);
38 
39 
40  for (ImageAxis axis = X_AXIS; axis <= Z_AXIS; ++axis)
41  {
42  // Apply filter only if image is not flat in that direction
43  if (im.dim()[axis] > 1)
44  {
45  filterAlongAxis(im, coeffs, axis, filter1);
46  filterAlongAxis(im, coeffs, axis, filter2);
47  }
48  }
49  }
50 } // namespace
51 
52 #endif
53 
void sqrt(const TImage &in, TImage &out)
Definition: imageArith.h:326
void similarityCheck(const TImage1 &im1, const TImage2 &im2)
Check whether both images are allocated and have the same size and voxel size.
Definition: imageTools.h:75
Belongs to package Box Do not include directly, include til/Box.h instead.
Definition: Accumulator.h:10
void cubicSplineCoefficients(const TImage &im, TImage &coeffs)
Replaces im by a pre-processed version of im for cubic spline interpolation.
General macros, definitions and functions.
ImageAxis
Definition: miscTools.h:123
void filterAlongAxis(const TImage &im, TImage &out, ImageAxis axis, const TLineFilter &filter)
Definition: rf4Tools.h:25