Public Types | Static Public Member Functions | Static Public Attributes | Static Protected Attributes | List of all members
mirtk::BSpline< TReal > Class Template Reference

#include <BSpline.h>

Collaboration diagram for mirtk::BSpline< TReal >:
Collaboration graph

Public Types

typedef TReal RealType
 Floating point precision type used.
 

Static Public Member Functions

static MIRTKCU_API TReal B (TReal)
 Returns the value of the B-spline function.
 
static MIRTKCU_API TReal B (int, TReal)
 Returns the value of the i-th B-spline basis function.
 
static MIRTKCU_API TReal B0 (TReal)
 Returns the value of the first B-spline basis function.
 
static MIRTKCU_API TReal B0_I (TReal)
 Returns the 1st derivative value of the first B-spline basis function.
 
static MIRTKCU_API TReal B0_II (TReal)
 Returns the 2nd derivative value of the first B-spline basis function.
 
static MIRTKCU_API TReal B0_III (TReal)
 Returns the 3rd derivative value of the first B-spline basis function.
 
static MIRTKCU_API TReal B0_nI (int, TReal)
 Returns the n-th derivative value of the first B-spline basis function.
 
static MIRTKCU_API TReal B1 (TReal)
 Returns the value of the second B-spline basis function.
 
static MIRTKCU_API TReal B1_I (TReal)
 Returns the 1st derivative value of the second B-spline basis function.
 
static MIRTKCU_API TReal B1_II (TReal)
 Returns the 2nd derivative value of the second B-spline basis function.
 
static MIRTKCU_API TReal B1_III (TReal)
 Returns the 3rd derivative value of the second B-spline basis function.
 
static MIRTKCU_API TReal B1_nI (int, TReal)
 Returns the n-th derivative value of the second B-spline basis function.
 
static MIRTKCU_API TReal B2 (TReal)
 Returns the value of the third B-spline basis function.
 
static MIRTKCU_API TReal B2_I (TReal)
 Returns the 1st derivative value of the third B-spline basis function.
 
static MIRTKCU_API TReal B2_II (TReal)
 Returns the 2nd derivative value of the third B-spline basis function.
 
static MIRTKCU_API TReal B2_III (TReal)
 Returns the 3rd derivative value of the third B-spline basis function.
 
static MIRTKCU_API TReal B2_nI (int, TReal)
 Returns the n-th derivative value of the third B-spline basis function.
 
static MIRTKCU_API TReal B3 (TReal)
 Returns the value of the fourth B-spline basis function.
 
static MIRTKCU_API TReal B3_I (TReal)
 Returns the 1st derivative value of the fourth B-spline basis function.
 
static MIRTKCU_API TReal B3_II (TReal)
 Returns the 2nd derivative value of the fourth B-spline basis function.
 
static MIRTKCU_API TReal B3_III (TReal)
 Returns the 3rd derivative value of the fourth B-spline basis function.
 
static MIRTKCU_API TReal B3_nI (int, TReal)
 Returns the n-th derivative value of the fourth B-spline basis function.
 
static MIRTKCU_API TReal B_I (TReal)
 Returns the 1st derivative value of the B-spline function.
 
static MIRTKCU_API TReal B_I (int, TReal)
 Returns the 1st derivative value of the i-th B-spline basis function.
 
static MIRTKCU_API TReal B_II (TReal)
 Returns the 2nd derivative value of the B-spline function.
 
static MIRTKCU_API TReal B_II (int, TReal)
 Returns the 2nd derivative value of the i-th B-spline basis function.
 
static MIRTKCU_API TReal B_III (TReal)
 Returns the 3rd derivative value of the B-spline function.
 
static MIRTKCU_API TReal B_III (int, TReal)
 Returns the 3rd derivative value of the i-th B-spline basis function.
 
static MIRTKCU_API TReal B_nI (int, TReal)
 Returns the n-th derivative value of the B-spline function.
 
static MIRTKCU_API TReal B_nI (int, int, TReal)
 Returns the n-th derivative value of the i-th B-spline basis function.
 
static void Initialize (bool=false)
 Initialize lookup tables.
 
static int VariableToIndex (TReal)
 Returns the lookup table index for a given value in [0,1].
 
static bool VariableToIndex (TReal, int &i, int &j)
 
static MIRTKCU_API TReal Weight (TReal)
 Returns the value of the B-spline function.
 
static MIRTKCU_API void Weights (TReal, TReal[4])
 

