Numerical Tools (pysdic.numeric)#

The submodule pysdic.numeric provides low-level numerical tools on 1D signals sampled at given abscissas (e.g. the times of the frames): finite differences and polynomial fitting. They are not exported in the pysdic namespace:

from pysdic.numeric import assemble_finite_difference_matrix, fit_polynomial

They are used, for example, by pysdic.SDICTemporalRegularizationTerm (finite difference matrix on the actual times of the frames).

Finite differences#

The finite difference coefficients \(c_k\) approximate the derivative of order \(n\) of a function at a point \(t\) from its values at the points \(t_k\) of a stencil:

\[f^{(n)}(t) \approx \sum_k c_k \, f(t_k)\]

The coefficients are computed for any (non-uniform) stencil with the algorithm of Fornberg, and the stencils can be centered, forward or backward.

Coefficients#

Matrices#

The matrix \(D\) of a finite difference over a whole signal, \(f^{(n)} \approx D f\) (one row per evaluated point), for example to build a linear regularization term.

Application to a signal#

Polynomial fitting#

Fit a polynomial to sampled values in the least squares sense and evaluate it, e.g. to extrapolate a displacement from the previous frames.