Woolz Image Processing  Version 1.7.5
WlzKrig.c File Reference

Functions for interpolation based on kriging. More...

Functions

void WlzKrigSetModelFn (WlzKrigModelFn *fn, WlzKrigModelFnType type, double c0, double c1, double a)
 Sets a kriging function data stuctures parameters and function pointer. See the kriging model function types and their implementation for the meaning of the parameters. More...
 
double WlzKrigModelFnNugget (WlzKrigModelFn *f, double h)
 A nugget kriging variance model.

\[ \left\{ \begin{array}{ll} h = 0 & \gamma(h) = 0 \\ h > 0 & \gamma(h) = c_0 \end{array} \right. \]

. More...

 
double WlzKrigModelFnLinear (WlzKrigModelFn *f, double h)
 A linear kriging variance model.

\[ \left\{ \begin{array}{ll} h < a & \gamma(h) = c_0 + \frac{(c_1 - c_0)}{a} h \\ h \geq a & \gamma(h) = c_1 \end{array} \right. \]

. More...

 
double WlzKrigModelFnSpherical (WlzKrigModelFn *f, double h)
 A spherical kriging variance model.

\[ \left\{ \begin{array}{ll} 0 < h \leq a & \gamma(h) = c_0 + c_1 \frac{1}{2} (\frac{3h}{a} - \frac{h^3}{a^3}) \\ h > a & \gamma(h) = c_0 + c_1 \end{array} \right. \]

. More...

 
double WlzKrigModelFnExponential (WlzKrigModelFn *f, double h)
 An exponential kriging variance model.

\[ \gamma(h) = c_0 + c_1(1 - e^{-\frac{h}{a}}) \]

. More...

 
double WlzKrigModelFnGaussian (WlzKrigModelFn *f, double h)
 A Gaussian kriging variance model.

\[ \gamma(h) = c_0 + c_1(1 - e^{-(\frac{h}{a})^2}) \]

. More...

 
double WlzKrigModelFnQuadratic (WlzKrigModelFn *f, double h)
 A Quadratic kriging variance model.

\[ \gamma(h) = c_0 + c_1 \left( \frac{ (\frac{h}{a})^2} {1 + (\frac{h}{a})^2} \right) \]

. More...

 
WlzErrorNum WlzKrigOSetModelSV2D (AlgMatrix modelSV, WlzKrigModelFn *modelFn, int n, WlzDVertex2 *nbr, int *wSp)
 Computes the ordinary kriging model semi-variogram from the given neighbourhood vertices. More...
 
WlzErrorNum WlzKrigOSetModelSV3D (AlgMatrix modelSV, WlzKrigModelFn *modelFn, int n, WlzDVertex3 *nbr, int *wSp)
 Computes the ordinary kriging model semi-variogram from the given neighbourhood vertices. More...
 
WlzErrorNum WlzKrigOSetPosSV2D (double *posSV, WlzKrigModelFn *modelFn, int n, WlzDVertex2 *nbr, WlzDVertex2 pos)
 Computes the ordinary kriging position semi-variogram from the given neighbourhood vertices and the given position vertex. More...
 
WlzErrorNum WlzKrigOSetPosSV3D (double *posSV, WlzKrigModelFn *modelFn, int n, WlzDVertex3 *nbr, WlzDVertex3 pos)
 Computes the ordinary kriging position semi-variogram from the given neighbourhood vertices and the given position vertex. More...
 
WlzErrorNum WlzKrigOWeightsSolve (AlgMatrix modelSV, double *posSV, int *wSp, double eps)
 Computes the ordinary kriging weights from the model and position semi-variograms. More...
 
WlzErrorNum WlzKrigReallocBuffers2D (WlzDVertex2 **dstNbrPosBuf, double **dstPosSV, int **dstWSp, AlgMatrix *dstModelSV, int *dstMaxKrigBuf, int nNbrC, int nNbrL)
 A convinience function for allocating and reallocating the buffers needed for 2D kriging. All given pointers must be valid and on the first call all pointer values (eg *dstNbrPosBuf) must be NULL. More...
 
WlzErrorNum WlzKrigReallocBuffers3D (WlzDVertex3 **dstNbrPosBuf, double **dstPosSV, int **dstWSp, AlgMatrix *dstModelSV, int *dstMaxKrigBuf, int nNbrC, int nNbrL)
 A convinience function for allocating and reallocating the buffers needed for 3D kriging. All given pointers must be valid and on the first call all pointer values (eg *dstNbrPosBuf) must be NULL. More...
 

Detailed Description

Functions for interpolation based on kriging.

Author
Bill Hill
Date
October 2012
Version
Id
44a4631c99a5a59dc0b6b7a55014432b84db2bd2
Address: MRC Human Genetics Unit, MRC Institute of Genetics and Molecular Medicine, University of Edinburgh, Western General Hospital, Edinburgh, EH4 2XU, UK.
Copyright (C), [2012], The University Court of the University of Edinburgh, Old College, Edinburgh, UK.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Kriging is an interpolation method from geo-statistics (hence some terms such as nugget), which aims to find the Best Linear Unbiased Estimate (BLUE) of a value at some point in space based on the semi-variograms of the values within some local region. The procedure is first to choose a model for the semi-variogram behavior which when plotted against the lag (distance) is assumed to have a nugget (constant or intercept variance), sill (variance at an infinite lag) and range (lag for which values have little correlation). This should be set using WlzKrigSetModelFn(). The model semi-variogram should then be computed using WlzKrigOSetModelSV2D() and then for each position to be interpolated with this model (ie all positions where the model is valid) WlzKrigOSetPosSV2D() should be called followed by WlzKrigOWeightsSolve().

For a simple system in which there are \(N\) known values \(\{v_i\}\) at positions \(\{p_i\}\) ( \(i \in [1-N]\)) then we want to estimate a system of weights \(\{w_i\}\) such that the value \(v_x\) at some position \(p_x\) can be computed by a simple linear system of weights

\[ v_x = \sum_i w_i v_i \]

with the weights computed such that \( \sum_i w_i = 1\). Setting \(h_{ij} = \|p_i - p_j\|\) and having choosen a variance model \(\gamma\) then

\[ \mathbf{M} \mathbf{w} = \mathbf{p} \]

where \(\mathbf{M} = \gamma(h_{ij})\), \(\mathbf{w} = w_j\) and \(\mathbf{p} = h_{i}\). In practice a slack variable \(\lambda\) is added to the weights column vector and both the model matrix and position vector are padded using to 1. This equation is then solved for the weights.

Function Documentation

double WlzKrigModelFnNugget ( WlzKrigModelFn f,
double  h 
)

A nugget kriging variance model.

\[ \left\{ \begin{array}{ll} h = 0 & \gamma(h) = 0 \\ h > 0 & \gamma(h) = c_0 \end{array} \right. \]

.

Returns
Function output value.
Parameters
fThe kriging function data stucture.
hFunction input value.

References _WlzKrigModelFn::c0.

Referenced by WlzKrigSetModelFn().