Changeset 2261
- Timestamp:
- Nov 1, 2004, 3:52:43 PM (22 years ago)
- Location:
- trunk/psLib/src
- Files:
-
- 4 edited
-
dataManip/psConstants.h (modified) (2 diffs)
-
image/psImageStats.c (modified) (9 diffs)
-
imageops/psImageStats.c (modified) (9 diffs)
-
math/psConstants.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/dataManip/psConstants.h
r2230 r2261 6 6 * @author GLG, MHPCC 7 7 * 8 * @version $Revision: 1.3 1$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-1 0-28 23:03:11$8 * @version $Revision: 1.32 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-11-02 01:52:43 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 225 225 } \ 226 226 227 227 #define PS_POLY_CHECK_TYPE(NAME, TYPE, RVAL) \ 228 if (NAME->type != TYPE) { \ 229 psError(__func__,"Unallowable operation: polynomial %s has wrong type.", #NAME); \ 230 return(RVAL); \ 231 } \ 228 232 229 233 /***************************************************************************** -
trunk/psLib/src/image/psImageStats.c
r2212 r2261 9 9 * @author GLG, MHPCC 10 10 * 11 * @version $Revision: 1.4 6$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-1 0-27 20:07:17$11 * @version $Revision: 1.47 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-11-02 01:52:43 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 149 149 } 150 150 151 double *CalcScaleFactors(psS32 n) 152 { 153 psS32 i = 0; 154 double tmp = 0.0; 155 double *scalingFactors = (double *)psAlloc(n * sizeof(double)); 156 157 for (i = 0; i < n; i++) { 158 tmp = (double)(n - i); 159 tmp = (M_PI * (tmp - 0.5)) / ((double)n); 160 scalingFactors[i] = cos(tmp); 161 } 162 163 return (scalingFactors); 164 } 165 151 166 // XXX: Why do we have this function? 152 float *p_psCalcScaleFactorsFit(psS32 n)153 { 154 psS32 i = 0; 155 floattmp = 0.0;156 float *scalingFactors = (float *)psAlloc(n * sizeof(float));167 double *CalcScaleFactorsFit(psS32 n) 168 { 169 psS32 i = 0; 170 double tmp = 0.0; 171 double *scalingFactors = (double *)psAlloc(n * sizeof(double)); 157 172 158 173 for (i = 0; i < n; i++) { 159 // ((2.0 * (float) i) / ((float) (n-1))) 160 // - 1.0; 161 // tmp = (float) (i + 1); 162 tmp = (float)(n - i); 163 tmp = (M_PI * (tmp - 0.5)) / ((float)n); 174 tmp = (double)(n - i); 175 tmp = (M_PI * (tmp - 0.5)) / ((double)n); 164 176 scalingFactors[i] = cos(tmp); 165 177 } … … 169 181 170 182 /***************************************************************************** 171 p_psCalcScaleFactorsEval(n): The Chebyshev polynomials are defined over the183 CalcScaleFactorsEval(n): The Chebyshev polynomials are defined over the 172 184 interval [-1.0 : 1.0]. Images typically have sizes of 512x512 or more. In 173 185 order to use Chebyshev polynomials, we must scale the coordinates from … … 175 187 output a vector of evenly spaced floating point values between -1.0:1.0. 176 188 *****************************************************************************/ 177 float *p_psCalcScaleFactorsEval(psS32 n) 178 { 179 psS32 i = 0; 180 float tmp = 0.0; 181 182 return p_psCalcScaleFactorsFit(n); 183 184 printf("Should not get here\n"); 185 float *scalingFactors = (float *)psAlloc(n * sizeof(float)); 189 double *CalcScaleFactorsEval(psS32 n) 190 { 191 psS32 i = 0; 192 double tmp = 0.0; 193 194 return(CalcScaleFactorsFit(n)); 195 196 double *scalingFactors = (double *)psAlloc(n * sizeof(double)); 186 197 187 198 for (i = 0; i < n; i++) { 188 // scalingFactors[i] = ((2.0 * (float) i) 189 // / ((float) (n-1))) - 1.0; 190 tmp = (float)(n - i); 191 tmp = (M_PI * (tmp - 0.5)) / ((float)n); 199 tmp = (double)(n - i); 200 tmp = (M_PI * (tmp - 0.5)) / ((double)n); 192 201 scalingFactors[i] = cos(tmp); 193 202 } … … 249 258 psS32 i = 0; 250 259 psS32 j = 0; 251 float**sums = NULL;260 double **sums = NULL; 252 261 psPolynomial1D* *chebPolys = NULL; 253 262 psS32 maxChebyPoly = 0; 254 float*cScalingFactors = NULL;255 float*rScalingFactors = NULL;263 double *cScalingFactors = NULL; 264 double *rScalingFactors = NULL; 256 265 257 266 // Check for null inputs … … 275 284 // 29 in the ADD: sums[k][l] = SUM { 276 285 // image(x,y) * Tk(x) * Tl(y) } 277 sums = ( float **)psAlloc(coeffs->nX * sizeof(float*));286 sums = (double **)psAlloc(coeffs->nX * sizeof(double *)); 278 287 for (i = 0; i < coeffs->nX; i++) { 279 sums[i] = ( float *)psAlloc(coeffs->nY * sizeof(float));288 sums[i] = (double *)psAlloc(coeffs->nY * sizeof(double)); 280 289 } 281 290 // We scale the pixel positions to values 282 291 // between -1.0 and 1.0 283 rScalingFactors = p_psCalcScaleFactorsFit(input->numRows);284 cScalingFactors = p_psCalcScaleFactorsFit(input->numCols);292 rScalingFactors = CalcScaleFactors(input->numRows); 293 cScalingFactors = CalcScaleFactors(input->numCols); 285 294 286 295 // Determine how many Chebyshev polynomials … … 292 301 chebPolys = p_psCreateChebyshevPolys(maxChebyPoly); 293 302 294 295 /*296 // Sanity check for the Chebyshevs.297 for (i = 0; i < coeffs->nX; i++) {298 for (j = 0; j < coeffs->nY; j++) {299 tmp = 0.0;300 for (x = 0; x < input->numRows; x++) {301 tmp +=302 psPolynomial1DEval303 (rScalingFactors[x], chebPolys[i]) * psPolynomial1DEval(rScalingFactors[x], chebPolys[j]);304 305 }306 // printf("SUM(Cheby(%d) * Cheby(%d))307 // is %f\n", i, j, tmp);308 }309 }310 */311 303 312 304 // Compute the sums[][] data structure. … … 362 354 363 355 XXX: Currently we only support F32. 356 S8, U16, F32, F64 364 357 *****************************************************************************/ 365 358 psImage* psImageEvalPolynomial(psImage* input, const psPolynomial2D* coeffs) 366 359 { 360 PS_IMAGE_CHECK_NULL(input, NULL); 361 PS_IMAGE_CHECK_EMPTY(input, NULL); 362 if ((input->type.type != PS_TYPE_S8) && 363 (input->type.type != PS_TYPE_U16) && 364 (input->type.type != PS_TYPE_F32) && 365 (input->type.type != PS_TYPE_F64)) { 366 psError(__func__, "Unalowwable image type.\n"); 367 } 368 PS_POLY_CHECK_NULL(coeffs, NULL); 369 PS_POLY_CHECK_TYPE(coeffs, PS_POLYNOMIAL_CHEB, NULL); 370 367 371 psS32 x = 0; 368 372 psS32 y = 0; … … 372 376 psPolynomial1D* *chebPolys = NULL; 373 377 psS32 maxChebyPoly = 0; 374 float *cScalingFactors = NULL; 375 float *rScalingFactors = NULL; 376 float polySum = 0.0; 377 378 // Create the sums[][] data structure. This will hold the LHS of 379 // equation 29 in the ADD: 380 // sums[k][l] = SUM { image(x,y) * Tk(x) * Tl(y) } 381 // 382 // sums = (float **)psAlloc(coeffs->nX * sizeof(float *)); 383 // for (i = 0; i < coeffs->nX; i++) { 384 // sums[i] = (float *)psAlloc(coeffs->nY * sizeof(float)); 385 // } 386 // for (i = 0; i < coeffs->nX; i++) { 387 // for (j = 0; j < coeffs->nY; j++) { 388 // sums[i][j] = 0.0; 389 // } 390 // } 391 392 393 // Check for null inputs 394 if (input == NULL) { 395 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageEvalPolynomial", 396 PS_ERR_BAD_PARAMETER_NULL, true, 397 PS_ERRORTEXT_psImage_IMAGE_NULL); 398 return NULL; 399 } 400 401 if (coeffs == NULL) { 402 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageEvalPolynomial", 403 PS_ERR_BAD_PARAMETER_NULL, true, 404 PS_ERRORTEXT_psImage_COEFF_NULL); 405 return NULL; 406 } 378 double *cScalingFactors = NULL; 379 double *rScalingFactors = NULL; 380 double polySum = 0.0; 381 407 382 408 383 // We scale the pixel positions to values between -1.0 and 1.0 409 384 // Use static data structures here. 410 rScalingFactors = p_psCalcScaleFactorsEval(input->numRows);411 cScalingFactors = p_psCalcScaleFactorsEval(input->numCols);385 rScalingFactors = CalcScaleFactors(input->numRows); 386 cScalingFactors = CalcScaleFactors(input->numCols); 412 387 413 388 // Determine how many Chebyshev polynomials -
trunk/psLib/src/imageops/psImageStats.c
r2212 r2261 9 9 * @author GLG, MHPCC 10 10 * 11 * @version $Revision: 1.4 6$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-1 0-27 20:07:17$11 * @version $Revision: 1.47 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-11-02 01:52:43 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 149 149 } 150 150 151 double *CalcScaleFactors(psS32 n) 152 { 153 psS32 i = 0; 154 double tmp = 0.0; 155 double *scalingFactors = (double *)psAlloc(n * sizeof(double)); 156 157 for (i = 0; i < n; i++) { 158 tmp = (double)(n - i); 159 tmp = (M_PI * (tmp - 0.5)) / ((double)n); 160 scalingFactors[i] = cos(tmp); 161 } 162 163 return (scalingFactors); 164 } 165 151 166 // XXX: Why do we have this function? 152 float *p_psCalcScaleFactorsFit(psS32 n)153 { 154 psS32 i = 0; 155 floattmp = 0.0;156 float *scalingFactors = (float *)psAlloc(n * sizeof(float));167 double *CalcScaleFactorsFit(psS32 n) 168 { 169 psS32 i = 0; 170 double tmp = 0.0; 171 double *scalingFactors = (double *)psAlloc(n * sizeof(double)); 157 172 158 173 for (i = 0; i < n; i++) { 159 // ((2.0 * (float) i) / ((float) (n-1))) 160 // - 1.0; 161 // tmp = (float) (i + 1); 162 tmp = (float)(n - i); 163 tmp = (M_PI * (tmp - 0.5)) / ((float)n); 174 tmp = (double)(n - i); 175 tmp = (M_PI * (tmp - 0.5)) / ((double)n); 164 176 scalingFactors[i] = cos(tmp); 165 177 } … … 169 181 170 182 /***************************************************************************** 171 p_psCalcScaleFactorsEval(n): The Chebyshev polynomials are defined over the183 CalcScaleFactorsEval(n): The Chebyshev polynomials are defined over the 172 184 interval [-1.0 : 1.0]. Images typically have sizes of 512x512 or more. In 173 185 order to use Chebyshev polynomials, we must scale the coordinates from … … 175 187 output a vector of evenly spaced floating point values between -1.0:1.0. 176 188 *****************************************************************************/ 177 float *p_psCalcScaleFactorsEval(psS32 n) 178 { 179 psS32 i = 0; 180 float tmp = 0.0; 181 182 return p_psCalcScaleFactorsFit(n); 183 184 printf("Should not get here\n"); 185 float *scalingFactors = (float *)psAlloc(n * sizeof(float)); 189 double *CalcScaleFactorsEval(psS32 n) 190 { 191 psS32 i = 0; 192 double tmp = 0.0; 193 194 return(CalcScaleFactorsFit(n)); 195 196 double *scalingFactors = (double *)psAlloc(n * sizeof(double)); 186 197 187 198 for (i = 0; i < n; i++) { 188 // scalingFactors[i] = ((2.0 * (float) i) 189 // / ((float) (n-1))) - 1.0; 190 tmp = (float)(n - i); 191 tmp = (M_PI * (tmp - 0.5)) / ((float)n); 199 tmp = (double)(n - i); 200 tmp = (M_PI * (tmp - 0.5)) / ((double)n); 192 201 scalingFactors[i] = cos(tmp); 193 202 } … … 249 258 psS32 i = 0; 250 259 psS32 j = 0; 251 float**sums = NULL;260 double **sums = NULL; 252 261 psPolynomial1D* *chebPolys = NULL; 253 262 psS32 maxChebyPoly = 0; 254 float*cScalingFactors = NULL;255 float*rScalingFactors = NULL;263 double *cScalingFactors = NULL; 264 double *rScalingFactors = NULL; 256 265 257 266 // Check for null inputs … … 275 284 // 29 in the ADD: sums[k][l] = SUM { 276 285 // image(x,y) * Tk(x) * Tl(y) } 277 sums = ( float **)psAlloc(coeffs->nX * sizeof(float*));286 sums = (double **)psAlloc(coeffs->nX * sizeof(double *)); 278 287 for (i = 0; i < coeffs->nX; i++) { 279 sums[i] = ( float *)psAlloc(coeffs->nY * sizeof(float));288 sums[i] = (double *)psAlloc(coeffs->nY * sizeof(double)); 280 289 } 281 290 // We scale the pixel positions to values 282 291 // between -1.0 and 1.0 283 rScalingFactors = p_psCalcScaleFactorsFit(input->numRows);284 cScalingFactors = p_psCalcScaleFactorsFit(input->numCols);292 rScalingFactors = CalcScaleFactors(input->numRows); 293 cScalingFactors = CalcScaleFactors(input->numCols); 285 294 286 295 // Determine how many Chebyshev polynomials … … 292 301 chebPolys = p_psCreateChebyshevPolys(maxChebyPoly); 293 302 294 295 /*296 // Sanity check for the Chebyshevs.297 for (i = 0; i < coeffs->nX; i++) {298 for (j = 0; j < coeffs->nY; j++) {299 tmp = 0.0;300 for (x = 0; x < input->numRows; x++) {301 tmp +=302 psPolynomial1DEval303 (rScalingFactors[x], chebPolys[i]) * psPolynomial1DEval(rScalingFactors[x], chebPolys[j]);304 305 }306 // printf("SUM(Cheby(%d) * Cheby(%d))307 // is %f\n", i, j, tmp);308 }309 }310 */311 303 312 304 // Compute the sums[][] data structure. … … 362 354 363 355 XXX: Currently we only support F32. 356 S8, U16, F32, F64 364 357 *****************************************************************************/ 365 358 psImage* psImageEvalPolynomial(psImage* input, const psPolynomial2D* coeffs) 366 359 { 360 PS_IMAGE_CHECK_NULL(input, NULL); 361 PS_IMAGE_CHECK_EMPTY(input, NULL); 362 if ((input->type.type != PS_TYPE_S8) && 363 (input->type.type != PS_TYPE_U16) && 364 (input->type.type != PS_TYPE_F32) && 365 (input->type.type != PS_TYPE_F64)) { 366 psError(__func__, "Unalowwable image type.\n"); 367 } 368 PS_POLY_CHECK_NULL(coeffs, NULL); 369 PS_POLY_CHECK_TYPE(coeffs, PS_POLYNOMIAL_CHEB, NULL); 370 367 371 psS32 x = 0; 368 372 psS32 y = 0; … … 372 376 psPolynomial1D* *chebPolys = NULL; 373 377 psS32 maxChebyPoly = 0; 374 float *cScalingFactors = NULL; 375 float *rScalingFactors = NULL; 376 float polySum = 0.0; 377 378 // Create the sums[][] data structure. This will hold the LHS of 379 // equation 29 in the ADD: 380 // sums[k][l] = SUM { image(x,y) * Tk(x) * Tl(y) } 381 // 382 // sums = (float **)psAlloc(coeffs->nX * sizeof(float *)); 383 // for (i = 0; i < coeffs->nX; i++) { 384 // sums[i] = (float *)psAlloc(coeffs->nY * sizeof(float)); 385 // } 386 // for (i = 0; i < coeffs->nX; i++) { 387 // for (j = 0; j < coeffs->nY; j++) { 388 // sums[i][j] = 0.0; 389 // } 390 // } 391 392 393 // Check for null inputs 394 if (input == NULL) { 395 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageEvalPolynomial", 396 PS_ERR_BAD_PARAMETER_NULL, true, 397 PS_ERRORTEXT_psImage_IMAGE_NULL); 398 return NULL; 399 } 400 401 if (coeffs == NULL) { 402 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageEvalPolynomial", 403 PS_ERR_BAD_PARAMETER_NULL, true, 404 PS_ERRORTEXT_psImage_COEFF_NULL); 405 return NULL; 406 } 378 double *cScalingFactors = NULL; 379 double *rScalingFactors = NULL; 380 double polySum = 0.0; 381 407 382 408 383 // We scale the pixel positions to values between -1.0 and 1.0 409 384 // Use static data structures here. 410 rScalingFactors = p_psCalcScaleFactorsEval(input->numRows);411 cScalingFactors = p_psCalcScaleFactorsEval(input->numCols);385 rScalingFactors = CalcScaleFactors(input->numRows); 386 cScalingFactors = CalcScaleFactors(input->numCols); 412 387 413 388 // Determine how many Chebyshev polynomials -
trunk/psLib/src/math/psConstants.h
r2230 r2261 6 6 * @author GLG, MHPCC 7 7 * 8 * @version $Revision: 1.3 1$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-1 0-28 23:03:11$8 * @version $Revision: 1.32 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-11-02 01:52:43 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 225 225 } \ 226 226 227 227 #define PS_POLY_CHECK_TYPE(NAME, TYPE, RVAL) \ 228 if (NAME->type != TYPE) { \ 229 psError(__func__,"Unallowable operation: polynomial %s has wrong type.", #NAME); \ 230 return(RVAL); \ 231 } \ 228 232 229 233 /*****************************************************************************
Note:
See TracChangeset
for help on using the changeset viewer.
