Changeset 2204 for trunk/psLib/test/image/tst_psImageConvolve.c
- Timestamp:
- Oct 26, 2004, 2:57:34 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/test/image/tst_psImageConvolve.c (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/image/tst_psImageConvolve.c
r2068 r2204 5 5 * @author Robert DeSonia, MHPCC 6 6 * 7 * @version $Revision: 1. 5$ $Name: not supported by cvs2svn $8 * @date $Date: 2004-10- 13 01:22:38$7 * @version $Revision: 1.6 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2004-10-27 00:57:33 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 20 20 #include "psType.h" 21 21 22 static inttestKernelAlloc(void);23 static inttestKernelGenerate(void);24 //static inttestImageConvolve(void);22 static psS32 testKernelAlloc(void); 23 static psS32 testKernelGenerate(void); 24 //static psS32 testImageConvolve(void); 25 25 26 26 testDescription tests[] = { … … 31 31 }; 32 32 33 int main(intargc, char* argv[])33 psS32 main(psS32 argc, char* argv[]) 34 34 { 35 35 psLogSetLevel(PS_LOG_INFO); … … 38 38 } 39 39 40 static inttestKernelAlloc(void)40 static psS32 testKernelAlloc(void) 41 41 { 42 intnumCases = 4;43 intxMin[] = { -5, 0,-10, 5};44 intxMax[] = { 0, 5, -5, 10};45 intyMin[] = { -4, 0, -8, 4};46 intyMax[] = { 0, 4, -4, 8};47 inti;42 psS32 numCases = 4; 43 psS32 xMin[] = { -5, 0,-10, 5}; 44 psS32 xMax[] = { 0, 5, -5, 10}; 45 psS32 yMin[] = { -4, 0, -8, 4}; 46 psS32 yMax[] = { 0, 4, -4, 8}; 47 psS32 i; 48 48 psKernel* k; 49 49 … … 73 73 } 74 74 75 for ( intj=yMin[i]; j<yMax[i]; j++) {75 for (psS32 j=yMin[i]; j<yMax[i]; j++) { 76 76 if (k->kernel[j]+xMin[i] != k->image->data.PS_TYPE_KERNEL_DATA[j-yMin[i]]) { 77 77 psError(__func__,"The kernel pointer was set wrong for row %d.", … … 115 115 } 116 116 117 static inttestKernelGenerate(void)117 static psS32 testKernelGenerate(void) 118 118 { 119 intsize = 4;120 intt[] = { 1, 2, 8, 10 };121 intx[] = { 0, 1, 0, -1 };122 inty[] = { 2, 1, -1, -2 };119 psS32 size = 4; 120 psS32 t[] = { 1, 2, 8, 10 }; 121 psS32 x[] = { 0, 1, 0, -1 }; 122 psS32 y[] = { 2, 1, -1, -2 }; 123 123 psKernelType sum; 124 124 … … 127 127 psVector* tVec = psVectorAlloc(size,PS_TYPE_U32); 128 128 129 for ( inti = 0; i < size; i++) {129 for (psS32 i = 0; i < size; i++) { 130 130 xVec->data.U32[i] = x[i]; 131 131 yVec->data.U32[i] = y[i]; … … 148 148 149 149 sum = 0.0; 150 for ( inty = result->yMin; y <= result->yMax; y++) {151 for ( intx = result->xMin; x <= result->xMax; x++) {150 for (psS32 y = result->yMin; y <= result->yMax; y++) { 151 for (psS32 x = result->xMin; x <= result->xMax; x++) { 152 152 sum += result->kernel[y][x]; 153 153 } … … 182 182 tVec = psVectorAlloc(size,PS_TYPE_S16); 183 183 184 for ( inti = 0; i < size; i++) {184 for (psS32 i = 0; i < size; i++) { 185 185 xVec->data.S16[i] = x[i]; 186 186 yVec->data.S16[i] = y[i]; … … 203 203 204 204 sum = 0.0; 205 for ( inty = result->yMin; y <= result->yMax; y++) {206 for ( intx = result->xMin; x <= result->xMax; x++) {205 for (psS32 y = result->yMin; y <= result->yMax; y++) { 206 for (psS32 x = result->xMin; x <= result->xMax; x++) { 207 207 sum += result->kernel[y][x]; 208 208 } … … 236 236 tVec = psVectorAlloc(size,PS_TYPE_F32); 237 237 238 for ( inti = 0; i < size; i++) {238 for (psS32 i = 0; i < size; i++) { 239 239 xVec->data.F32[i] = x[i]+0.1; 240 240 yVec->data.F32[i] = y[i]+0.2; … … 291 291 292 292 /* 293 static inttestImageConvolve(void)293 static psS32 testImageConvolve(void) 294 294 { 295 const intr = 200;296 const intc = 300;297 intsum;295 const psS32 r = 200; 296 const psS32 c = 300; 297 psS32 sum; 298 298 299 299 // approximate a normalized gaussian kernel. … … 312 312 psKernel* nsk = psKernelAlloc(0,2,0,2); 313 313 sum = 0.0; 314 for ( inti=0;i<2;i++) {315 for ( intj=0;j<2;j++) {314 for (psS32 i=0;i<2;i++) { 315 for (psS32 j=0;j<2;j++) { 316 316 nsk->kernel[i][j] = i+j; 317 317 sum = i+j; 318 318 } 319 319 } 320 for ( inti=0;i<2;i++) {321 for ( intj=0;j<2;j++) {320 for (psS32 i=0;i<2;i++) { 321 for (psS32 j=0;j<2;j++) { 322 322 nsk->kernel[i][j] /= sum; 323 323 } … … 356 356 357 357 // test values 358 for ( inti=-1;i<1;i++) {359 for ( intj=-1;j<1;j++) {358 for (psS32 i=-1;i<1;i++) { 359 for (psS32 j=-1;j<1;j++) { 360 360 if (fabsf(out->data.F32[r/2+i][c/2+j] - g->kernel[i][j]) > 0.0001) { 361 361 psError(__func__,"Convolved image wrong at %d,%d. Value is %g, expected %g.", … … 423 423 psImageWriteSection(out2,0,0,0,NULL,0,"out2.fits"); 424 424 // test values 425 for ( inti=-1;i<1;i++) {426 for ( intj=-1;j<1;j++) {425 for (psS32 i=-1;i<1;i++) { 426 for (psS32 j=-1;j<1;j++) { 427 427 if (fabsf(out->data.F32[r/2+i][c/2+j] - g->kernel[i][j]) > 0.0001) { 428 428 psError(__func__,"Convolved image wrong at %d,%d. Value is %g, expected %g.",
Note:
See TracChangeset
for help on using the changeset viewer.