Static Public Attributes

static const TReal LatticeWeights [4]
 
static const TReal LatticeWeights_I [4]
 
static const TReal LatticeWeights_II [4]
 
static MIRTK_Numerics_EXPORT TReal LookupTable [LookupTableSize][4]
 Lookup table of B-spline basis function values.
 
static MIRTK_Numerics_EXPORT TReal LookupTable_I [LookupTableSize][4]
 Lookup table of B-spline basis function 1st derivative values.
 
static MIRTK_Numerics_EXPORT TReal LookupTable_II [LookupTableSize][4]
 Lookup table of B-spline basis function 2nd derivative values.
 
static const unsigned int LookupTableSize = 1000
 Size of lookup tables of pre-computed B-spline values.
 
static MIRTK_Numerics_EXPORT TReal WeightLookupTable [LookupTableSize]
 Lookup table of B-spline function values.
 

Static Protected Attributes

static MIRTK_Numerics_EXPORT bool _initialized
 Flag which indicates whether the lookup tables are initialized.
 

Detailed Description

template<class TReal>
class mirtk::BSpline< TReal >

Cubic B-spline, its basis functions, and their derivatives.

This static class provides methods to evaluate the cubic B-spline function, each of its four basis functions, and the corresponding first and second derivatives in the interval [0, 1]. It is in particular intended for use by classes implementing the irtkFreeFormTransformation interface using a cubic B-spline basis to represent the displacement or velocity field, respectively.

The cubic B-spline pieces are indexed here in reverse order! This is especially important when using the derivatives, because otherwise the sign may be incorrect when the intervals are exchanged. Spline function B(t) consists of pieces:

Note
Though not explicitly enforced by protecting these members, do not modify the lookup tables of precomputed function values as it will affect all code which makes use of them! Moreover, make sure to call the static Initialize() method at least once in your program before accessing any of these precomputed values.

Usage:

BSplineFunction kernel;
// evaluate function explicitly
double exact = kernel.B1(0.2);
// or use lookup table; note that the Initialize() method must only be
// called once during the life-time of the program
double approx = kernel.LookupTable[kernel.VariableToIndex(0.2)][1];

Definition at line 71 of file BSpline.h.

Member Function Documentation

§ VariableToIndex()

template<class TReal >
bool mirtk::BSpline< TReal >::VariableToIndex ( TReal  t,
int &  i,
int &  j 
)
inlinestatic

Returns the lookup table indices for any t value

Parameters
[in]tCubic B-spline function parameter.
[out]iFirst lookup table index in [0, LookupTableSize - 1].
[out]jSecond lookup table index in [0, 3].
Returns
Whether t is within local support of cubic B-spline function. When the return value is false, lookup table indices corresponding to a boundary of the local support region is returned.

Definition at line 634 of file BSpline.h.

§ Weights()

template<class TReal >
void mirtk::BSpline< TReal >::Weights ( TReal  t,
TReal  value[4] 
)
inlinestatic

Returns the values of the B-spline function for

  • [0]: t in ]-2, -1[
  • [1]: t in [-1, 0]
  • [2]: t in ]0, 1]
  • [3]: t in ]1, 2[

Definition at line 278 of file BSpline.h.

Member Data Documentation

§ LatticeWeights

template<class TReal >
const TReal mirtk::BSpline< TReal >::LatticeWeights
static
Initial value:
= {
TReal(1.0/6.0), TReal(2.0/3.0), TReal(1.0/6.0), TReal(0.0)
}

Lookup table of B-spline basis function values for t=0 (i.e., kernel centered at lattice coordinate)

Definition at line 83 of file BSpline.h.

§ LatticeWeights_I

template<class TReal >
const TReal mirtk::BSpline< TReal >::LatticeWeights_I
static
Initial value:
= {
TReal(-0.5), TReal(0.0), TReal(0.5), TReal(0.0)
}

Lookup table of B-spline basis function 1st derivative values for t=0 (i.e., kernel centered at lattice coordinate)

Definition at line 87 of file BSpline.h.

§ LatticeWeights_II

template<class TReal >
const TReal mirtk::BSpline< TReal >::LatticeWeights_II
static
Initial value:
= {
TReal(1.0), TReal(-2.0), TReal(1.0), TReal(0.0)
}

Lookup table of B-spline basis function 2nd derivative values for t=0 (i.e., kernel centered at lattice coordinate)

Definition at line 91 of file BSpline.h.


The documentation for this class was generated from the following file: