Changeset 2262 for trunk/psLib/src/image/psImageStats.c
- Timestamp:
- Nov 1, 2004, 4:03:56 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/image/psImageStats.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/image/psImageStats.c
r2261 r2262 9 9 * @author GLG, MHPCC 10 10 * 11 * @version $Revision: 1.4 7$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-11-02 0 1:52:43$11 * @version $Revision: 1.48 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-11-02 02:03:56 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 248 248 psPolynomial1DEval((float) y, chebPolys[j]); 249 249 over all pixels (x,y) in the image. 250 251 XXX: Currently we only support F32. 252 *****************************************************************************/ 250 *****************************************************************************/ 253 251 psPolynomial2D* psImageFitPolynomial(psPolynomial2D* coeffs, 254 252 const psImage* input) 255 253 { 254 PS_IMAGE_CHECK_NULL(input, NULL); 255 PS_IMAGE_CHECK_EMPTY(input, NULL); 256 if ((input->type.type != PS_TYPE_S8) && 257 (input->type.type != PS_TYPE_U16) && 258 (input->type.type != PS_TYPE_F32) && 259 (input->type.type != PS_TYPE_F64)) { 260 psError(__func__, "Unalowwable image type.\n"); 261 } 262 PS_POLY_CHECK_NULL(coeffs, NULL); 263 PS_POLY_CHECK_TYPE(coeffs, PS_POLYNOMIAL_CHEB, NULL); 256 264 psS32 x = 0; 257 265 psS32 y = 0; … … 308 316 for (x = 0; x < input->numRows; x++) { 309 317 for (y = 0; y < input->numCols; y++) { 310 sums[i][j] += 311 input->data.F32[x][y] * 312 psPolynomial1DEval(rScalingFactors[x], chebPolys[i]) * 313 psPolynomial1DEval(cScalingFactors[y], chebPolys[j]); 318 double pixel; 319 if (input->type.type == PS_TYPE_S8) { 320 pixel = (double) input->data.S8[x][y]; 321 } else if (input->type.type == PS_TYPE_U16) { 322 pixel = (double) input->data.U16[x][y]; 323 } else if (input->type.type == PS_TYPE_F32) { 324 pixel = (double) input->data.F32[x][y]; 325 } else if (input->type.type == PS_TYPE_F64) { 326 pixel = input->data.F64[x][y]; 327 } 328 sums[i][j] += pixel * 329 psPolynomial1DEval(rScalingFactors[x], chebPolys[i]) * 330 psPolynomial1DEval(cScalingFactors[y], chebPolys[j]); 314 331 } 315 332 } … … 320 337 for (j = 0; j < coeffs->nY; j++) { 321 338 coeffs->coeff[i][j] = sums[i][j]; 322 coeffs->coeff[i][j] /= ( float)(input->numRows * input->numCols);339 coeffs->coeff[i][j] /= (double)(input->numRows * input->numCols); 323 340 324 341 if ((i != 0) && (j != 0)) { … … 352 369 /***************************************************************************** 353 370 XXX: Use static variables for chebyshev polynomials and scaling factors. 354 355 XXX: Currently we only support F32.356 S8, U16, F32, F64357 371 *****************************************************************************/ 358 372 psImage* psImageEvalPolynomial(psImage* input, const psPolynomial2D* coeffs) … … 373 387 psS32 i = 0; 374 388 psS32 j = 0; 375 // float **sums = NULL;376 389 psPolynomial1D* *chebPolys = NULL; 377 390 psS32 maxChebyPoly = 0; … … 407 420 } 408 421 } 409 input->data.F32[x][y] = polySum; 422 423 if (input->type.type == PS_TYPE_S8) { 424 input->data.S8[x][y] = (char) polySum; 425 } else if (input->type.type == PS_TYPE_U16) { 426 input->data.U16[x][y] = (short int) polySum; 427 } else if (input->type.type == PS_TYPE_F32) { 428 input->data.F32[x][y] = (float) polySum; 429 } else if (input->type.type == PS_TYPE_F64) { 430 input->data.F64[x][y] = polySum; 431 } 410 432 } 411 433 }
Note:
See TracChangeset
for help on using the changeset viewer.
