dicinterpolator.hpp¶
-
struct InterpVals¶
- #include <dicinterpolator.hpp>
namespace for bicubic spline interpolation.
Based on the implementation by GNU Scientific Library (GSL). Main difference is the removal of the binary search for index lookup. For use in DIC, we only ever need integer locations and therefore its sufficient to get the floor value of the subpixel location.
-
class Interpolator¶
Public Functions
-
Interpolator(double *img, int px_hori, int px_vert)¶
Initializes the bicubic interpolator with deformed image data.
Sets up the necessary data structures and computes derivatives required for bicubic interpolation.
- Parameters:
img – Pointer to the image data array
px_hori – Width of the image in pixels
px_vert – Height of the image in pixels
-
double eval_bicubic(const int ss_x, const int ss_y, const double subpx_x, const double subpx_y) const¶
Evaluates the bicubic interpolation at a specified point.
Computes the interpolated value at (x,y) using bicubic interpolation from the surrounding pixel values.
- Parameters:
x – The x-coordinate of the interpolation point
y – The y-coordinate of the interpolation point
- Returns:
The interpolated value at (x,y)
-
double eval_bicubic_dx(const int ss_x, const int ss_y, const double subpx_x, const double subpx_y) const¶
Evaluates the x-derivative of bicubic interpolation at a specified point.
Computes the partial derivative with respect to x at point (x,y).
- Parameters:
x – The x-coordinate of the point
y – The y-coordinate of the point
- Returns:
The x-derivative of the interpolated function at (x,y)
-
double eval_bicubic_dy(const int ss_x, const int ss_y, const double subpx_x, const double subpx_y) const¶
Evaluates the y-derivative of bicubic interpolation at a specified point.
Computes the partial derivative with respect to y at point (x,y).
- Parameters:
x – The x-coordinate of the point
y – The y-coordinate of the point
- Returns:
The y-derivative of the interpolated function at (x,y)
-
InterpVals eval_bicubic_and_derivs(const int ss_x, const int ss_y, const double subpx_x, const double subpx_y) const¶
Evaluates the bicubic interpolation and its derivatives at a specified point.
Computes the interpolated value and its partial derivatives at (x,y) in a single call.
- Parameters:
x – The x-coordinate of the point
y – The y-coordinate of the point
- Returns:
Data struct containing the interpolated value and its x and y derivatives
Public Members
-
std::vector<double> dx¶
-
std::vector<double> dy¶
-
std::vector<double> dxy¶
-
std::vector<double> tridiag_solution¶
-
std::vector<double> px_y¶
-
std::vector<double> px_x¶
-
double *image¶
-
int px_vert¶
-
int px_hori¶
Private Functions
-
inline void coeff_calc(std::vector<double> &tridiag_solution, double dy, double dx, size_t index, double *b, double *c, double *d)¶
Calculates the coefficients for cubic spline interpolation.
Computes the coefficients b, c, and d for the cubic spline polynomial.
- Parameters:
tridiag_solution – The solution vector from the tridiagonal system
dy – Difference in function values
dx – Difference in x values
index – Current index in the data array
b – Pointer to store the computed b coefficient
c – Pointer to store the computed c coefficient
d – Pointer to store the computed d coefficient
-
inline void index_lookup_xy(const int ss_x, const int ss_y, size_t &xi, size_t &yi, const double subpx_x, const double subpx_y) const¶
-
inline int index_lookup(const std::vector<double> &px, double x) const¶
Finds the index of the pixel that contains the given coordinate.
Determines the lower index of the interval containing the specified value.
- Parameters:
px – Vector of pixel coordinates
x – The coordinate to look up
- Returns:
The index of the pixel containing the coordinate
-
void cspline_init(std::vector<double> &px, std::vector<double> &data)¶
Initializes the cubic spline coefficients.
Sets up the tridiagonal system and solves it to obtain the cubic spline coefficients.
- Parameters:
px – Vector of x coordinates
data – Vector of function values at the x coordinates
-
double cspline_eval_deriv(std::vector<double> &px, std::vector<double> &data, double value, int length)¶
Evaluates the derivative of a cubic spline at a specified point.
Computes the first derivative of the cubic spline function at the given value.
- Parameters:
px – Vector of x coordinates
data – Vector of function values at the x coordinates
value – The point at which to evaluate the derivative
length – The length of the px and data arrays
- Returns:
The derivative value at the specified point
-
Interpolator(double *img, int px_hori, int px_vert)¶