Changeset 2204 for trunk/psLib/test/image/tst_psImageFFT.c
- Timestamp:
- Oct 26, 2004, 2:57:34 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/test/image/tst_psImageFFT.c (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/image/tst_psImageFFT.c
r2078 r2204 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1.1 1$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-10- 13 19:50:12$8 * @version $Revision: 1.12 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-10-27 00:57:33 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 20 20 #define GENIMAGE(img,c,r,TYP, valueFcn) \ 21 21 img = psImageAlloc(c,r,PS_TYPE_##TYP); \ 22 for ( unsigned introw=0;row<r;row++) { \22 for (psU32 row=0;row<r;row++) { \ 23 23 ps##TYP* imgRow = img->data.TYP[row]; \ 24 for ( unsigned intcol=0;col<c;col++) { \24 for (psU32 col=0;col<c;col++) { \ 25 25 imgRow[col] = (ps##TYP)(valueFcn); \ 26 26 } \ 27 27 } 28 28 29 static inttestImageFFT(void);30 static inttestImageRealImaginary(void);31 static inttestImageComplex(void);32 static inttestImageConjugate(void);33 static inttestImagePowerSpectrum(void);29 static psS32 testImageFFT(void); 30 static psS32 testImageRealImaginary(void); 31 static psS32 testImageComplex(void); 32 static psS32 testImageConjugate(void); 33 static psS32 testImagePowerSpectrum(void); 34 34 35 35 testDescription tests[] = { … … 54 54 }; 55 55 56 int main(intargc, char* argv[])56 psS32 main(psS32 argc, char* argv[]) 57 57 { 58 58 psLogSetLevel(PS_LOG_INFO); … … 61 61 } 62 62 63 inttestImageFFT(void)63 psS32 testImageFFT(void) 64 64 { 65 65 psImage* img = NULL; 66 66 psImage* img2 = NULL; 67 67 psImage* img3 = NULL; 68 unsigned intm = 128;69 unsigned intn = 64;68 psU32 m = 128; 69 psU32 n = 64; 70 70 psImage* img4 = NULL; 71 71 psImage* img5 = NULL; … … 95 95 96 96 // 3. verify that the only significant component cooresponds to the freqency of the input in step 1. 97 for ( unsigned introw=0;row<n;row++) {97 for (psU32 row=0;row<n;row++) { 98 98 psC32* img2Row = img2->data.C32[row]; 99 for ( unsigned intcol=0;col<m;col++) {99 for (psU32 col=0;col<m;col++) { 100 100 psF32 mag = cabsf(img2Row[col])/m/n; 101 101 if (mag > 0.1f) { … … 130 130 } 131 131 132 for ( unsigned introw=0;row<n;row++) {132 for (psU32 row=0;row<n;row++) { 133 133 psC32* img3Row = img3->data.C32[row]; 134 134 psF32* imgRow = img->data.F32[row]; 135 for ( unsigned intcol=0;col<m;col++) {135 for (psU32 col=0;col<m;col++) { 136 136 psF32 pixel = creal(img3Row[col])/m/n; 137 137 if (fabsf(pixel-imgRow[col]) > 0.1) { … … 159 159 } 160 160 161 for ( unsigned introw=0;row<n;row++) {161 for (psU32 row=0;row<n;row++) { 162 162 psF32* img3Row = img3->data.F32[row]; 163 163 psF32* imgRow = img->data.F32[row]; 164 for ( unsigned intcol=0;col<m;col++) {164 for (psU32 col=0;col<m;col++) { 165 165 psF32 pixel = img3Row[col]/m/n; 166 166 if (fabsf(pixel-imgRow[col]) > 0.1) { … … 209 209 } 210 210 211 inttestImageRealImaginary(void)211 psS32 testImageRealImaginary(void) 212 212 { 213 213 psImage* img = NULL; 214 214 psImage* img2 = NULL; 215 215 psImage* img3 = NULL; 216 unsigned intm = 128;217 unsigned intn = 64;216 psU32 m = 128; 217 psU32 n = 64; 218 218 219 219 /* … … 250 250 251 251 // 3. compare results to the real/imaginary components of input 252 for ( unsigned introw=0;row<n;row++) {252 for (psU32 row=0;row<n;row++) { 253 253 psF32* img2Row = img2->data.F32[row]; 254 254 psF32* img3Row = img3->data.F32[row]; 255 for ( unsigned intcol=0;col<m;col++) {255 for (psU32 col=0;col<m;col++) { 256 256 if (fabsf(img2Row[col] - row) > FLT_EPSILON) { 257 257 psError(__func__,"psImageReal didn't return the real portion at n=%d", … … 274 274 } 275 275 276 inttestImageComplex(void)276 psS32 testImageComplex(void) 277 277 { 278 278 psImage* img = NULL; 279 279 psImage* img2 = NULL; 280 280 psImage* img3 = NULL; 281 unsigned intm = 128;282 unsigned intn = 64;281 psU32 m = 128; 282 psU32 n = 64; 283 283 284 284 /* … … 314 314 // 4. call psImageReal and psImageImaginary on step 2 results (not needed, just use crealf/cimagf) 315 315 // 5. compare step 4 results to input. 316 for ( unsigned introw=0;row<n;row++) {316 for (psU32 row=0;row<n;row++) { 317 317 psC32* img3Row = img3->data.C32[row]; 318 for ( unsigned intcol=0;col<m;col++) {318 for (psU32 col=0;col<m;col++) { 319 319 if (fabsf(crealf(img3Row[col]) - row) > FLT_EPSILON || 320 320 fabsf(cimagf(img3Row[col]) - col) > FLT_EPSILON) { … … 358 358 } 359 359 360 inttestImageConjugate(void)360 psS32 testImageConjugate(void) 361 361 { 362 362 psImage* img = NULL; 363 363 psImage* img2 = NULL; 364 unsigned intm = 128;365 unsigned intn = 64;364 psU32 m = 128; 365 psU32 n = 64; 366 366 367 367 /* … … 385 385 386 386 // 4. verify each value is conjugate of input (a+bi -> a-bi) 387 for ( unsigned introw=0;row<n;row++) {387 for (psU32 row=0;row<n;row++) { 388 388 psC32* img2Row = img2->data.C32[row]; 389 for ( unsigned intcol=0;col<m;col++) {389 for (psU32 col=0;col<m;col++) { 390 390 if (fabsf(crealf(img2Row[col]) - row) > FLT_EPSILON || 391 391 fabsf(cimagf(img2Row[col]) + col) > FLT_EPSILON) { … … 403 403 } 404 404 405 inttestImagePowerSpectrum(void)405 psS32 testImagePowerSpectrum(void) 406 406 { 407 407 psImage* img = NULL; 408 408 psImage* img2 = NULL; 409 unsigned intm = 128;410 unsigned intn = 64;409 psU32 m = 128; 410 psU32 n = 64; 411 411 412 412 /* … … 430 430 431 431 // 4. verify the values are the square of the absolute values of the original 432 for ( unsigned introw=0;row<n;row++) {432 for (psU32 row=0;row<n;row++) { 433 433 psC32* imgRow = img->data.C32[row]; 434 434 psF32* img2Row = img2->data.F32[row]; 435 for ( unsigned intcol=0;col<m;col++) {435 for (psU32 col=0;col<m;col++) { 436 436 psF32 power = cabs(imgRow[col]); 437 437 power *= power/n/n/m/m;
Note:
See TracChangeset
for help on using the changeset viewer.
