Changeset 21518 for trunk/psLib/src/math/psPolynomialUtils.c
- Timestamp:
- Feb 16, 2009, 12:31:47 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/math/psPolynomialUtils.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/math/psPolynomialUtils.c
r21183 r21518 139 139 // XXX determine the errors, and propagate to the output of psImageBicubeMin 140 140 // 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 141 142 psPolynomial2D *psImageBicubeFit(const psImage *image, int x, int y) 142 143 { … … 179 180 psPlane psImageBicubeMin(const psPolynomial2D *poly) 180 181 { 181 psPlane min = { NAN, NAN, 0, 0}; // Minimum value to return182 psPlane min = { NAN, NAN, NAN, NAN }; // Minimum value to return 182 183 183 184 PS_ASSERT_PTR_NON_NULL(poly, min); … … 186 187 187 188 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); 190 204 191 205 return min;
Note:
See TracChangeset
for help on using the changeset viewer.
