Changeset 1984
- Timestamp:
- Oct 6, 2004, 11:40:13 AM (22 years ago)
- Location:
- trunk/psLib
- Files:
-
- 10 edited
-
psLib.kdevelop.filelist (modified) (1 diff)
-
psLib.kdevelop.pcs (modified) ( previous)
-
psLib.kdevses (modified) (1 diff)
-
src/dataManip/psVectorFFT.h (modified) (2 diffs)
-
src/fft/psVectorFFT.h (modified) (2 diffs)
-
src/sys/psType.h (modified) (2 diffs)
-
src/sysUtils/psType.h (modified) (2 diffs)
-
test/dataManip/verified/tst_psMinimize04.stderr (modified) (1 diff)
-
test/image/tst_psImageConvolve.c (modified) (3 diffs)
-
test/image/tst_psImageFFT.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/psLib.kdevelop.filelist
r1866 r1984 447 447 CVS/Repository 448 448 CVS/Root 449 test/image/tst_psImageConvolve.c -
trunk/psLib/psLib.kdevses
r1929 r1984 3 3 <KDevPrjSession> 4 4 <DocsAndViews NumberOfDocuments="6" > 5 <Doc0 NumberOfViews="1" URL="file:/home/desonia/psLib/src/image/psImage Extraction.h" >6 <View0 line=" 0" Type="???" >7 <AdditionalSettings Top=" 1" Width="1138" Attach="1" Height="702" Left="1" MinMaxMode="0" />5 <Doc0 NumberOfViews="1" URL="file:/home/desonia/psLib/src/image/psImageConvolve.c" > 6 <View0 line="412" Type="???" > 7 <AdditionalSettings Top="2" Width="1181" Attach="1" Height="701" Left="2" MinMaxMode="0" /> 8 8 </View0> 9 9 </Doc0> 10 <Doc1 NumberOfViews="1" URL="file:/home/desonia/psLib/src/image/psImage Extraction.c" >11 <View0 line=" 151" Type="???" >12 <AdditionalSettings Top=" 1" Width="1530" Attach="1" Height="998" Left="1" MinMaxMode="0" />10 <Doc1 NumberOfViews="1" URL="file:/home/desonia/psLib/src/image/psImageFFT.c" > 11 <View0 line="36" Type="???" > 12 <AdditionalSettings Top="2" Width="1181" Attach="1" Height="701" Left="2" MinMaxMode="0" /> 13 13 </View0> 14 14 </Doc1> 15 <Doc2 NumberOfViews="1" URL="file:/home/desonia/psLib/ test/image/tst_psImageExtraction.c" >16 <View0 line=" 523" Type="???" >17 <AdditionalSettings Top=" 1" Width="1138" Attach="1" Height="675" Left="1" MinMaxMode="0" />15 <Doc2 NumberOfViews="1" URL="file:/home/desonia/psLib/src/dataManip/psVectorFFT.h" > 16 <View0 line="31" Type="???" > 17 <AdditionalSettings Top="2" Width="1181" Attach="1" Height="701" Left="2" MinMaxMode="0" /> 18 18 </View0> 19 19 </Doc2> 20 <Doc3 NumberOfViews="1" URL="file:/home/desonia/psLib/ test/image/tst_psImageManip.c" >21 <View0 line="4 5" Type="???" >22 <AdditionalSettings Top=" 1" Width="1138" Attach="1" Height="675" Left="1" MinMaxMode="0" />20 <Doc3 NumberOfViews="1" URL="file:/home/desonia/psLib/src/image/psImageErrors.dat" > 21 <View0 line="44" Type="???" > 22 <AdditionalSettings Top="2" Width="1181" Attach="1" Height="701" Left="2" MinMaxMode="0" /> 23 23 </View0> 24 24 </Doc3> 25 <Doc4 NumberOfViews="1" URL="file:/home/desonia/psLib/test/image/tst_psImage .c" >26 <View0 line=" 23" Type="???" >27 <AdditionalSettings Top=" 1" Width="1138" Attach="1" Height="675" Left="1" MinMaxMode="0" />25 <Doc4 NumberOfViews="1" URL="file:/home/desonia/psLib/test/image/tst_psImageConvolve.c" > 26 <View0 line="386" Type="???" > 27 <AdditionalSettings Top="2" Width="1181" Attach="1" Height="701" Left="2" MinMaxMode="0" /> 28 28 </View0> 29 29 </Doc4> 30 <Doc5 NumberOfViews="1" URL="file:/home/desonia/psLib/src/ image/psImageErrors.dat" >31 <View0 line=" 15" Type="???" >32 <AdditionalSettings Top=" 1" Width="1532" Attach="1" Height="991" Left="1" MinMaxMode="0" />30 <Doc5 NumberOfViews="1" URL="file:/home/desonia/psLib/src/collections/psVector.c" > 31 <View0 line="86" Type="???" > 32 <AdditionalSettings Top="2" Width="1181" Attach="1" Height="701" Left="2" MinMaxMode="0" /> 33 33 </View0> 34 34 </Doc5> -
trunk/psLib/src/dataManip/psVectorFFT.h
r1625 r1984 7 7 * @author Robert DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1.1 4$ $Name: not supported by cvs2svn $10 * @date $Date: 2004- 08-25 21:10:08$9 * @version $Revision: 1.15 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-10-06 21:40:13 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 24 24 typedef enum { 25 25 /// psImageFFT/psVectorFFT should perform a forward FFT. 26 PS_FFT_FORWARD = (-1),26 PS_FFT_FORWARD = 1, 27 27 28 28 /// psImageFFT/psVectorFFT should perform a reverse FFT. 29 PS_FFT_REVERSE = (+1) 29 PS_FFT_REVERSE = 2, 30 31 /// psImageFFT/psVectorFFT should perform a reverse FFT with a real result. 32 PS_FFT_REAL_RESULT = 4 30 33 } psFftDirection; 31 34 -
trunk/psLib/src/fft/psVectorFFT.h
r1625 r1984 7 7 * @author Robert DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1.1 4$ $Name: not supported by cvs2svn $10 * @date $Date: 2004- 08-25 21:10:08$9 * @version $Revision: 1.15 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-10-06 21:40:13 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 24 24 typedef enum { 25 25 /// psImageFFT/psVectorFFT should perform a forward FFT. 26 PS_FFT_FORWARD = (-1),26 PS_FFT_FORWARD = 1, 27 27 28 28 /// psImageFFT/psVectorFFT should perform a reverse FFT. 29 PS_FFT_REVERSE = (+1) 29 PS_FFT_REVERSE = 2, 30 31 /// psImageFFT/psVectorFFT should perform a reverse FFT with a real result. 32 PS_FFT_REAL_RESULT = 4 30 33 } psFftDirection; 31 34 -
trunk/psLib/src/sys/psType.h
r1840 r1984 11 11 * @author Ross Harman, MHPCC 12 12 * 13 * @version $Revision: 1.2 1$ $Name: not supported by cvs2svn $14 * @date $Date: 2004- 09-21 22:30:19$13 * @version $Revision: 1.22 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2004-10-06 21:40:13 $ 15 15 * 16 16 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 50 50 typedef float psF32; ///< 32-bit floating point 51 51 typedef double psF64; ///< 64-bit floating point 52 typedef complex float psC32;///< complex with 32-bit floating point Real and Imagary numbers53 typedef complex double psC64;///< complex with 64-bit floating point Real and Imagary numbers52 typedef float _Complex psC32; ///< complex with 32-bit floating point Real and Imagary numbers 53 typedef double _Complex psC64; ///< complex with 64-bit floating point Real and Imagary numbers 54 54 typedef void *psPTR; ///< void pointer 55 55 -
trunk/psLib/src/sysUtils/psType.h
r1840 r1984 11 11 * @author Ross Harman, MHPCC 12 12 * 13 * @version $Revision: 1.2 1$ $Name: not supported by cvs2svn $14 * @date $Date: 2004- 09-21 22:30:19$13 * @version $Revision: 1.22 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2004-10-06 21:40:13 $ 15 15 * 16 16 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 50 50 typedef float psF32; ///< 32-bit floating point 51 51 typedef double psF64; ///< 64-bit floating point 52 typedef complex float psC32;///< complex with 32-bit floating point Real and Imagary numbers53 typedef complex double psC64;///< complex with 64-bit floating point Real and Imagary numbers52 typedef float _Complex psC32; ///< complex with 32-bit floating point Real and Imagary numbers 53 typedef double _Complex psC64; ///< complex with 64-bit floating point Real and Imagary numbers 54 54 typedef void *psPTR; ///< void pointer 55 55 -
trunk/psLib/test/dataManip/verified/tst_psMinimize04.stderr
r1976 r1984 2 2 Following should generate an error for null input polynomial. 3 3 <DATE><TIME>|<HOST>|E|psVectorFitPolynomial1D 4 Invalidoperation: myPoly or its coeffs is NULL.4 Unallowable operation: myPoly or its coeffs is NULL. -
trunk/psLib/test/image/tst_psImageConvolve.c
r1940 r1984 5 5 * @author Robert DeSonia, MHPCC 6 6 * 7 * @version $Revision: 1. 3$ $Name: not supported by cvs2svn $8 * @date $Date: 2004-10-0 1 20:58:32$7 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2004-10-06 21:40:13 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 22 22 static int testKernelAlloc(void); 23 23 static int testKernelGenerate(void); 24 static int testImageConvolve(void); 24 25 25 26 testDescription tests[] = { 26 27 {testKernelAlloc,731,"psKernelAlloc",0,false}, 27 28 {testKernelGenerate,732,"psKernelGenerate",0,false}, 29 {testImageConvolve,733,"psImageConvolve",0,false}, 28 30 {NULL} 29 31 }; … … 287 289 return 0; 288 290 } 291 292 static int testImageConvolve(void) 293 { 294 const int r = 200; 295 const int c = 300; 296 int sum; 297 298 // approximate a normalized gaussian kernel. 299 psKernel* g = psKernelAlloc(-1,1,-1,1); 300 g->kernel[-1][-1] = 301 g->kernel[-1][1] = 302 g->kernel[1][-1] = 303 g->kernel[1][1] = 0.0113; 304 g->kernel[1][0] = 305 g->kernel[-1][0] = 306 g->kernel[0][-1] = 307 g->kernel[0][1] = 0.0838; 308 g->kernel[0][0] = 0.6193; 309 310 // create a normalized non-symetric kernel. 311 psKernel* nsk = psKernelAlloc(0,2,0,2); 312 sum = 0.0; 313 for (int i=0;i<2;i++) { 314 for (int j=0;j<2;j++) { 315 nsk->kernel[i][j] = i+j; 316 sum = i+j; 317 } 318 } 319 for (int i=0;i<2;i++) { 320 for (int j=0;j<2;j++) { 321 nsk->kernel[i][j] /= sum; 322 } 323 } 324 325 326 psImage* img = psImageAlloc(c,r,PS_TYPE_F32); 327 memset(img->data.F32[0],0,c*r*PSELEMTYPE_SIZEOF(PS_TYPE_F32)); 328 img->data.F32[0][0] = 1.0f; 329 img->data.F32[r/2][c/2] = 1.0f; 330 img->data.F32[r-1][c/2] = 1.0f; 331 332 // test spacial convolution of gaussian 333 psLogMsg(__func__,PS_LOG_INFO,"Testing direct gaussian convolution"); 334 psImage* out = psImageConvolve(NULL, img, g, true); 335 336 if (out == NULL) { 337 psError(__func__, "psImageConvolve returned a NULL for direct gaussian case."); 338 return 1; 339 } 340 341 if (out->numCols != c || out->numRows != r) { 342 psError(__func__, "psImageConvolve result image is %dx%d, but expected %dx%d.", 343 out->numCols, out->numRows, 344 c,r); 345 return 2; 346 } 347 348 if (out->type.type != PS_TYPE_F32) { 349 char* typeStr; 350 PS_TYPE_NAME(typeStr,out->type.type); 351 psError(__func__, "psImageConvolve result image is of type %s, not psF32.", 352 typeStr); 353 return 3; 354 } 355 356 // test values 357 for (int i=-1;i<1;i++) { 358 for (int j=-1;j<1;j++) { 359 if (fabsf(out->data.F32[r/2+i][c/2+j] - g->kernel[i][j]) > 0.0001) { 360 psError(__func__,"Convolved image wrong at %d,%d. Value is %g, expected %g.", 361 c/2+j,r/2+i, 362 out->data.F32[r/2+i][c/2+j], g->kernel[i][j]); 363 return 4; 364 } 365 if (i >= 0 && j >= 0 && fabsf(out->data.F32[i][j] - g->kernel[i][j]) > 0.0001) { 366 psError(__func__,"Convolved image wrong at %d,%d. Value is %g, expected %g.", 367 j,i, 368 out->data.F32[i][j], g->kernel[i][j]); 369 return 5; 370 } 371 if (i <= 0 && fabsf(out->data.F32[r-1+i][c/2+j] - g->kernel[i][j]) > 0.0001) { 372 psError(__func__,"Convolved image wrong at %d,%d. Value is %g, expected %g.", 373 c/2+j,r-1+i, 374 out->data.F32[r-1+i][c/2+j], g->kernel[i][j]); 375 return 6; 376 } 377 } 378 } 379 380 // test fourier convolution of gaussian 381 psLogMsg(__func__,PS_LOG_INFO,"Testing fourier gaussian convolution"); 382 psKernel* gg = psKernelAlloc(1,3,1,3); 383 gg->kernel[1][1] = 384 gg->kernel[1][3] = 385 gg->kernel[3][1] = 386 gg->kernel[3][3] = 0.0113; 387 gg->kernel[3][2] = 388 gg->kernel[1][2] = 389 gg->kernel[2][1] = 390 gg->kernel[2][3] = 0.0838; 391 gg->kernel[2][2] = 0.6193; 392 img->data.F32[0][0] = 0.0f; 393 img->data.F32[r/2][c/2] = 1.0f; 394 img->data.F32[r-1][c/2] = 0.0f; 395 psImage* out2 = psImageConvolve(out, img, gg, false); 396 397 if (out == NULL) { 398 psError(__func__, "psImageConvolve returned a NULL for gaussian case."); 399 return 10; 400 } 401 402 if (out != out2) { 403 psError(__func__, "psImageConvolve didn't recycle the supplied out image struct."); 404 return 11; 405 } 406 407 if (out->numCols != c || out->numRows != r) { 408 psError(__func__, "psImageConvolve result image is %dx%d, but expected %dx%d.", 409 out->numCols, out->numRows, 410 c,r); 411 return 12; 412 } 413 414 if (out->type.type != PS_TYPE_F32) { 415 char* typeStr; 416 PS_TYPE_NAME(typeStr,out->type.type); 417 psError(__func__, "psImageConvolve result image is of type %s, not psF32.", 418 typeStr); 419 return 13; 420 } 421 422 psImageWriteSection(out2,0,0,0,NULL,0,"out2.fits"); 423 // test values 424 for (int i=-1;i<1;i++) { 425 for (int j=-1;j<1;j++) { 426 if (fabsf(out->data.F32[r/2+i][c/2+j] - g->kernel[i][j]) > 0.0001) { 427 psError(__func__,"Convolved image wrong at %d,%d. Value is %g, expected %g.", 428 c/2+j,r/2+i, 429 out->data.F32[r/2+i][c/2+j], g->kernel[i][j]); 430 psImageWriteSection(out,0,0,0,NULL,0,"problem.fits"); 431 return 14; 432 } 433 if (i >= 0 && j >= 0 && fabsf(out->data.F32[i][j] - g->kernel[i][j]) > 0.0001) { 434 psError(__func__,"Convolved image wrong at %d,%d. Value is %g, expected %g.", 435 j,i, 436 out->data.F32[i][j], g->kernel[i][j]); 437 return 15; 438 } 439 if (i <= 0 && fabsf(out->data.F32[r-1+i][c/2+j] - g->kernel[i][j]) > 0.0001) { 440 psError(__func__,"Convolved image wrong at %d,%d. Value is %g, expected %g.", 441 c/2+j,r-1+i, 442 out->data.F32[r-1+i][c/2+j], g->kernel[i][j]); 443 return 16; 444 } 445 } 446 } 447 448 psFree(g); 449 psFree(img); 450 psFree(nsk); 451 psFree(out); 452 return 0; 453 } -
trunk/psLib/test/image/tst_psImageFFT.c
r1979 r1984 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1. 9$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-10-06 19:36:30$8 * @version $Revision: 1.10 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-10-06 21:40:13 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 88 88 return 1; 89 89 } 90 if (img2->numCols != m || img2->numRows != n) { 91 psError(__func__,"FFT didn't produce proper size result (%dx%d vs. expected %dx%d).", 92 img2->numCols,img2->numRows,m,n); 93 return 2; 94 } 90 95 91 96 // 3. verify that the only significant component cooresponds to the freqency of the input in step 1. … … 99 104 && ! (row == 0 && (col==1 || col == n-1)) ) { 100 105 psError(__func__,"Result invalid at %d,%d (%.2f)",col,row,mag); 106 return 3; 101 107 } 102 108 } else … … 104 110 || (row == 0 && (col==1 || col == n-1)) ) { 105 111 psError(__func__,"Result invalid at %d,%d (%.2f)",col,row,mag); 112 return 4; 106 113 } 107 114 } … … 114 121 if (img3->type.type != PS_TYPE_C32) { 115 122 psError(__func__,"FFT didn't produce complex values?"); 116 return 4; 123 return 5; 124 } 125 126 if (img3->numCols != m || img3->numRows != n) { 127 psError(__func__,"FFT didn't produce proper size result (%dx%d vs. expected %dx%d).", 128 img3->numCols,img3->numRows,m,n); 129 return 6; 117 130 } 118 131 … … 125 138 psError(__func__,"Reverse FFT didn't give original image back (%d,%d %.2f vs %.2f)", 126 139 col,row,pixel,imgRow[col]); 127 return 5; 128 } 129 } 140 return 7; 141 } 142 } 143 } 144 145 // 4. perform a reverse transform to real result 146 img3 = psImageFFT(img3,img2,PS_FFT_REVERSE|PS_FFT_REAL_RESULT); 147 148 if (img3->type.type != PS_TYPE_F32) { 149 char* typeStr; 150 PS_TYPE_NAME(typeStr,img3->type.type) 151 psError(__func__,"FFT asked to make real result, but I got a %s type image?",typeStr); 152 return 8; 153 } 154 155 if (img3->numCols != m || img3->numRows != n) { 156 psError(__func__,"FFT didn't produce proper size result (%dx%d vs. expected %dx%d).", 157 img3->numCols,img3->numRows,m,n); 158 return 9; 159 } 160 161 for (unsigned int row=0;row<n;row++) { 162 psF32* img3Row = img3->data.F32[row]; 163 psF32* imgRow = img->data.F32[row]; 164 for (unsigned int col=0;col<m;col++) { 165 psF32 pixel = img3Row[col]/m/n; 166 if (fabsf(pixel-imgRow[col]) > 0.1) { 167 psError(__func__,"Reverse FFT didn't give original image back (%d,%d %.2f vs %.2f)", 168 col,row,pixel,imgRow[col]); 169 return 10; 170 } 171 } 172 } 173 174 // check if error occurs if FORWARD and REVERSE are both given. 175 psLogMsg(__func__,PS_LOG_INFO,"Following should be an error."); 176 if (psImageFFT(NULL,img2,PS_FFT_REVERSE|PS_FFT_FORWARD) != NULL) { 177 psError(__func__,"PS_FFT_REVERSE|PS_FFT_FORWARD option produced something?"); 178 return 11; 179 } 180 181 psLogMsg(__func__,PS_LOG_INFO,"Following should be an error."); 182 if (psImageFFT(NULL,img2,PS_FFT_FORWARD|PS_FFT_REAL_RESULT) != NULL) { 183 psError(__func__,"PS_FFT_FORWARD|PS_FFT_REAL_RESULT option produced something?"); 184 return 12; 130 185 } 131 186
Note:
See TracChangeset
for help on using the changeset viewer.
