KPG1_ALIGN

Align a pair of 2-dimensional arrays using a least squares fit

Description:

This routine aligns a pair of 2-dimensional arrays using a least squares fit. The two arrays must be the same size and are assumed to be connected by an affine transformation, and to be in near alignment.

Invocation

CALL KPG1_ALIGN( NX, NY, IPIN, IPREF, VIN, VREF, IPVIN, IPVREF, FORM, IFAC, RFAC, IOFF, ROFF, FITVAL, C, STATUS )

Arguments

NX = INTEGER (Given)
The length of the first pixel axis in each array
NY = INTEGER (Given)
The length of the second pixel axis in each array
IPIN = INTEGER (Given)
Pointer to a _DOUBLE array with dimensions (NX,NY), holding the Data values associated with the IN array.
IPREF = INTEGER (Given)
Pointer to a _DOUBLE array with dimensions (NX,NY), holding the Data values associated with the REF array.
VIN = LOGICAL (Given)
If TRUE, use IPVIN as weights within the minimisation.
VREF = LOGICAL (Given)
If TRUE, use IPVREF as weights within the minimisation.
IPVIN = INTEGER (Given)
Pointer to a _DOUBLE array with dimensions (NX,NY), holding the Variances associated with the IN array. Only used if VIN is .TRUE.
IPVREF = INTEGER (Given)
Pointer to a _DOUBLE array with dimensions (NX,NY), holding the Variances associated with the REF array. Only used if VREF is .TRUE.
FORM = INTEGER (Given)
The form of the affine transformation to use:
  • 0: Full unrestricted 6 coefficient fit

  • 1: Shift, rotation and a common X/Y scale but no shear.

  • 2: Shift and rotation but no scale or shear.

  • 3: Shift but not rotation, scale or shear.

IFAC = DOUBLE PRECISION (Given)
A factor by which the input values should be multipled before being used. Idealy, this should result in them having a standard deviation of unity.
RFAC = DOUBLE PRECISION (Given)
A factor by which the reference values should be multipled before being used. Idealy, this should result in them having a standard deviation of unity.
IOFF = DOUBLE PRECISION (Given)
An offset to subtract from the scaled input values before being used. Idealy, this should result in them having a mean of zero.
ROFF = DOUBLE PRECISION (Given)
An offset to subtract from the scaled reference values before being Used. Idealy, this should result in them having a mean of zero.
FITVAL = LOGICAL (Given)
If TRUE, then the fit is extended to include the relative scale factor and zero point offset between the pixle values in the two arrays.
C = DOUBLE PRECISION( ) (Returned)
The coefficients of the affine transformation:
  • Xin = C1 + C2Xref + C3Yref

  • Yin = C4 + C5Xref + C6Yref

(Xin,Yin) are grid coordinates in IN, and (Xref,Yref) are grid coordinates in REF. If FITVAL is FALSE, this array should have at least 6 elements. Otherwise it should have at least 8 elements. The last two elements give the relationship between the pixel values in the two arrays:

  • in = C7ref + C8

STATUS = INTEGER (Given and Returned)
The global status.