| |
Program Functions
109
6.4 DisplacementField
This directory contains functions that are used to deal with the displacement fields for all pix-
els (u and v) and the displacement fields for the control points (cu and cv).
biline_weight.m
To calculate the displacement fields for all pixels (u and v) from the displacement field for the
control points (cu and cv), bilinear interpolation is used. Since this calculation has to be done
very often, the bilinear weights for all control points are calculated in advance and stored in a
sparse matrix. Sparse matrices consume less memory and the computational speed can be im-
proved by using a sparse matrix. The format of the weights matrix was also changed com-
pared with the format at the beginning so that the calculation of the u and v could be vector-
ized. For more on this topic, please refer to the explanation of the function vCu2U below.
The function biline_weight was tested by displaying weights for single control points (see
Figure 38). In addition, the weights for all control points were written into one image. This
resulted in a homogenous image, where every pixel had the value one. This was expected.
vCalcCtrlPtDists.m
This is a very short function that calculates the distance in pixels between neighboring control
points based on the image size (vertical and horizontal) in pixels and the number of control
points in the vertical and horizontal directions.
vCtrlPtIndex2xy.m
Based on a linear control point index and some other input variables, namely the numbers of
control points and the pixel distances between control points, this function calculates the x (in
horizontal direction) and y (in vertical direction) positions of a control point within an image.
The linear control point index is defined as follows: Index 1 is given to the control point
that corresponds to the entry in the upper left corner of the control point displacements matri-
|  |
|
| |
|
|