Changeset 1072 for trunk/psLib/src/imageops/psImageStats.c
- Timestamp:
- Jun 23, 2004, 11:41:15 AM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/imageops/psImageStats.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/imageops/psImageStats.c
r1025 r1072 155 155 } 156 156 157 /***************************************************************************** 158 p_psCalcScaleFactorsEval(n): The Chebyshev polynomials are defined over the 159 interval [-1.0 : 1.0]. Images typically have sizes of 512x512 or more. In 160 order to use Chebyshev polynomials, we must scales the coordinates from 161 0:512 to -1:1. This routine takes as input an integer N and produces as 162 output a vector of evenly spaced floating point values between -1.0:1.0. 163 *****************************************************************************/ 157 164 float *p_psCalcScaleFactorsEval(int n) 158 165 { … … 200 207 201 208 /***************************************************************************** 202 psImageFitPolynomial(): 203 This routine takes as input a 2-D image and produces as output 204 the coefficients of the Chebyshev polynomials which match that 205 input image. 206 Input: 207 Output: 208 Internal Data Structures: 209 210 chebPolys[i][j] 211 212 sums[i][j]: This will contain the sum of 213 input->data.F32[x][y] * 209 psImageFitPolynomial(): This routine takes as input a 2-D image and produces 210 as output the coefficients of the Chebyshev polynomials which match that 211 input image. 212 Input: 213 Output: 214 Internal Data Structures: 215 chebPolys[i][j] 216 sums[i][j]: This will contain the sum of 217 input->data.F32[x][y] * 214 218 psEvalPolynomial1D((float) x, chebPolys[i]) * 215 219 psEvalPolynomial1D((float) y, chebPolys[j]); 216 over all pixels (x,y) in the image. 217 218 220 over all pixels (x,y) in the image. 219 221 *****************************************************************************/ 220 222 psPolynomial2D * … … 253 255 chebPolys = p_psCreateChebyshevPolys(maxChebyPoly); 254 256 255 // Sanity check for the Chebyshevs 257 // Sanity check for the Chebyshevs. 256 258 for (i=0;i<coeffs->nX;i++) { 257 259 for (j=0;j<coeffs->nY;j++) { … … 262 264 263 265 } 264 } 265 } 266 266 printf("SUM(Cheby(%d) * Cheby(%d)) is %f\n", i, j, tmp); 267 } 268 } 269 270 // Compute the sums[][] data structure. 267 271 for (i=0;i<coeffs->nX;i++) { 268 272 for (j=0;j<coeffs->nY;j++) { … … 279 283 280 284 // NOTE: Check the math on this at a later date. 281 coeffs->coeff[0][0] = sums[0][0] / ((float) (coeffs->nX * coeffs->nY)); 282 for (i=0;i<coeffs->nX;i++) { 283 coeffs->coeff[i][0] = ((sums[i][0] * 2.0) / 284 ((float) (coeffs->nX * coeffs->nY))) - 285 coeffs->coeff[0][0]; 286 } 287 for (j=0;j<coeffs->nY;j++) { 288 coeffs->coeff[0][j] = 289 ((sums[0][j] * 2.0) / 290 ((float) (coeffs->nX * coeffs->nY))) - 291 coeffs->coeff[0][0]; 292 } 293 for (i=1;i<coeffs->nX;i++) { 294 for (j=1;j<coeffs->nY;j++) { 295 coeffs->coeff[i][j] = 296 ((sums[i][0] * 4.0) / ((float) (coeffs->nX * coeffs->nY))) - 297 (coeffs->coeff[0][0] + 298 coeffs->coeff[i][0] + 299 coeffs->coeff[0][j]); 285 // coeffs->coeff[0][0] = sums[0][0] / ((float) (coeffs->nX * coeffs->nY)); 286 // for (i=0;i<coeffs->nX;i++) { 287 // coeffs->coeff[i][0] = ((sums[i][0] * 2.0) / 288 // ((float) (coeffs->nX * coeffs->nY))) - 289 // coeffs->coeff[0][0]; 290 // } 291 // for (j=0;j<coeffs->nY;j++) { 292 // coeffs->coeff[0][j] = 293 // ((sums[0][j] * 2.0) / 294 // ((float) (coeffs->nX * coeffs->nY))) - 295 // coeffs->coeff[0][0]; 296 // } 297 298 for (i=0;i<coeffs->nX;i++) { 299 for (j=0;j<coeffs->nY;j++) { 300 coeffs->coeff[i][j] = sums[i][j]; 301 coeffs->coeff[i][j]/= ((float) coeffs->nX) * ((float) coeffs->nY); 302 if ((i != 0) && (j != 0)) { 303 coeffs->coeff[i][j]*= 4.0; 304 } else if ((i == 0) && (j == 0)) { 305 coeffs->coeff[i][j]*= 1.0; 306 } else { 307 coeffs->coeff[i][j]*= 2.0; 308 } 309 310 // coeffs->coeff[i][j] = 311 // ((sums[i][0] * 4.0) / ((float) (coeffs->nX * coeffs->nY))) - 312 // (coeffs->coeff[0][0] + 313 // coeffs->coeff[i][0] + 314 // coeffs->coeff[0][j]); 300 315 } 301 316 }
Note:
See TracChangeset
for help on using the changeset viewer.
