interpolation

interpolation — General interpolation functions

Synopsis




enum        GwyInterpolationType;
gdouble     gwy_interpolation_get_dval      (gdouble x,
                                             gdouble x1_,
                                             gdouble y1_,
                                             gdouble x2_,
                                             gdouble y2_,
                                             GwyInterpolationType interpolation);
gdouble     gwy_interpolation_get_dval_of_equidists
                                            (gdouble x,
                                             gdouble *data,
                                             GwyInterpolationType interpolation);

Description

Details

enum GwyInterpolationType

typedef enum {
  GWY_INTERPOLATION_NONE      = 0,
  GWY_INTERPOLATION_ROUND     = 1,
  GWY_INTERPOLATION_BILINEAR  = 2,
  GWY_INTERPOLATION_KEY       = 3,
  GWY_INTERPOLATION_BSPLINE   = 4,
  GWY_INTERPOLATION_OMOMS     = 5,
  GWY_INTERPOLATION_NNA       = 6
} GwyInterpolationType;

Interpolation types.

GWY_INTERPOLATION_NONE No interpolation at all, resulting values are not meaningful and should not be used (use for resize operations discarding original data).
GWY_INTERPOLATION_ROUND Round interpolation (nearest neighbour interpolation).
GWY_INTERPOLATION_BILINEAR Bilinear interpolation.
GWY_INTERPOLATION_KEY Key interpolation.
GWY_INTERPOLATION_BSPLINE B-spline interpolation.
GWY_INTERPOLATION_OMOMS Omoms interpolation
GWY_INTERPOLATION_NNA Nearest neighbour approximation.

gwy_interpolation_get_dval ()

gdouble     gwy_interpolation_get_dval      (gdouble x,
                                             gdouble x1_,
                                             gdouble y1_,
                                             gdouble x2_,
                                             gdouble y2_,
                                             GwyInterpolationType interpolation);

This function uses two-point interpolation methods to get interpolated value between two arbitrary data points.

x : requested value coordinate
x1_ : x coordinate of first value
y1_ : y coordinate of first value
x2_ : x coordinate of second value
y2_ : y coordinate of second value
interpolation : interpolation type
Returns : interpolated value

gwy_interpolation_get_dval_of_equidists ()

gdouble     gwy_interpolation_get_dval_of_equidists
                                            (gdouble x,
                                             gdouble *data,
                                             GwyInterpolationType interpolation);

Function computes interpolateed value bettween 2 or 4 equidistant values. For using GWY_INTERPOLATION_NONE, GWY_INTERPOLATION_ROUND or GWY_INTERPOLATION_BILINEAR it is enough to use data in format {0, data[i], data[i+1], 0} and function computes value at data[i+x]. For four value interpolations you have to prapare data as {data[i-1], data[i], data[i+1], data[i+2]} and function again returns value at data[i+x].

x : noninteger part of requested x
data : array of 4 gdoubles (see below)
interpolation : interpolation type
Returns : interpolated value