Changeset 2204 for trunk/psLib/test/image/tst_psImageExtraction.c
- Timestamp:
- Oct 26, 2004, 2:57:34 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/test/image/tst_psImageExtraction.c (modified) (23 diffs)
Legend:
- Unmodified
- Added
- Removed
-
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,
Note:
See TracChangeset
for help on using the changeset viewer.
