vspline 1.1.0
Generic C++11 Code for Uniform B-Splines
Classes | Namespaces | Functions
basis.h File Reference

Code to calculate the value of the B-spline basis function and it's derivatives. More...

#include "common.h"
#include "poles.h"

Go to the source code of this file.

Classes

struct  vspline::basis_functor< math_type >
 basis_functor is an object producing the b-spline basis function value for given arguments, or optionally a derivative of the basis function. While basis_functor can produce single basis function values for single arguments, it can also produce a set of basis function values for a given 'delta'. This set is a unit-spaced sampling of the basis function sampled at n + delta for all n E N. Such samplings are used to evaluate b-splines; they constitute the set of weights which have to be applied to a set of b-spline coefficients to form the weighted sum which is the spline's value at a given position. More...
 

Namespaces

namespace  vspline
 

Functions

template<typename ic_t , typename rc_t >
void vspline::odd_split (rc_t v, ic_t &iv, rc_t &fv)
 coordinates are split into an integral part and a remainder. this is used for weight generation, and also for calculating the basis function value. The split is done differently for odd and even splines. More...
 
template<typename ic_t , typename rc_t , int N>
void vspline::odd_split (vigra::TinyVector< rc_t, N > v, vigra::TinyVector< ic_t, N > &iv, vigra::TinyVector< rc_t, N > &fv)
 
template<typename ic_t , typename rc_t >
void vspline::even_split (rc_t v, ic_t &iv, rc_t &fv)
 for even splines, the integral part is obtained by rounding. when the result of rounding is subtracted from the original coordinate, a value between -0.5 and 0.5 is obtained which is used for weight generation. More...
 
template<typename ic_t , typename rc_t , int N>
void vspline::even_split (vigra::TinyVector< rc_t, N > v, vigra::TinyVector< ic_t, N > &iv, vigra::TinyVector< rc_t, N > &fv)
 
template<class real_type >
real_type vspline::bspline_basis_2 (int x2, int degree, int derivative=0)
 bspline_basis_2 yields the value of the b-spline basis function at multiples of 1/2, for which vspline has precomputed values. Instead of passing real values x which are multiples of 1/2, this routine takes the doubled argument, so instead of calling it with x = 0.5, you call it with x2 = 1. More...
 
template<class target_type >
void vspline::calculate_weight_matrix (vigra::MultiArray< 2, target_type > &res)
 a 'weight matrix' is used to calculate a set of weights for a given remainder part of a real coordinate. The 'weight matrix' is multipled with a vector containing the power series of the given remainder, yielding a set of weights to apply to a window of b-spline coefficients. More...
 
template<class target_type >
void vspline::get_kernel (const int &degree, vigra::MultiArrayView< 1, target_type > &kernel, const bool &odd=true)
 this function deposits the reconstruction kernel in the array 'kernel'. This kernel can be used to convolve a set of coefficients, to obtain the original signal. This is a convenience function which merely picks the right values from the precomputed values in precomputed_basis_function_values. if 'odd' is passed false, the result is an even kernel. This kernel can't be used for reconstruction (.5 phase shift), but it's handy to get values half a unit step from the knot points. More...
 
template<class real_type >
real_type vspline::cdb_bspline_basis (real_type x, int degree, int derivative=0)
 Implementation of the Cox-de Boor recursion formula to calculate the value of the bspline basis function for arbitrary real x. This code was taken from vigra but modified to take the spline degree as a parameter. Since this routine uses recursion, it's usefulness is limited to smaller degrees. More...
 
template<typename real_type >
real_type vspline::gaussian_bspline_basis_approximation (real_type x, int degree)
 Gaussian approximation to B-spline basis function. This routine approximates the basis function of degree spline_degree for real x. I checked for all degrees up to 45. The partition of unity quality of the resulting reconstruction filter is okay for larger degrees, the cumulated error over the covered interval is quite low. Still, as the basis function is never actually evaluated in vspline (whenever it's needed, it is needed at n * 1/2 and we have precomputed values for that) there is not much point in having this function around. I leave the code in for now. More...
 

Detailed Description

Code to calculate the value of the B-spline basis function and it's derivatives.

This file begins with some collateral code used to 'split' coordinates into an integral part and a small real remainder. This split is used in b-spline evaluation and fits thematically with the remainder of the file, which deals with the basis function.

vspline only uses the B-spline basis function values at multiples of 0.5. With these values it can construct it's evaluators which in turn are capable of evaluating the spline at real coordinates. Since these values aren't 'too many' but take some effort to calculate precisely, they are provided as precalculated constants in poles.h, which also holds the prefilter poles.

The basis function values at half unit steps are used for evaluation via a 'weight matrix'. This is a matrix of numbers which can yield the value of a b-spline by employing a simple fixed-time matrix/vector multiplication (which also vectorizes well). In a similar way, a 'basis_functor' can be set up from these values which can provide the value of the basis function for arbitrary real arguments.

for a discussion of the b-spline basis function, have a look at http://www.cs.mtu.edu/~shene/COURSES/cs3621/NOTES/spline/B-spline/bspline-basis.html

Definition in file basis.h.