IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 21518


Ignore:
Timestamp:
Feb 16, 2009, 12:31:47 PM (17 years ago)
Author:
eugene
Message:

calculate error on psImageBicubeMin

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/math/psPolynomialUtils.c

    r21183 r21518  
    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    // sigma_xn^2 / xn^2 = sigma_11^2 / C11
     196
     197    // without a supplied error, we calculate the normalized error
     198    double fdetErr2 = 0.5/PS_SQR(poly->coeff[0][2]) + 0.5/PS_SQR(poly->coeff[2][0]) + 4.0/(6.0*PS_SQR(poly->coeff[1][1]));
     199    double fxnErr2 = 1.0/(6.0*PS_SQR(poly->coeff[0][1])) + 1.0/(6.0*PS_SQR(poly->coeff[1][0])) + 1.0/(6.0*PS_SQR(poly->coeff[1][1])) + 0.5/PS_SQR(poly->coeff[0][2]);
     200    double fynErr2 = 1.0/(6.0*PS_SQR(poly->coeff[0][1])) + 1.0/(6.0*PS_SQR(poly->coeff[1][0])) + 1.0/(6.0*PS_SQR(poly->coeff[1][1])) + 0.5/PS_SQR(poly->coeff[2][0]);
     201
     202    min.xErr = fabs(min.x) * sqrt(fxnErr2 + fdetErr2);
     203    min.yErr = fabs(min.y) * sqrt(fynErr2 + fdetErr2);
    190204
    191205    return min;
Note: See TracChangeset for help on using the changeset viewer.