IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 21445


Ignore:
Timestamp:
Feb 11, 2009, 6:40:36 PM (17 years ago)
Author:
eugene
Message:

adding error calculation to psImageBicubeFit

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branch_20090208/psLib/src/math/psPolynomialUtils.c

    r21408 r21445  
    139139// XXX determine the errors, and propagate to the output of psImageBicubeMin
    140140// XXX x,y are the image pixel index, but the fit is implied for the image pixel coordinates (0.5,0.5 center)
     141// this solution is determined assuming constant weight per pixel
    141142psPolynomial2D *psImageBicubeFit(const psImage *image, int x, int y)
    142143{
     
    179180psPlane psImageBicubeMin(const psPolynomial2D *poly)
    180181{
    181     psPlane min = { NAN, NAN, 0, 0 };   // Minimum value to return
     182    psPlane min = { NAN, NAN, NAN, NAN };   // Minimum value to return
    182183
    183184    PS_ASSERT_PTR_NON_NULL(poly, min);
     
    186187
    187188    double det = 4*poly->coeff[2][0]*poly->coeff[0][2] - PS_SQR(poly->coeff[1][1]); // Determinant
    188     min.x = (poly->coeff[1][1]*poly->coeff[0][1] - 2*poly->coeff[0][2]*poly->coeff[1][0]) / det;
    189     min.y = (poly->coeff[1][1]*poly->coeff[1][0] - 2*poly->coeff[2][0]*poly->coeff[0][1]) / det;
     189    double xn = (poly->coeff[1][1]*poly->coeff[0][1] - 2*poly->coeff[0][2]*poly->coeff[1][0]);
     190    double yn = (poly->coeff[1][1]*poly->coeff[1][0] - 2*poly->coeff[2][0]*poly->coeff[0][1]);
     191
     192    min.x = xn / det;
     193    min.y = yn / det;
     194
     195    // without a supplied error, we calculate the normalized error
     196    double detErr2 = 4.0*PS_SQR(poly->coeff[1][1])/6.0 + 8.0*PS_SQR(poly->coeff[0][2]) + 8.0*PS_SQR(poly->coeff[2][0]);
     197    double xnErr2 = PS_SQR(poly->coeff[0][1])/6.0 + PS_SQR(poly->coeff[1][1])/6.0 + 2.0*PS_SQR(poly->coeff[1][0]) + 4.0*PS_SQR(poly->coeff[0][2])/6.0;
     198    double ynErr2 = PS_SQR(poly->coeff[1][0])/6.0 + PS_SQR(poly->coeff[1][1])/6.0 + 2.0*PS_SQR(poly->coeff[0][1]) + 4.0*PS_SQR(poly->coeff[2][0])/6.0;
     199
     200    min.xErr = min.x * sqrt(xnErr2 / PS_SQR(xn) + detErr2 / PS_SQR(det));
     201    min.yErr = min.y * sqrt(ynErr2 / PS_SQR(yn) + detErr2 / PS_SQR(det));
    190202
    191203    return min;
Note: See TracChangeset for help on using the changeset viewer.