Changeset 2204 for trunk/psLib/test/image
- Timestamp:
- Oct 26, 2004, 2:57:34 PM (22 years ago)
- Location:
- trunk/psLib/test/image
- Files:
-
- 12 edited
-
tst_psImage.c (modified) (15 diffs)
-
tst_psImageConvolve.c (modified) (15 diffs)
-
tst_psImageExtraction.c (modified) (23 diffs)
-
tst_psImageFFT.c (modified) (15 diffs)
-
tst_psImageIO.c (modified) (8 diffs)
-
tst_psImageManip.c (modified) (46 diffs)
-
tst_psImageStats00.c (modified) (2 diffs)
-
tst_psImageStats01.c (modified) (2 diffs)
-
tst_psImageStats02.c (modified) (2 diffs)
-
tst_psImageStats03.c (modified) (1 diff)
-
verified/fOut.fits (modified) ( previous)
-
verified/sOut.fits (modified) ( previous)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/image/tst_psImage.c
r1929 r2204 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1.2 7$ $Name: not supported by cvs2svn $9 * @date $Date: 2004- 09-29 20:17:58$8 * @version $Revision: 1.28 $ $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 … … 21 21 #include "psType.h" 22 22 23 static inttestImageAlloc(void);24 static inttestImageCopy(void);23 static psS32 testImageAlloc(void); 24 static psS32 testImageCopy(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 inttestImageAlloc(void)40 psS32 testImageAlloc(void) 41 41 { 42 42 psImage* image = NULL; 43 unsigned intsizes = 6;44 unsigned intnumCols[] = {45 0,1,1,100,100,15046 };47 unsigned intnumRows[] = {48 0,1,100,1,150,10049 };50 unsigned inttypes = 13;43 psU32 sizes = 6; 44 psU32 numCols[] = { 45 0,1,1,100,100,150 46 }; 47 psU32 numRows[] = { 48 0,1,100,1,150,100 49 }; 50 psU32 types = 13; 51 51 psElemType type[] = { PS_TYPE_S8, PS_TYPE_S16, PS_TYPE_S32, PS_TYPE_S64, 52 52 PS_TYPE_U8, PS_TYPE_U16, PS_TYPE_U32, PS_TYPE_U64, … … 56 56 psLogMsg(__func__,PS_LOG_INFO,"#546 - psImageAlloc shall allocate memory for a psImage structure"); 57 57 58 for ( unsigned intt=0;t<types;t++) {58 for (psU32 t=0;t<types;t++) { 59 59 psLogMsg(__func__,PS_LOG_INFO,"Testing psImage with type %xh",type[t]); 60 60 61 for ( unsigned inti=0;i<sizes;i++) {61 for (psU32 i=0;i<sizes;i++) { 62 62 63 63 if (numRows[i] == 0 || numCols[i] == 0) { … … 112 112 switch (type[t]) { 113 113 case PS_TYPE_U16: { 114 unsigned introws = numRows[i];115 unsigned intcols = numCols[i];116 117 for ( intr=0;r<rows;r++) {118 for ( intc=0;c<cols;c++) {114 psU32 rows = numRows[i]; 115 psU32 cols = numCols[i]; 116 117 for (psS32 r=0;r<rows;r++) { 118 for (psS32 c=0;c<cols;c++) { 119 119 image->data.U16[r][c] = 2*c+r; 120 120 } 121 121 } 122 for ( intr=0;r<rows;r++) {123 for ( intc=0;c<cols;c++) {122 for (psS32 r=0;r<rows;r++) { 123 for (psS32 c=0;c<cols;c++) { 124 124 if (image->data.U16[r][c] != 2*c+r) { 125 125 psError(__func__,"Could not set all pixels in uint16 image at (%d,%d)",c,r); … … 132 132 break; 133 133 case PS_TYPE_F32: { 134 unsigned introws = numRows[i];135 unsigned intcols = numCols[i];136 137 for ( intr=0;r<rows;r++) {138 for ( intc=0;c<cols;c++) {134 psU32 rows = numRows[i]; 135 psU32 cols = numCols[i]; 136 137 for (psS32 r=0;r<rows;r++) { 138 for (psS32 c=0;c<cols;c++) { 139 139 image->data.F32[r][c] = 2.0f*c+r; 140 140 } 141 141 } 142 for ( intr=0;r<rows;r++) {143 for ( intc=0;c<cols;c++) {142 for (psS32 r=0;r<rows;r++) { 143 for (psS32 c=0;c<cols;c++) { 144 144 if (fabsf(image->data.F32[r][c] - (2.0f*c+r)) > FLT_EPSILON) { 145 145 psError(__func__,"Could not set all pixels in float image at (%d,%d)",c,r); … … 152 152 break; 153 153 case PS_TYPE_F64: { 154 unsigned introws = numRows[i];155 unsigned intcols = numCols[i];156 157 for ( intr=0;r<rows;r++) {158 for ( intc=0;c<cols;c++) {154 psU32 rows = numRows[i]; 155 psU32 cols = numCols[i]; 156 157 for (psS32 r=0;r<rows;r++) { 158 for (psS32 c=0;c<cols;c++) { 159 159 image->data.F64[r][c] = 2.0f*c+r; 160 160 } 161 161 } 162 for ( intr=0;r<rows;r++) {163 for ( intc=0;c<cols;c++) {162 for (psS32 r=0;r<rows;r++) { 163 for (psS32 c=0;c<cols;c++) { 164 164 if (fabs(image->data.F64[r][c] - (2.0f*c+r)) > DBL_EPSILON) { 165 165 psError(__func__,"Could not set all pixels in double image at (%d,%d)",c,r); … … 172 172 break; 173 173 case PS_TYPE_C32: { 174 unsigned introws = numRows[i];175 unsigned intcols = numCols[i];176 177 for ( intr=0;r<rows;r++) {178 for ( intc=0;c<cols;c++) {174 psU32 rows = numRows[i]; 175 psU32 cols = numCols[i]; 176 177 for (psS32 r=0;r<rows;r++) { 178 for (psS32 c=0;c<cols;c++) { 179 179 image->data.C32[r][c] = r + I * c; 180 180 } 181 181 } 182 for ( intr=0;r<rows;r++) {183 for ( intc=0;c<cols;c++) {182 for (psS32 r=0;r<rows;r++) { 183 for (psS32 c=0;c<cols;c++) { 184 184 if (fabsf(crealf(image->data.C32[r][c]) - r) > FLT_EPSILON || 185 185 fabsf(cimagf(image->data.C32[r][c]) - c) > FLT_EPSILON ) { … … 193 193 break; 194 194 case PS_TYPE_PTR: { 195 unsigned introws = numRows[i];196 unsigned intcols = numCols[i];195 psU32 rows = numRows[i]; 196 psU32 cols = numCols[i]; 197 197 psImage* temp = psImageAlloc(1,1,PS_TYPE_F32); 198 198 199 for ( intr=0;r<rows;r++) {200 for ( intc=0;c<cols;c++) {199 for (psS32 r=0;r<rows;r++) { 200 for (psS32 c=0;c<cols;c++) { 201 201 image->data.PTR[r][c] = psMemIncrRefCounter(temp); 202 202 } 203 203 } 204 for ( intr=0;r<rows;r++) {205 for ( intc=0;c<cols;c++) {204 for (psS32 r=0;r<rows;r++) { 205 for (psS32 c=0;c<cols;c++) { 206 206 if (image->data.PTR[r][c] != temp) { 207 207 psError(__func__, "Could not set pixel in pointer image at (%d,%d): %x %x", … … 218 218 default: { 219 219 // ignore type and just use as byte bucket. 220 unsigned introws = numRows[i];221 unsigned intcols = numCols[i]*PSELEMTYPE_SIZEOF(type[t]);222 223 for ( intr=0;r<rows;r++) {224 for ( intc=0;c<cols;c++) {220 psU32 rows = numRows[i]; 221 psU32 cols = numCols[i]*PSELEMTYPE_SIZEOF(type[t]); 222 223 for (psS32 r=0;r<rows;r++) { 224 for (psS32 c=0;c<cols;c++) { 225 225 image->data.U8[r][c] = (uint8_t)(r + c); 226 226 } 227 227 } 228 for ( intr=0;r<rows;r++) {229 for ( intc=0;c<cols;c++) {228 for (psS32 r=0;r<rows;r++) { 229 for (psS32 c=0;c<cols;c++) { 230 230 if (image->data.U8[r][c] != (uint8_t)(r + c)) { 231 231 psError(__func__,"Could not set all pixels in image (type=%d) at (%d,%d)", … … 253 253 } 254 254 255 inttestImageCopy(void)255 psS32 testImageCopy(void) 256 256 { 257 257 psImage* img = NULL; … … 259 259 psImage* img3 = NULL; 260 260 psImage* img4 = NULL; 261 unsigned intc = 128;262 unsigned intr = 256;261 psU32 c = 128; 262 psU32 r = 256; 263 263 264 264 img = psImageAlloc(c,r,PS_TYPE_F32); … … 296 296 return 4; 297 297 } 298 for ( unsigned introw=0;row<r;row++) {298 for (psU32 row=0;row<r;row++) { 299 299 psF32* imgInRow = img->data.F32[row]; 300 300 psF32* imgOutRow = img4->data.F32[row]; … … 324 324 return 2; \ 325 325 } \ 326 for ( unsigned introw=0;row<r;row++) { \326 for (psU32 row=0;row<r;row++) { \ 327 327 ps##IN* imgRow = img->data.IN[row]; \ 328 328 ps##OUT* img2Row = img2->data.OUT[row]; \ 329 for ( unsigned intcol=0;col<c;col++) { \329 for (psU32 col=0;col<c;col++) { \ 330 330 if (abs(imgRow[col] - (ps##IN)(row+col)) > 0.5) { \ 331 331 psError(__func__,"Input image was changed at %d,%d!", \ -
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.", -
trunk/psLib/test/image/tst_psImageExtraction.c
r2156 r2204 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1.1 7$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-10- 15 20:00:56$8 * @version $Revision: 1.18 $ $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 … … 18 18 #include "psType.h" 19 19 20 static inttestImageSlice(void);21 static inttestImageSubset(void);22 static inttestImageSubsection(void);23 static inttestImageTrim(void);24 static inttestImageCut(void);25 static inttestImageRadialCut(void);20 static psS32 testImageSlice(void); 21 static psS32 testImageSubset(void); 22 static psS32 testImageSubsection(void); 23 static psS32 testImageTrim(void); 24 static psS32 testImageCut(void); 25 static psS32 testImageRadialCut(void); 26 26 27 27 … … 37 37 }; 38 38 39 int main( intargc, char* argv[] )39 psS32 main( psS32 argc, char* argv[] ) 40 40 { 41 41 return ! runTestSuite( stderr, "psImage", tests, argc, argv ); 42 42 } 43 43 44 inttestImageSlice(void)44 psS32 testImageSlice(void) 45 45 { 46 const intr = 200;47 const intc = 300;48 const intm = r / 2 -1;49 const intn = r / 4 -1;46 const psS32 r = 200; 47 const psS32 c = 300; 48 const psS32 m = r / 2 -1; 49 const psS32 n = r / 4 -1; 50 50 psVector* out = NULL; 51 51 psImage* image; … … 68 68 */ 69 69 70 for ( introw = 0;row < r;row++ ) {70 for ( psS32 row = 0;row < r;row++ ) { 71 71 psMaskType* maskRow = mask->data.PS_TYPE_MASK_DATA[row]; 72 for ( intcol = 0;col < c;col++ ) {72 for ( psS32 col = 0;col < c;col++ ) { 73 73 maskRow[ col ] = 0; 74 74 } … … 77 77 #define PSIMAGESLICE_TEST1(TYPE,M,N,DIRECTION,TRUTH_SIZE,TRUTHPIX_X,TRUTHPIX_Y,TESTNUM) \ 78 78 image = psImageAlloc( c, r, PS_TYPE_##TYPE ); \ 79 for ( introw = 0;row < r;row++ ) { \79 for ( psS32 row = 0;row < r;row++ ) { \ 80 80 ps##TYPE *imageRow = image->data.TYPE[ row ]; \ 81 81 ps##TYPE rowOffset = row * 2; \ 82 for ( intcol = 0;col < c;col++ ) { \82 for ( psS32 col = 0;col < c;col++ ) { \ 83 83 imageRow[ col ] = col + rowOffset; \ 84 84 } \ … … 98 98 } \ 99 99 \ 100 for ( inti=0;i<out->n;i++) { \100 for (psS32 i=0;i<out->n;i++) { \ 101 101 if (fabs(out->data.F64[i]-image->data.TYPE[r/10+TRUTHPIX_Y][c/10+TRUTHPIX_X]) > 1.0/(psF64)r) { \ 102 102 psError(__func__,"Improper result at position %d. Got %g, expected %g",i, \ … … 363 363 364 364 // #547: psImageSubset shall create child image of a specified size from a parent psImage structure 365 inttestImageSubset(void)365 psS32 testImageSubset(void) 366 366 { 367 367 psImage preSubsetStruct; … … 370 370 psImage* subset2 = NULL; 371 371 psImage* subset3 = NULL; 372 intc = 128;373 intr = 256;372 psS32 c = 128; 373 psS32 r = 256; 374 374 375 375 original = psImageAlloc(c,r,PS_TYPE_U32); 376 for ( introw=0;row<r;row++) {377 for ( intcol=0;col<c;col++) {376 for (psS32 row=0;row<r;row++) { 377 for (psS32 col=0;col<c;col++) { 378 378 original->data.F32[row][col] = row*1000+col; 379 379 } … … 404 404 "row member, if the input psImage structure image contains known values."); 405 405 406 for ( introw=0;row<r/2;row++) {407 for ( intcol=0;col<c/2;col++) {406 for (psS32 row=0;row<r/2;row++) { 407 for (psS32 col=0;col<c/2;col++) { 408 408 if (subset2->data.U32[row][col] != original->data.U32[row+r/4][col+c/4]) { 409 409 psError(__func__,"psImageSubset output #1 was wrong at %dx%d (%d vs %d).", … … 596 596 597 597 // #730: psImageSubsection shall create child image of a specified size from a parent psImage structure 598 inttestImageSubsection(void)598 psS32 testImageSubsection(void) 599 599 { 600 600 psImage* original; 601 601 psImage* subset; 602 intc = 128;603 intr = 256;604 inti;605 intnumRegions = 4;606 intx1[] = { 0, 32, 64, 32};607 intx2[] = { 32, 64,127, 64};608 inty1[] = { 0, 32, 32,128};609 inty2[] = { 32, 64, 64,255};602 psS32 c = 128; 603 psS32 r = 256; 604 psS32 i; 605 psS32 numRegions = 4; 606 psS32 x1[] = { 0, 32, 64, 32}; 607 psS32 x2[] = { 32, 64,127, 64}; 608 psS32 y1[] = { 0, 32, 32,128}; 609 psS32 y2[] = { 32, 64, 64,255}; 610 610 611 611 original = psImageAlloc(c,r,PS_TYPE_U32); 612 for ( introw=0;row<r;row++) {613 for ( intcol=0;col<c;col++) {612 for (psS32 row=0;row<r;row++) { 613 for (psS32 col=0;col<c;col++) { 614 614 original->data.F32[row][col] = row*1000+col; 615 615 } … … 664 664 } 665 665 666 intnumCols = x2[i]-x1[i]+1;667 intnumRows = y2[i]-y1[i]+1;666 psS32 numCols = x2[i]-x1[i]+1; 667 psS32 numRows = y2[i]-y1[i]+1; 668 668 if (subset->numCols != numCols || subset->numRows != numRows) { 669 669 psError(__func__,"psImageSubsection output size was not proper(%dx%d, should be %dx%d).", … … 672 672 } 673 673 674 for ( introw=0;row<numRows;row++) {675 for ( intcol=0;col<numCols;col++) {674 for (psS32 row=0;row<numRows;row++) { 675 for (psS32 col=0;col<numCols;col++) { 676 676 if (subset->data.U32[row][col] != original->data.U32[row+y1[i]][col+x1[i]]) { 677 677 psError(__func__,"psImageSubset output #1 was wrong at %dx%d (%d vs %d).", … … 751 751 } 752 752 753 static inttestImageTrim(void)753 static psS32 testImageTrim(void) 754 754 { 755 intr = 200;756 intc = 300;757 intqtrR = r/4;758 intqtrC = c/4;759 inthalfR = r/2;760 inthalfC = c/2;755 psS32 r = 200; 756 psS32 c = 300; 757 psS32 qtrR = r/4; 758 psS32 qtrC = c/4; 759 psS32 halfR = r/2; 760 psS32 halfC = c/2; 761 761 762 762 psImage* image = psImageAlloc(c,r,PS_TYPE_F32); 763 for ( introw = 0; row < image->numRows; row++) {764 for ( intcol = 0; col < image->numCols; col++) {763 for (psS32 row = 0; row < image->numRows; row++) { 764 for (psS32 col = 0; col < image->numCols; col++) { 765 765 image->data.F32[row][col] = (psF32)col + (psF32)row/1000.0f; 766 766 } … … 792 792 } 793 793 794 for ( introw = 0; row < image2->numRows; row++) {795 for ( intcol = 0; col < image2->numCols; col++) {794 for (psS32 row = 0; row < image2->numRows; row++) { 795 for (psS32 col = 0; col < image2->numCols; col++) { 796 796 if (fabsf(image2->data.F32[row][col] - image->data.F32[row+qtrR][col+qtrC]) > FLT_EPSILON) { 797 797 psLogMsg(__func__,PS_LOG_ERROR, … … 830 830 } 831 831 832 for ( introw = 0; row < image2->numRows; row++) {833 for ( intcol = 0; col < image2->numCols; col++) {832 for (psS32 row = 0; row < image2->numRows; row++) { 833 for (psS32 col = 0; col < image2->numCols; col++) { 834 834 if (fabsf(image2->data.F32[row][col] - 835 835 image->data.F32[row+qtrR][col+qtrC]) > FLT_EPSILON) { … … 869 869 } 870 870 871 for ( introw = 0; row < image2->numRows; row++) {872 for ( intcol = 0; col < image2->numCols; col++) {871 for (psS32 row = 0; row < image2->numRows; row++) { 872 for (psS32 col = 0; col < image2->numCols; col++) { 873 873 if (fabsf(image2->data.F32[row][col] - 874 874 image->data.F32[row+qtrR][col+qtrC]) > FLT_EPSILON) { … … 1014 1014 } 1015 1015 1016 static inttestImageCut(void)1016 static psS32 testImageCut(void) 1017 1017 { 1018 intc = 300;1019 intr = 200;1020 intnumPoints = 15;1018 psS32 c = 300; 1019 psS32 r = 200; 1020 psS32 numPoints = 15; 1021 1021 float startCol[] = { 40,150, 40, 0,280, 40,280, -1,300, 20, 20, 20, 20, 20, 20}; 1022 1022 float endCol[] = {240,150,240,299, 40,240, 40,240,240, -1,300,240,240,240,240}; 1023 1023 float startRow[] = { 20, 10,100, 0, 20,180,180, 10, 10, 10, 10, -1,200, 10, 10}; 1024 1024 float endRow[] = {160,180,100,199,160, 10, 10,180,180,180,180,180,180, -1,200}; 1025 bool success[] = {true,true,true,true,true,true,true,false,false,false,false,false,false,false,false};1026 unsigned intlength = 100;1025 psBool success[] = {true,true,true,true,true,true,true,false,false,false,false,false,false,false,false}; 1026 psU32 length = 100; 1027 1027 1028 1028 psImage* image = psImageAlloc(c,r,PS_TYPE_F32); 1029 1029 psImage* mask = psImageAlloc(c,r,PS_TYPE_MASK); 1030 for ( introw = 0; row < image->numRows; row++) {1031 for ( intcol = 0; col < image->numCols; col++) {1030 for (psS32 row = 0; row < image->numRows; row++) { 1031 for (psS32 col = 0; col < image->numCols; col++) { 1032 1032 image->data.F32[row][col] = (psF32)col + (psF32)row/1000.0f; 1033 1033 if ((row & 0x0F) == 0) { … … 1042 1042 1043 1043 psVector* result = NULL; 1044 for ( intn = 0; n < numPoints; n++) {1044 for (psS32 n = 0; n < numPoints; n++) { 1045 1045 psVector* orig = result; 1046 1046 if (! success[n]) { … … 1083 1083 float deltaCol = (endCol[n]-startCol[n])/(length-1); 1084 1084 psF32 truth; 1085 for ( inti = 0; i < length; i++) {1085 for (psS32 i = 0; i < length; i++) { 1086 1086 float x = (float)startCol[n]+(float)i*deltaCol; 1087 1087 float y = (float)startRow[n]+(float)i*deltaRow; … … 1177 1177 } 1178 1178 1179 static inttestImageRadialCut(void)1179 static psS32 testImageRadialCut(void) 1180 1180 { 1181 intc = 300;1182 intr = 200;1183 intcenterX = c/2;1184 intcenterY = r/2;1181 psS32 c = 300; 1182 psS32 r = 200; 1183 psS32 centerX = c/2; 1184 psS32 centerY = r/2; 1185 1185 psErr* err = NULL; 1186 1186 1187 1187 psImage* image = psImageAlloc(c,r,PS_TYPE_F32); 1188 1188 psImage* mask = psImageAlloc(c,r,PS_TYPE_MASK); 1189 for ( introw = 0; row < image->numRows; row++) {1190 for ( intcol = 0; col < image->numCols; col++) {1189 for (psS32 row = 0; row < image->numRows; row++) { 1190 for (psS32 col = 0; col < image->numCols; col++) { 1191 1191 image->data.F32[row][col] = sqrtf((col-centerX)*(col-centerX)+(row-centerY)*(row-centerY)); 1192 1192 if ((row & 0x0F) == 0) { … … 1200 1200 psStats* stat = psStatsAlloc(PS_STAT_SAMPLE_MEAN); 1201 1201 psVector* radii = psVectorAlloc(10,PS_TYPE_F32); 1202 for ( inti=0; i < 10; i++) {1202 for (psS32 i=0; i < 10; i++) { 1203 1203 radii->data.F32[i] = 10+i*10; 1204 1204 } … … 1220 1220 } 1221 1221 1222 for ( inti=0; i < 9; i++) {1222 for (psS32 i=0; i < 9; i++) { 1223 1223 if (fabs(result->data.F64[i] - (15.0+i*10)) > 1) { 1224 1224 psLogMsg(__func__,PS_LOG_ERROR, … … 1245 1245 } 1246 1246 1247 for ( inti=0; i < 9; i++) {1247 for (psS32 i=0; i < 9; i++) { 1248 1248 if (fabs(result->data.F64[i] - (15.0+i*10)) > 1) { 1249 1249 psLogMsg(__func__,PS_LOG_ERROR, -
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; -
trunk/psLib/test/image/tst_psImageIO.c
r1942 r2204 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1. 9$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-10- 02 02:09:21$8 * @version $Revision: 1.10 $ $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 … … 25 25 #define GENIMAGE(img,c,r,TYP, valueFcn) \ 26 26 img = psImageAlloc(c,r,PS_TYPE_##TYP); \ 27 for ( unsigned introw=0;row<r;row++) { \27 for (psU32 row=0;row<r;row++) { \ 28 28 ps##TYP* imgRow = img->data.TYP[row]; \ 29 for ( unsigned intcol=0;col<c;col++) { \29 for (psU32 col=0;col<c;col++) { \ 30 30 imgRow[col] = (ps##TYP)(valueFcn); \ 31 31 } \ 32 32 } 33 33 34 static inttestImageRead(void);35 static inttestImageWrite(void);34 static psS32 testImageRead(void); 35 static psS32 testImageWrite(void); 36 36 37 37 testDescription tests[] = { … … 47 47 }; 48 48 49 int main(intargc, char* argv[])49 psS32 main(psS32 argc, char* argv[]) 50 50 { 51 51 psLogSetLevel(PS_LOG_INFO); … … 57 57 } 58 58 59 inttestImageRead(void)59 psS32 testImageRead(void) 60 60 { 61 intN = 256;62 intM = 128;61 psS32 N = 256; 62 psS32 M = 128; 63 63 psImage* image = NULL; 64 64 … … 127 127 return 6; \ 128 128 } \ 129 for ( unsigned introw = readN0; row < readN; row++) { \129 for (psU32 row = readN0; row < readN; row++) { \ 130 130 ps##TYP* imgRow = img->data.TYP[row-readN0]; \ 131 131 ps##TYP* img2Row = img2->data.TYP[row]; \ 132 132 ps##TYP* img3Row = img3->data.TYP[row-readN0]; \ 133 133 ps##TYP* img4Row = img4->data.TYP[row]; \ 134 for ( unsigned intcol = readM0; col < readM; col++) { \134 for (psU32 col = readM0; col < readM; col++) { \ 135 135 if (fabsf(imgRow[col-readM0]-img2Row[col]) > FLT_EPSILON) { \ 136 136 psError(__func__,"Image changed in I/O operation at %d,%d,0 (%.2f vs %.2f) for %s", \ … … 155 155 return 9; \ 156 156 } \ 157 for ( unsigned introw = readN0; row < readN; row++) { \157 for (psU32 row = readN0; row < readN; row++) { \ 158 158 ps##TYP* imgRow = img->data.TYP[row-readN0]; \ 159 159 ps##TYP* img2Row = img2->data.TYP[row]; \ 160 160 ps##TYP* img3Row = img3->data.TYP[row-readN0]; \ 161 161 ps##TYP* img4Row = img4->data.TYP[row]; \ 162 for ( unsigned intcol = readM0; col < readM; col++) { \162 for (psU32 col = readM0; col < readM; col++) { \ 163 163 if (fabsf(imgRow[col-readM0]-img2Row[col]) > FLT_EPSILON) { \ 164 164 psError(__func__,"Image changed in I/O operation at %d,%d,0 (%.2f vs %.2f) for %s", \ … … 258 258 } 259 259 260 inttestImageWrite(void)260 psS32 testImageWrite(void) 261 261 { 262 262 psImage* img = NULL; 263 263 psImage* img2 = NULL; 264 intm = 64;265 intn = 96;264 psS32 m = 64; 265 psS32 n = 96; 266 266 267 267 /* … … 318 318 return 16; 319 319 } 320 for ( unsigned introw=0;row<n;row++) {320 for (psU32 row=0;row<n;row++) { 321 321 psF32* imgRow = img->data.F32[row]; 322 for ( unsigned intcol=0;col<m;col++) {322 for (psU32 col=0;col<m;col++) { 323 323 if (fabsf(imgRow[col] - (row+2*col)) > FLT_EPSILON) { 324 324 psError(__func__,"The image values were not overwritten at %d,%d (%.2f vs %.2f)", -
trunk/psLib/test/image/tst_psImageManip.c
r2105 r2204 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1. 29$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-10- 14 01:22:59$8 * @version $Revision: 1.30 $ $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 … … 25 25 #include "psType.h" 26 26 27 static inttestImageClip(void);28 static inttestImageClipNAN(void);29 static inttestImageClipComplexRegion(void);30 static inttestImageOverlay(void);31 static inttestImageRebin(void);32 static inttestImageRoll(void);33 static inttestImageRotate(void);34 static inttestImageShift(void);35 static int testImageShiftCase(int cols, introws, float colShift,float rowShift);36 static inttestImageResample(void);27 static psS32 testImageClip(void); 28 static psS32 testImageClipNAN(void); 29 static psS32 testImageClipComplexRegion(void); 30 static psS32 testImageOverlay(void); 31 static psS32 testImageRebin(void); 32 static psS32 testImageRoll(void); 33 static psS32 testImageRotate(void); 34 static psS32 testImageShift(void); 35 static psS32 testImageShiftCase(psS32 cols, psS32 rows, float colShift,float rowShift); 36 static psS32 testImageResample(void); 37 37 38 38 testDescription tests[] = { … … 49 49 }; 50 50 51 int main(intargc, char* argv[])51 psS32 main(psS32 argc, char* argv[]) 52 52 { 53 53 psLogSetLevel(PS_LOG_INFO); … … 57 57 58 58 59 inttestImageClip(void)59 psS32 testImageClip(void) 60 60 { 61 61 psImage* img = NULL; 62 unsigned intc = 128;63 unsigned intr = 256;62 psU32 c = 128; 63 psU32 r = 256; 64 64 psF64 min; 65 65 psF64 max; 66 intnumClipped = 0;67 intretVal;66 psS32 numClipped = 0; 67 psS32 retVal; 68 68 69 69 psLogMsg(__func__,PS_LOG_INFO, … … 95 95 #define testImageClipByType(datatype) \ 96 96 img = psImageAlloc(c,r,PS_TYPE_##datatype); \ 97 for ( unsigned introw=0;row<r;row++) { \97 for (psU32 row=0;row<r;row++) { \ 98 98 ps##datatype* imgRow = img->data.datatype[row]; \ 99 for ( unsigned intcol=0;col<c;col++) { \99 for (psU32 col=0;col<c;col++) { \ 100 100 imgRow[col] = (ps##datatype)(row+col); \ 101 101 } \ … … 107 107 \ 108 108 numClipped = 0; \ 109 for ( unsigned introw=0;row<r;row++) { \109 for (psU32 row=0;row<r;row++) { \ 110 110 ps##datatype* imgRow = img->data.datatype[row]; \ 111 for ( unsigned intcol=0;col<c;col++) { \111 for (psU32 col=0;col<c;col++) { \ 112 112 ps##datatype value = (ps##datatype)(row+col); \ 113 113 if (value < min) { \ … … 134 134 #define testImageClipByComplexType(datatype) \ 135 135 img = psImageAlloc(c,r,PS_TYPE_##datatype); \ 136 for ( unsigned introw=0;row<r;row++) { \136 for (psU32 row=0;row<r;row++) { \ 137 137 ps##datatype* imgRow = img->data.datatype[row]; \ 138 for ( unsigned intcol=0;col<c;col++) { \138 for (psU32 col=0;col<c;col++) { \ 139 139 imgRow[col] = (ps##datatype)(row+I*col); \ 140 140 } \ … … 146 146 \ 147 147 numClipped = 0; \ 148 for ( unsigned introw=0;row<r;row++) { \148 for (psU32 row=0;row<r;row++) { \ 149 149 ps##datatype* imgRow = img->data.datatype[row]; \ 150 for ( unsigned intcol=0;col<c;col++) { \150 for (psU32 col=0;col<c;col++) { \ 151 151 ps##datatype value = row+I*col; \ 152 152 if (cabs(value) < min) { \ … … 225 225 } 226 226 227 inttestImageClipNAN(void)227 psS32 testImageClipNAN(void) 228 228 { 229 229 psImage* img = NULL; 230 unsigned intc = 128;231 unsigned intr = 256;232 intnumClipped = 0;233 intretVal;230 psU32 c = 128; 231 psU32 r = 256; 232 psS32 numClipped = 0; 233 psS32 retVal; 234 234 235 235 psLogMsg(__func__,PS_LOG_INFO, … … 317 317 } 318 318 319 inttestImageClipComplexRegion(void)319 psS32 testImageClipComplexRegion(void) 320 320 { 321 321 psImage* img = NULL; 322 unsigned intc = 1024;323 unsigned intr = 2048;324 intnumClipped = 0;325 intretVal;322 psU32 c = 1024; 323 psU32 r = 2048; 324 psS32 numClipped = 0; 325 psS32 retVal; 326 326 327 327 psLogMsg(__func__,PS_LOG_INFO, … … 581 581 } 582 582 583 inttestImageOverlay(void)583 psS32 testImageOverlay(void) 584 584 { 585 585 … … 588 588 psImage* img3 = NULL; 589 589 psImage* img4 = NULL; 590 unsigned intc = 128;591 unsigned intr = 256;592 intretVal;590 psU32 c = 128; 591 psU32 r = 256; 592 psS32 retVal; 593 593 594 594 /* … … 833 833 } 834 834 835 static inttestImageRebin(void)835 static psS32 testImageRebin(void) 836 836 { 837 837 … … 869 869 memset(meanTruthWMask->data.F32[0],0,sizeof(psF32)*4*4); \ 870 870 memset(maxTruth->data.F32[0],0,sizeof(psF32)*6*6); \ 871 for ( introw = 0; row<16; row++) { \871 for (psS32 row = 0; row<16; row++) { \ 872 872 ps##DATATYPE* inRow = in->data.DATATYPE[row]; \ 873 873 psF32* meanTruthRow = meanTruth->data.F32[row/4]; \ … … 875 875 psF32* maxTruthRow = maxTruth->data.F32[row/3]; \ 876 876 psU8* maskRow = mask->data.U8[row]; \ 877 for ( intcol = 0; col<16; col++) { \877 for (psS32 col = 0; col<16; col++) { \ 878 878 if(col != 15) { \ 879 879 maskRow[col] = 0; \ … … 891 891 } \ 892 892 } \ 893 for ( introw = 0; row<4; row++) { \893 for (psS32 row = 0; row<4; row++) { \ 894 894 psF32* meanTruthRow = meanTruth->data.F32[row]; \ 895 895 psF32* meanTruthWMaskRow = meanTruthWMask->data.F32[row]; \ 896 for ( intcol = 0; col<4; col++) { \896 for (psS32 col = 0; col<4; col++) { \ 897 897 meanTruthRow[col] /= 16; \ 898 898 if ( col == 3 ) { \ … … 915 915 return 2; \ 916 916 } \ 917 for ( introw = 0; row<4; row++) { \917 for (psS32 row = 0; row<4; row++) { \ 918 918 ps##DATATYPE* outRow = out->data.DATATYPE[row]; \ 919 919 psF32* truthRow = meanTruth->data.F32[row]; \ 920 for ( intcol = 0; col<4; col++) { \920 for (psS32 col = 0; col<4; col++) { \ 921 921 if (fabsf((float)outRow[col]-(float)truthRow[col]) > FLT_EPSILON) { \ 922 922 psError(__func__,"psImageRebin didn't produce the proper mean " \ … … 929 929 stats.options = PS_STAT_SAMPLE_MEAN; \ 930 930 out3 = psImageRebin(NULL,in,mask,1,4,&stats); \ 931 for ( introw = 0; row<4; row++) { \931 for (psS32 row = 0; row<4; row++) { \ 932 932 ps##DATATYPE* outRow = out3->data.DATATYPE[row]; \ 933 933 psF32* truthRow = meanTruthWMask->data.F32[row]; \ 934 for ( intcol = 0; col<4; col++) { \935 if(abs(( int)outRow[col]-(int)truthRow[col]) > FLT_EPSILON) { \934 for ( psS32 col = 0; col<4; col++) { \ 935 if(abs((psS32)outRow[col]-(psS32)truthRow[col]) > FLT_EPSILON) { \ 936 936 psError(__func__,"psImageRebin with mask didn't produce the proper mean " \ 937 937 "result at (%d,%d) [%f vs %f].", \ … … 957 957 return 5; \ 958 958 } \ 959 for ( introw = 0; row<6; row++) { \959 for (psS32 row = 0; row<6; row++) { \ 960 960 ps##DATATYPE* outRow = out->data.DATATYPE[row]; \ 961 961 psF32* truthRow = maxTruth->data.F32[row]; \ 962 for ( intcol = 0; col<6; col++) { \962 for (psS32 col = 0; col<6; col++) { \ 963 963 if (fabsf((float)outRow[col]-(float)truthRow[col]) > FLT_EPSILON) { \ 964 964 psError(__func__,"psImageRebin didn't produce the proper " \ … … 1082 1082 } 1083 1083 1084 static inttestImageRoll(void)1084 static psS32 testImageRoll(void) 1085 1085 { 1086 1086 … … 1088 1088 psImage* out; 1089 1089 psImage* out2; 1090 introws = 64;1091 intcols = 64;1092 introws1 = 8;1093 intcols1 = 8;1090 psS32 rows = 64; 1091 psS32 cols = 64; 1092 psS32 rows1 = 8; 1093 psS32 cols1 = 8; 1094 1094 1095 1095 /* … … 1108 1108 1109 1109 in = psImageAlloc(cols,rows,PS_TYPE_F32); 1110 for ( introw=0;row<rows;row++) {1110 for (psS32 row=0;row<rows;row++) { 1111 1111 psF32* inRow = in->data.F32[row]; 1112 for ( intcol=0;col<cols;col++) {1112 for (psS32 col=0;col<cols;col++) { 1113 1113 inRow[col] = (psF32)row+(psF32)col/1000.0f; 1114 1114 } … … 1116 1116 1117 1117 out = psImageRoll(NULL,in,0,0); 1118 for ( introw=0;row<rows;row++) {1118 for (psS32 row=0;row<rows;row++) { 1119 1119 psF32* inRow = in->data.F32[row]; 1120 1120 psF32* outRow = out->data.F32[row]; 1121 for ( intcol=0;col<cols;col++) {1121 for (psS32 col=0;col<cols;col++) { 1122 1122 if (inRow[col] != outRow[col]) { 1123 1123 psError(__func__,"psImageRoll didn't produce expected result " … … 1130 1130 1131 1131 out2 = psImageRoll(out,in,cols/4,0); 1132 for ( introw=0;row<rows;row++) {1132 for (psS32 row=0;row<rows;row++) { 1133 1133 psF32* inRow = in->data.F32[row]; 1134 1134 psF32* outRow = out->data.F32[row]; 1135 for ( intcol=0;col<cols;col++) {1135 for (psS32 col=0;col<cols;col++) { 1136 1136 if (inRow[(col+cols/4) % cols] != outRow[col]) { 1137 1137 psError(__func__,"psImageRoll didn't produce expected result " … … 1151 1151 1152 1152 out = psImageRoll(out,in,0,rows/4); 1153 for ( introw=0;row<rows;row++) {1153 for (psS32 row=0;row<rows;row++) { 1154 1154 psF32* inRow = in->data.F32[(row+rows/4)%rows]; 1155 1155 psF32* outRow = out->data.F32[row]; 1156 for ( intcol=0;col<cols;col++) {1156 for (psS32 col=0;col<cols;col++) { 1157 1157 if (inRow[col] != outRow[col]) { 1158 1158 psError(__func__,"psImageRoll didn't produce expected result " … … 1165 1165 1166 1166 out = psImageRoll(out,in,cols/4,rows/4); 1167 for ( introw=0;row<rows;row++) {1167 for (psS32 row=0;row<rows;row++) { 1168 1168 psF32* inRow = in->data.F32[(row+rows/4)%rows]; 1169 1169 psF32* outRow = out->data.F32[row]; 1170 for ( intcol=0;col<cols;col++) {1170 for (psS32 col=0;col<cols;col++) { 1171 1171 if (inRow[(col+cols/4) % cols] != outRow[col]) { 1172 1172 psError(__func__,"psImageRoll didn't produce expected result " … … 1179 1179 1180 1180 out = psImageRoll(out,in,-cols/4,0); 1181 for ( introw=0;row<rows;row++) {1181 for (psS32 row=0;row<rows;row++) { 1182 1182 psF32* inRow = in->data.F32[row]; 1183 1183 psF32* outRow = out->data.F32[row]; 1184 for ( intcol=0;col<cols;col++) {1184 for (psS32 col=0;col<cols;col++) { 1185 1185 if (inRow[(col+(cols-cols/4)) % cols] != outRow[col]) { 1186 1186 psError(__func__,"psImageRoll didn't produce expected result " … … 1193 1193 1194 1194 out = psImageRoll(out,in,0,-rows/4); 1195 for ( introw=0;row<rows;row++) {1195 for (psS32 row=0;row<rows;row++) { 1196 1196 psF32* inRow = in->data.F32[(row+rows-rows/4)%rows]; 1197 1197 psF32* outRow = out->data.F32[row]; 1198 for ( intcol=0;col<cols;col++) {1198 for (psS32 col=0;col<cols;col++) { 1199 1199 if (inRow[col] != outRow[col]) { 1200 1200 psError(__func__,"psImageRoll didn't produce expected result " … … 1207 1207 1208 1208 out = psImageRoll(out,in,-cols/4,-rows/4); 1209 for ( introw=0;row<rows;row++) {1209 for (psS32 row=0;row<rows;row++) { 1210 1210 psF32* inRow = in->data.F32[(row+rows-rows/4)%rows]; 1211 1211 psF32* outRow = out->data.F32[row]; 1212 for ( intcol=0;col<cols;col++) {1212 for (psS32 col=0;col<cols;col++) { 1213 1213 if (inRow[(col+cols-cols/4) % cols] != outRow[col]) { 1214 1214 psError(__func__,"psImageRoll didn't produce expected result " … … 1236 1236 in = psImageAlloc(rows1,cols1,PS_TYPE_##DATATYPE); \ 1237 1237 \ 1238 for ( introw=0;row<rows1;row++) { \1238 for (psS32 row=0;row<rows1;row++) { \ 1239 1239 ps##DATATYPE* inRow = in->data.DATATYPE[row]; \ 1240 for ( intcol=0;col<cols1;col++) { \1240 for (psS32 col=0;col<cols1;col++) { \ 1241 1241 inRow[col] = (ps##DATATYPE)row+(ps##DATATYPE)col; \ 1242 1242 } \ … … 1244 1244 \ 1245 1245 out = psImageRoll(NULL,in,rows1/4,cols1/4); \ 1246 for ( introw=0;row<rows1;row++) { \1246 for (psS32 row=0;row<rows1;row++) { \ 1247 1247 ps##DATATYPE* inRow = in->data.DATATYPE[(row+rows1/4)%rows1]; \ 1248 1248 ps##DATATYPE* outRow = out->data.DATATYPE[row]; \ 1249 for ( intcol=0;col<cols1;col++) { \1249 for (psS32 col=0;col<cols1;col++) { \ 1250 1250 if (inRow[(col+cols1/4)%cols1] != outRow[col]) { \ 1251 1251 psError(__func__,"psImageRoll didn't produce expected result " \ … … 1270 1270 } 1271 1271 1272 inttestImageRotate(void)1272 psS32 testImageRotate(void) 1273 1273 { 1274 1274 /* … … 1300 1300 psImage* fBiTruth = NULL; 1301 1301 psImage* sBiTruth = NULL; 1302 introws = 64;1303 intcols = 64;1302 psS32 rows = 64; 1303 psS32 cols = 64; 1304 1304 psImage* fImg = psImageAlloc(cols,rows,PS_TYPE_F32); 1305 1305 psImage* sImg = psImageAlloc(cols,rows,PS_TYPE_S16); 1306 1306 psImage* s32Img = psImageAlloc(cols,rows,PS_TYPE_S32); 1307 1307 1308 for( introw=0;row<rows;row++) {1308 for(psS32 row=0;row<rows;row++) { 1309 1309 psF32* fRow = fImg->data.F32[row]; 1310 1310 psS16* sRow = sImg->data.S16[row]; 1311 1311 psS32* s32Row = s32Img->data.S32[row]; 1312 for ( intcol=0;col<cols;col++) {1312 for (psS32 col=0;col<cols;col++) { 1313 1313 fRow[col] = (psF32)(row)+(psF32)(col)/100.0f; 1314 1314 sRow[col] = row-2*col; … … 1336 1336 ("temp/sBiOut.fits"); 1337 1337 ; 1338 intindex = 0;1339 bool fail = false;1340 for ( introt=-180;rot<=180;rot+=45) {1338 psS32 index = 0; 1339 psBool fail = false; 1340 for (psS32 rot=-180;rot<=180;rot+=45) { 1341 1341 psImage* oldOut = fOut; 1342 1342 psImage* oldBiOut = fBiOut; … … 1388 1388 fail = true; 1389 1389 } else { 1390 for ( introw=0;row<fTruth->numRows;row++) {1390 for (psS32 row=0;row<fTruth->numRows;row++) { 1391 1391 psF32* truthRow = fTruth->data.F32[row]; 1392 1392 psF32* outRow = fOut->data.F32[row]; 1393 for ( intcol=0;col<fTruth->numCols;col++) {1393 for (psS32 col=0;col<fTruth->numCols;col++) { 1394 1394 if (fabsf(truthRow[col]-outRow[col]) > 1) { 1395 1395 psError(__func__,"Float Image mismatch (%f vs %f) at %d,%d.", … … 1409 1409 if (sTruth->numRows != sOut->numRows || 1410 1410 sTruth->numCols != sOut->numCols) { 1411 psError(__func__,"Rotated shortimage size did not match truth "1411 psError(__func__,"Rotated psS16 image size did not match truth " 1412 1412 "image for %d deg rotation.",rot); 1413 1413 fail = true; 1414 1414 } else { 1415 for ( introw=0;row<sTruth->numRows;row++) {1415 for (psS32 row=0;row<sTruth->numRows;row++) { 1416 1416 psS16* truthRow = sTruth->data.S16[row]; 1417 1417 psS16* outRow = sOut->data.S16[row]; 1418 for ( intcol=0;col<sTruth->numCols;col++) {1418 for (psS32 col=0;col<sTruth->numCols;col++) { 1419 1419 if (fabsf(truthRow[col]-outRow[col]) > 1) { 1420 1420 psError(__func__,"Short Image mismatch (%d vs %d) " … … 1440 1440 fail = true; 1441 1441 } else { 1442 for ( introw=0;row<fBiTruth->numRows;row++) {1442 for (psS32 row=0;row<fBiTruth->numRows;row++) { 1443 1443 psF32* truthRow = fBiTruth->data.F32[row]; 1444 1444 psF32* outRow = fBiOut->data.F32[row]; 1445 for ( intcol=0;col<fBiTruth->numCols;col++) {1445 for (psS32 col=0;col<fBiTruth->numCols;col++) { 1446 1446 if (fabsf(truthRow[col]-outRow[col]) > 1) { 1447 1447 psError(__func__,"Float Image mismatch (%f vs %f) at %d,%d. BILINEAR", … … 1461 1461 if (sBiTruth->numRows != sBiOut->numRows || 1462 1462 sBiTruth->numCols != sBiOut->numCols) { 1463 psError(__func__,"Rotated shortimage size did not match truth "1463 psError(__func__,"Rotated psS16 image size did not match truth " 1464 1464 "image for %d deg rotation. BILINEAR",rot); 1465 1465 fail = true; 1466 1466 } else { 1467 for ( introw=0;row<sBiTruth->numRows;row++) {1467 for (psS32 row=0;row<sBiTruth->numRows;row++) { 1468 1468 psS16* truthRow = sBiTruth->data.S16[row]; 1469 1469 psS16* outRow = sBiOut->data.S16[row]; 1470 for ( intcol=0;col<sBiTruth->numCols;col++) {1470 for (psS32 col=0;col<sBiTruth->numCols;col++) { 1471 1471 if (fabsf(truthRow[col]-outRow[col]) > 1) { 1472 1472 psError(__func__,"Short Image mismatch (%d vs %d) " … … 1537 1537 } 1538 1538 1539 static inttestImageShift(void)1539 static psS32 testImageShift(void) 1540 1540 { 1541 1541 /* psImageShift: … … 1558 1558 */ 1559 1559 1560 intretVal=0;1560 psS32 retVal=0; 1561 1561 1562 1562 // integer shift … … 1627 1627 } 1628 1628 1629 static int testImageShiftCase(intcols,1630 introws,1631 float colShift,1632 float rowShift)1629 static psS32 testImageShiftCase(psS32 cols, 1630 psS32 rows, 1631 float colShift, 1632 float rowShift) 1633 1633 { 1634 1634 psImage* fOut = NULL; … … 1643 1643 psImage* sBiOut = psImageAlloc(cols,rows,PS_TYPE_S16); 1644 1644 1645 for( introw=0;row<rows;row++) {1645 for(psS32 row=0;row<rows;row++) { 1646 1646 psF32* fRow = fImg->data.F32[row]; 1647 1647 psS16* sRow = sImg->data.S16[row]; 1648 for ( intcol=0;col<cols;col++) {1648 for (psS32 col=0;col<cols;col++) { 1649 1649 fRow[col] = (psF32)(row)+(psF32)(col)/100.0f; 1650 1650 sRow[col] = row-2*col; … … 1657 1657 sBiOut = psImageShift(sBiOut, sImg, colShift, rowShift, -1, PS_INTERPOLATE_BILINEAR); 1658 1658 1659 for( introw=0;row<rows;row++) {1659 for(psS32 row=0;row<rows;row++) { 1660 1660 psF32* fRow = fOut->data.F32[row]; 1661 1661 psS16* sRow = sOut->data.S16[row]; … … 1663 1663 psS16* sBiRow = sBiOut->data.S16[row]; 1664 1664 1665 for ( intcol=0;col<cols;col++) {1665 for (psS32 col=0;col<cols;col++) { 1666 1666 psF32 fValue = psImagePixelInterpolate(fImg,col+colShift, 1667 1667 row+rowShift,NULL,0,NAN,PS_INTERPOLATE_FLAT); … … 1707 1707 } 1708 1708 1709 static inttestImageResample(void)1709 static psS32 testImageResample(void) 1710 1710 { 1711 1711 1712 introws = 60;1713 intcols = 80;1712 psS32 rows = 60; 1713 psS32 cols = 80; 1714 1714 psImage* result = NULL; 1715 intscale = 4;1715 psS32 scale = 4; 1716 1716 psErr* err; 1717 1717 1718 1718 psImage* image = psImageAlloc(cols,rows,PS_TYPE_F32); 1719 for( introw=0;row<rows;row++) {1719 for(psS32 row=0;row<rows;row++) { 1720 1720 psF32* imageRow = image->data.F32[row]; 1721 for ( intcol=0;col<cols;col++) {1721 for (psS32 col=0;col<cols;col++) { 1722 1722 imageRow[col] = row+2*col; 1723 1723 } … … 1753 1753 1754 1754 psF32 truthValue; 1755 for( introw=0;row<result->numRows;row++) {1756 for ( intcol=0;col<result->numCols;col++) {1755 for(psS32 row=0;row<result->numRows;row++) { 1756 for (psS32 col=0;col<result->numCols;col++) { 1757 1757 truthValue = psImagePixelInterpolate(image, 1758 1758 (float)col/(float)scale,(float)row/(float)scale, -
trunk/psLib/test/image/tst_psImageStats00.c
r1956 r2204 14 14 #define M 64 15 15 16 intmain()16 psS32 main() 17 17 { 18 18 psHistogram * myHist = NULL; … … 20 20 psImage *tmpImage = NULL; 21 21 psImage *tmpMask = NULL; 22 inttestStatus = true;23 intmemLeaks = 0;24 intnb = 0;25 inti = 0;26 intj = 0;27 intIMAGE_X_SIZE = 0;28 intIMAGE_Y_SIZE = 0;29 intcurrentId = 0;22 psS32 testStatus = true; 23 psS32 memLeaks = 0; 24 psS32 nb = 0; 25 psS32 i = 0; 26 psS32 j = 0; 27 psS32 IMAGE_X_SIZE = 0; 28 psS32 IMAGE_Y_SIZE = 0; 29 psS32 currentId = 0; 30 30 31 31 currentId = psMemGetId(); -
trunk/psLib/test/image/tst_psImageStats01.c
r1944 r2204 15 15 #define M 64 16 16 17 intmain()17 psS32 main() 18 18 { 19 19 psStats * myStats = NULL; … … 21 21 psImage *tmpImage = NULL; 22 22 psImage *tmpMask = NULL; 23 inttestStatus = true;24 intmemLeaks = 0;25 intnb = 0;26 inti = 0;27 intj = 0;28 intIMAGE_X_SIZE = 0;29 intIMAGE_Y_SIZE = 0;30 intcurrentId = 0;23 psS32 testStatus = true; 24 psS32 memLeaks = 0; 25 psS32 nb = 0; 26 psS32 i = 0; 27 psS32 j = 0; 28 psS32 IMAGE_X_SIZE = 0; 29 psS32 IMAGE_Y_SIZE = 0; 30 psS32 currentId = 0; 31 31 32 32 currentId = psMemGetId(); -
trunk/psLib/test/image/tst_psImageStats02.c
r2099 r2204 18 18 #define CHEBY_Y_DIM 8 19 19 #define THRESHOLD 10 20 intmain()20 psS32 main() 21 21 { 22 22 psStats * myStats = NULL; … … 26 26 psPolynomial2D *my2DPoly = NULL; 27 27 psPolynomial2D *null2DPoly = NULL; 28 inttestStatus = true;29 intmemLeaks = 0;30 inti = 0;31 intj = 0;32 intcurrentId = 0;28 psS32 testStatus = true; 29 psS32 memLeaks = 0; 30 psS32 i = 0; 31 psS32 j = 0; 32 psS32 currentId = 0; 33 33 34 34 currentId = psMemGetId(); -
trunk/psLib/test/image/tst_psImageStats03.c
r1909 r2204 13 13 #define IMAGE_SIZE 10 14 14 15 intmain()15 psS32 main() 16 16 { 17 17 psImage *tmpImage = NULL; 18 inttestStatus = true;19 intmemLeaks = 0;20 inti = 0;21 intj = 0;18 psS32 testStatus = true; 19 psS32 memLeaks = 0; 20 psS32 i = 0; 21 psS32 j = 0; 22 22 float pixel = 0.0; 23 23 float x = 0.0; 24 24 float y = 0.0; 25 intcurrentId = psMemGetId();25 psS32 currentId = psMemGetId(); 26 26 27 27 /*************************************************************************/
Note:
See TracChangeset
for help on using the changeset viewer.
