Changeset 13123 for trunk/psLib/test/imageops
- Timestamp:
- May 1, 2007, 6:14:33 PM (19 years ago)
- Location:
- trunk/psLib/test/imageops
- Files:
-
- 7 edited
-
Makefile.am (modified) (1 diff)
-
tap_psImageGeomManip.c (modified) (28 diffs)
-
tap_psImageMaskOps.c (modified) (3 diffs)
-
tap_psImagePixelExtract.c (modified) (25 diffs)
-
tap_psImagePixelManip.c (modified) (10 diffs)
-
tap_psImageStats.c (modified) (5 diffs)
-
tap_psImageStructManip.c (modified) (22 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/imageops/Makefile.am
r13042 r13123 21 21 tap_psImageConvolve2 \ 22 22 tap_psImagePixelExtract \ 23 tap_psImageInterpolate2 23 tap_psImageInterpolate2 \ 24 tap_psImageMaskOps 24 25 25 26 # tap_psImageShiftKernel -
trunk/psLib/test/imageops/tap_psImageGeomManip.c
r13084 r13123 5 5 * @author Robert DeSonia, MHPCC 6 6 * 7 * @version $Revision: 1. 7$ $Name: not supported by cvs2svn $8 * @date $Date: 2007-05-0 1 00:08:52$7 * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2007-05-02 04:14:33 $ 9 9 * 10 10 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 154 154 plan_tests(237); 155 155 156 // test ImageRebin()157 // This function shall generate a rescaled version of a psImage structure158 // derived from a specified statistics method.156 // test psImageRebin() 157 // This function shall generate a rescaled version of a psImage 158 // structure derived from a specified statistics method. 159 159 if (1) { 160 160 psMemId id = psMemGetId(); … … 295 295 testRebinType(U16); 296 296 testRebinType(S8); 297 // Verify the returned psImage structure is nulland program execution297 // Verify the returned psImage structure is NULL and program execution 298 298 // doesn't stop, if the input image type is not supported. 299 299 // Following should be an error for unsupported type … … 305 305 ok(out == NULL, "psImageRebin returned NULL for unsupported type"); 306 306 307 // Verify the returned psImage structure is nulland program execution307 // Verify the returned psImage structure is NULL and program execution 308 308 // doesn't stop, if the mask type is not U8 309 309 // Following should be an error for invallid mask type … … 314 314 psFree(in); 315 315 316 // Verify the returned psImage structure is nulland program execution317 // doesn't stop, if the input parameter input is null.316 // Verify the returned psImage structure is NULL and program execution 317 // doesn't stop, if the input parameter input is NULL. 318 318 out2 = psImageRebin(NULL,NULL,NULL,0,1,&stats); 319 319 ok(out2 == NULL, "psImageRebin returned NULL with NULL input"); 320 320 321 // Verify the returned psImage structure is nulland program execution321 // Verify the returned psImage structure is NULL and program execution 322 322 // doesn't stop, if the input parameter scale is less than or equal to zero. 323 323 in = psImageAlloc(16, 16, PS_TYPE_F32); … … 327 327 ok(out2 == NULL, "psImageRebin returned NULL when the scale was zero"); 328 328 329 // Verify the returned psImage structure is nulland program execution330 // doesn't stop, if the input parameter stats is null.331 // Following should be an error for stats null329 // Verify the returned psImage structure is NULL and program execution 330 // doesn't stop, if the input parameter stats is NULL. 331 // Following should be an error for stats NULL 332 332 // XXX: Verify error 333 333 out2 = psImageRebin(NULL,in,NULL,0,1,NULL); 334 334 ok(out2 == NULL, "psImageRebin returned an NULL when the stats was NULL"); 335 335 336 // Verify the returned psImage structure is nulland program execution336 // Verify the returned psImage structure is NULL and program execution 337 337 // doesn't stop, if the input parameter psStats structure member options 338 338 // is zero or any value which doesn't correspond to a valid statistical … … 350 350 ok(out2 == NULL, "psImageRebin returned an image though the stats options was PS_STAT_USE_RANGE"); 351 351 352 // Verify the returned psImage structure is nulland program execution352 // Verify the returned psImage structure is NULL and program execution 353 353 // doesn't stop, if the input parameter psStats structure member options 354 354 // specifies more than one valid statistical method. … … 363 363 } 364 364 365 // test ImageRoll()365 // test psImageRoll() 366 366 if (1) { 367 367 psMemId id = psMemGetId(); … … 387 387 388 388 in = psImageAlloc(cols,rows,PS_TYPE_F32); 389 for (psS32 row=0;row<rows;row++) 390 { 391 psF32 *inRow = in->data.F32[row]; 392 for (psS32 col=0;col<cols;col++) { 393 inRow[col] = (psF32)row+(psF32)col/1000.0f; 389 for (psS32 row=0;row<rows;row++) { 390 for (psS32 col=0;col<cols;col++) { 391 in->data.F32[row][col] = (psF32)row+(psF32)col/1000.0f; 394 392 } 395 393 } … … 397 395 out = psImageRoll(NULL,in,0,0); 398 396 bool errorFlag = false; 399 for (psS32 row=0;row<rows;row++) 400 { 397 for (psS32 row=0;row<rows;row++) { 401 398 psF32 *inRow = in->data.F32[row]; 402 399 psF32 *outRow = out->data.F32[row]; … … 519 516 520 517 521 // Verify the returned psImage structure pointer is nulland program522 // execution doesn't stop, if input parameter input is null.518 // Verify the returned psImage structure pointer is NULL and program 519 // execution doesn't stop, if input parameter input is NULL. 523 520 out2 = psImageRoll(NULL,NULL,0,0); 524 if (out2 != NULL) 525 { 521 if (out2 != NULL) { 526 522 psError(PS_ERR_UNKNOWN, true,"psImageRoll did not return NULL though input image was NULL!?"); 527 523 return 2; … … 567 563 } 568 564 569 570 // testImageRotate() 565 // test psImageRotate() 571 566 if (1) { 572 567 psMemId id = psMemGetId(); … … 599 594 psImage *sImg = psImageAlloc(cols,rows,PS_TYPE_S16); 600 595 601 for(psS32 row=0;row<rows;row++) 602 { 596 for(psS32 row=0;row<rows;row++) { 603 597 psF32 *fRow = fImg->data.F32[row]; 604 598 psS16 *sRow = sImg->data.S16[row]; … … 612 606 // is to verify the results manually and bless it for automated comparison 613 607 // thereafter 614 615 608 616 609 // write results of various rotates to a file and verify with truth images … … 796 789 } 797 790 //HERE 798 // Verify the returned psImage structure pointer is nulland program799 // execution doesn't stop, if the input parameter input is null.791 // Verify the returned psImage structure pointer is NULL and program 792 // execution doesn't stop, if the input parameter input is NULL. 800 793 // Following should be an error 801 794 // XXX: Verify error … … 803 796 ok(fOut == NULL, "NULL was returned when the input image was NULL"); 804 797 805 // Verify the returned psImage structure pointer is nulland program798 // Verify the returned psImage structure pointer is NULL and program 806 799 // execution doesn't stop, if the specified interpolation mode is unallowed 807 800 // Following should be an error for unallowed interpolation type … … 882 875 ok(fRecycle == fOut, "psImageShift did recycle my image"); 883 876 884 // Verify the returned psImage structure pointer is nulland program885 // execution doesn't stop, if the input psImage structure pointer is null.877 // Verify the returned psImage structure pointer is NULL and program 878 // execution doesn't stop, if the input psImage structure pointer is NULL. 886 879 // Following should be an error 887 880 // XXX: Verify error … … 889 882 ok(fOut == NULL, "psImageShift did return NULL given a NULL input image"); 890 883 891 // Verify the returned psImage structure is nulland program execution884 // Verify the returned psImage structure is NULL and program execution 892 885 // doesn't stop, if the specified interpolation mode is unallowed. 893 886 // Following should be an error for unallowed interpolation mode … … 901 894 902 895 903 // test ImageResample()896 // test psImageResample() 904 897 if (1) { 905 898 psMemId id = psMemGetId(); 906 907 899 psS32 rows = 60; 908 900 psS32 cols = 80; … … 911 903 psErr *err; 912 904 913 psImage *image = psImageAlloc(cols,rows,PS_TYPE_F32); 914 for(psS32 row=0;row<rows;row++) 915 { 916 psF32 *imageRow = image->data.F32[row]; 917 for (psS32 col=0;col<cols;col++) { 918 imageRow[col] = row+2*col; 905 psImage *image = psImageAlloc(cols, rows, PS_TYPE_F32); 906 for(psS32 row=0;row<rows;row++) { 907 for (psS32 col=0;col<cols;col++) { 908 image->data.F32[row][col] = row+2*col; 919 909 } 920 910 } … … 925 915 ok(result == orig, "psImageResample() recycled image"); 926 916 ok(result->type.type == PS_TYPE_F32, "psImageResample() produced the correct type"); 927 928 929 917 ok(result->numCols == image->numCols*scale && result->numRows == image->numRows*scale, 930 918 "psImageResample() produced the correct size"); 931 932 919 933 920 bool errorFlag = false; … … 939 926 psMaskType maskVal; 940 927 psF32 truthValue; 941 for(psS32 row=0;row<result->numRows;row++) 942 { 928 for(psS32 row=0;row<result->numRows;row++) { 943 929 for (psS32 col=0;col<result->numCols;col++) { 944 930 // truthValue = psImagePixelInterpolate(image, … … 961 947 ok(!errorFlag, "psImageResample() produced the correct data values"); 962 948 963 // verify that image= nullis handled properly.949 // verify that image=NULL is handled properly. 964 950 psErrorClear(); 965 951 result = psImageResample(result,NULL,scale,PS_INTERPOLATE_FLAT); … … 1002 988 1003 989 1004 // test ImageTransform()990 // test psImageTransform() 1005 991 if (1) { 1006 992 psMemId id = psMemGetId(); … … 1013 999 1014 1000 psImage *in = psImageAlloc(cols,rows,PS_TYPE_F32); 1015 for (psS32 row=0;row<rows;row++) 1016 { 1017 psF32 *inRow = in->data.F32[row]; 1018 for (psS32 col=0;col<cols;col++) { 1019 inRow[col] = (psF32)row+(psF32)col/1000.0f; 1001 for (psS32 row=0;row<rows;row++) { 1002 for (psS32 col=0;col<cols;col++) { 1003 in->data.F32[row][col] = (psF32)row+(psF32)col/1000.0f; 1020 1004 } 1021 1005 } 1022 1006 P_PSIMAGE_SET_COL0(in, 1); 1023 psImage *out = psImageTransform(NULL, 1024 NULL, 1025 in, 1026 NULL, 1027 0, 1028 trans, 1029 psRegionSet(1,1+cols*2,0,rows*2), 1030 NULL, 1031 PS_INTERPOLATE_FLAT, 1032 -1); 1007 psImage *out = psImageTransform(NULL, NULL, in, NULL, 0, trans, 1008 psRegionSet(1,1+cols*2,0,rows*2), NULL, 1009 PS_INTERPOLATE_FLAT, -1); 1033 1010 1034 1011 ok(out != NULL, "psImageTransform() returned non-NULL"); … … 1036 1013 ok(out->numRows == rows*2 && out->numCols == cols*2, "psImageTransform() produced the correct size"); 1037 1014 1038 if ( 0) {1015 if (1) { 1039 1016 psMemId id = psMemGetId(); 1040 1017 psImageInterpolateOptions *tmpIntOpts = psImageInterpolateOptionsAlloc( … … 1045 1022 psMaskType maskVal; 1046 1023 bool errorFlag = false; 1047 for (psS32 row=0;row<out->numRows;row++) 1048 { 1049 psF32 *outRow = out->data.F32[row]; 1024 for (psS32 row=0;row<out->numRows;row++) { 1050 1025 for (psS32 col=0;col<cols;col++) { 1051 1026 psImageInterpolate(&imgVal, &varVal, &maskVal, … … 1054 1029 tmpIntOpts); 1055 1030 float inValue = imgVal; 1056 if (fabsf(outRow[col] - inValue) > 0.01) { 1057 diag("out at %d,%d was %g, expected %g", col,row,outRow[col], inValue); 1031 if (fabsf(out->data.F32[row][col] - inValue) > 0.01) { 1032 diag("out at %d,%d was %g, expected %g", col,row, 1033 out->data.F32[row][col], inValue); 1058 1034 errorFlag = true; 1059 1035 } -
trunk/psLib/test/imageops/tap_psImageMaskOps.c
r11729 r13123 3 3 * @brief Contains the tests for psMaskOps.[ch] 4 4 * 5 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $6 * @date $Date: 2007-0 2-09 20:40:22$5 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2007-05-02 04:14:33 $ 7 7 * 8 8 * XXX: In general, the image tests with (1, N) and (N, 1) failed and have … … 721 721 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 722 722 } 723 // XXX: These seg fault 723 724 if (0) genericImageMaskCircleTest(N, 1, N/2, 1, N/4); 724 725 if (0) genericImageMaskCircleTest(1, N, 1, N/2, N/4); … … 734 735 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 735 736 } 737 // XXX: These seg fault 736 738 if (0) genericImageKeepCircleTest(N, 1, N/2, 1, N/4); 737 739 if (0) genericImageKeepCircleTest(1, N, 1, N/2, N/4); -
trunk/psLib/test/imageops/tap_psImagePixelExtract.c
r13042 r13123 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1. 3$ $Name: not supported by cvs2svn $9 * @date $Date: 2007-0 4-26 22:18:03 $8 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2007-05-02 04:14:33 $ 10 10 * 11 11 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 17 17 #include "pstap.h" 18 18 19 psS32 main( psS32 argc, char* argv[])19 psS32 main(psS32 argc, char* argv[]) 20 20 { 21 21 psLogSetFormat("HLNM"); … … 23 23 plan_tests(248); 24 24 25 // test ImageSlice()25 // test psImageSlice() 26 26 { 27 27 psMemId id = psMemGetId(); … … 31 31 const psS32 n = r / 4 -1; 32 32 psImage* image; 33 psPixels* positions = psPixelsAlloc( r);34 psImage* mask = psImageAlloc( c, r, PS_TYPE_MASK);35 psStats* stat = psStatsAlloc( PS_STAT_SAMPLE_MEDIAN);33 psPixels* positions = psPixelsAlloc(r); 34 psImage* mask = psImageAlloc(c, r, PS_TYPE_MASK); 35 psStats* stat = psStatsAlloc(PS_STAT_SAMPLE_MEDIAN); 36 36 37 37 … … 46 46 // cases should be used for each possible direction. Data region cases 47 47 // should include 0x0, 1x1, Nx1, 1xN, NxN, MxN 48 for ( psS32 row = 0;row < r;row++) {48 for (psS32 row = 0;row < r;row++) { 49 49 psMaskType* maskRow = mask->data.PS_TYPE_MASK_DATA[row]; 50 for ( psS32 col = 0;col < c;col++) {51 maskRow[ col] = 0;50 for (psS32 col = 0;col < c;col++) { 51 maskRow[col] = 0; 52 52 } 53 53 } … … 58 58 psVector* out = NULL; \ 59 59 bool errorFlag = false; \ 60 image = psImageAlloc( c, r, PS_TYPE_##TYPE); \61 for ( psS32 row = 0;row < r;row++) { \62 ps##TYPE *imageRow = image->data.TYPE[ row]; \60 image = psImageAlloc(c, r, PS_TYPE_##TYPE); \ 61 for (psS32 row = 0;row < r;row++) { \ 62 ps##TYPE *imageRow = image->data.TYPE[row]; \ 63 63 ps##TYPE rowOffset = row * 2; \ 64 for ( psS32 col = 0;col < c;col++) { \65 imageRow[ col] = col + rowOffset; \64 for (psS32 col = 0;col < c;col++) { \ 65 imageRow[col] = col + rowOffset; \ 66 66 } \ 67 67 } \ … … 111 111 // 112 112 #define PSIMAGESLICE_TEST(TYPE) \ 113 PSIMAGESLICE_TEST1(TYPE, m, n, PS_CUT_X_POS, m, i, n / 2, 0 ); \114 PSIMAGESLICE_TEST1(TYPE, m, n, PS_CUT_X_NEG, m, m - 1 - i, n / 2, 1 ); \115 PSIMAGESLICE_TEST1(TYPE, m, n, PS_CUT_Y_POS, n, m / 2, i, 2 ); \116 PSIMAGESLICE_TEST1(TYPE, m, n, PS_CUT_Y_NEG, n, m / 2, n - 1 - i, 3 ); \113 PSIMAGESLICE_TEST1(TYPE, m, n, PS_CUT_X_POS, m, i, n / 2, 0); \ 114 PSIMAGESLICE_TEST1(TYPE, m, n, PS_CUT_X_NEG, m, m - 1 - i, n / 2, 1); \ 115 PSIMAGESLICE_TEST1(TYPE, m, n, PS_CUT_Y_POS, n, m / 2, i, 2); \ 116 PSIMAGESLICE_TEST1(TYPE, m, n, PS_CUT_Y_NEG, n, m / 2, n - 1 - i, 3); \ 117 117 \ 118 PSIMAGESLICE_TEST1(TYPE, m, 1, PS_CUT_X_POS, m, i, 0, 4 ); \119 PSIMAGESLICE_TEST1(TYPE, m, 1, PS_CUT_X_NEG, m, m - 1 - i, 0, 5 ); \120 PSIMAGESLICE_TEST1(TYPE, m, 1, PS_CUT_Y_POS, 1, m / 2, 0, 6 ); \121 PSIMAGESLICE_TEST1(TYPE, m, 1, PS_CUT_Y_NEG, 1, m / 2, 0, 7 ); \118 PSIMAGESLICE_TEST1(TYPE, m, 1, PS_CUT_X_POS, m, i, 0, 4); \ 119 PSIMAGESLICE_TEST1(TYPE, m, 1, PS_CUT_X_NEG, m, m - 1 - i, 0, 5); \ 120 PSIMAGESLICE_TEST1(TYPE, m, 1, PS_CUT_Y_POS, 1, m / 2, 0, 6); \ 121 PSIMAGESLICE_TEST1(TYPE, m, 1, PS_CUT_Y_NEG, 1, m / 2, 0, 7); \ 122 122 \ 123 PSIMAGESLICE_TEST1(TYPE, 1, n, PS_CUT_X_POS, 1, 0, n / 2, 8 ); \124 PSIMAGESLICE_TEST1(TYPE, 1, n, PS_CUT_X_NEG, 1, 0, n / 2, 9 ); \125 PSIMAGESLICE_TEST1(TYPE, 1, n, PS_CUT_Y_POS, n, 0, i, 10 ); \126 PSIMAGESLICE_TEST1(TYPE, 1, n, PS_CUT_Y_NEG, n, 0, n - 1 - i, 11 ); \123 PSIMAGESLICE_TEST1(TYPE, 1, n, PS_CUT_X_POS, 1, 0, n / 2, 8); \ 124 PSIMAGESLICE_TEST1(TYPE, 1, n, PS_CUT_X_NEG, 1, 0, n / 2, 9); \ 125 PSIMAGESLICE_TEST1(TYPE, 1, n, PS_CUT_Y_POS, n, 0, i, 10); \ 126 PSIMAGESLICE_TEST1(TYPE, 1, n, PS_CUT_Y_NEG, n, 0, n - 1 - i, 11); \ 127 127 \ 128 PSIMAGESLICE_TEST1(TYPE, 1, 1, PS_CUT_X_POS, 1, 0, 0, 12 ); \129 PSIMAGESLICE_TEST1(TYPE, 1, 1, PS_CUT_X_NEG, 1, 0, 0, 13 ); \130 PSIMAGESLICE_TEST1(TYPE, 1, 1, PS_CUT_Y_POS, 1, 0, 0, 14 ); \131 PSIMAGESLICE_TEST1(TYPE, 1, 1, PS_CUT_Y_NEG, 1, 0, 0, 15 ); \128 PSIMAGESLICE_TEST1(TYPE, 1, 1, PS_CUT_X_POS, 1, 0, 0, 12); \ 129 PSIMAGESLICE_TEST1(TYPE, 1, 1, PS_CUT_X_NEG, 1, 0, 0, 13); \ 130 PSIMAGESLICE_TEST1(TYPE, 1, 1, PS_CUT_Y_POS, 1, 0, 0, 14); \ 131 PSIMAGESLICE_TEST1(TYPE, 1, 1, PS_CUT_Y_NEG, 1, 0, 0, 15); \ 132 132 133 133 PSIMAGESLICE_TEST(F32); … … 149 149 psRegionSet(c/10, c/10 + 1, r/10, r/10 + 1), 150 150 PS_CUT_X_POS, 151 stat );151 stat); 152 152 ok(out == NULL, "psImageSlice() returned NULL with NULL input"); 153 153 … … 156 156 // Following should be an error 157 157 // XXX: Verify error 158 out = psImageSlice( out,158 out = psImageSlice(out, 159 159 NULL, image, 160 160 mask, 1, 161 161 psRegionSet(c/10, c/10 + 1, r/10, r/10 + 1), 162 162 PS_CUT_X_POS, 163 NULL );163 NULL); 164 164 ok(out == NULL, "psImageSlice() returned NULL with NULL psStats"); 165 psError( PS_ERR_UNKNOWN,true, "Giving a NULL stat struct, psImageSlice didn't return NULL as expected");165 psError(PS_ERR_UNKNOWN,true, "Giving a NULL stat struct, psImageSlice didn't return NULL as expected"); 166 166 167 167 // Verify the returned psVector structure pointer is null and program … … 182 182 // Following should be an error 183 183 // XXX: Verify error 184 out = psImageSlice( out,184 out = psImageSlice(out, 185 185 NULL, 186 186 image, … … 188 188 psRegionSet(c/10, c/10, r/10, r/10), 189 189 PS_CUT_X_POS, 190 stat );190 stat); 191 191 ok(out == NULL, "psImageSlice() returned NULL with 0x0 region"); 192 192 … … 196 196 // Following should be an error 197 197 // XXX: Verify error 198 out = psImageSlice( out, NULL,198 out = psImageSlice(out, NULL, 199 199 image, 200 200 mask, 1, 201 201 psRegionSet(c+1, c+2, r/10, r/10 + 10), 202 202 PS_CUT_X_POS, 203 stat );203 stat); 204 204 ok(out == NULL, "psImageSlice() returned NULL with unallowed x position"); 205 205 206 206 // Following should be an error 207 207 // XXX: Verify error 208 out = psImageSlice( out, NULL,208 out = psImageSlice(out, NULL, 209 209 image, 210 210 mask, 1, 211 211 psRegionSet(c/10, c/10 + 1, r+1,r+5), 212 212 PS_CUT_X_POS, 213 stat );213 stat); 214 214 ok(out == NULL, "psImageSlice() returned NULL with unallowed y position"); 215 215 216 216 // Following should be an error 217 217 // XXX: Verify error 218 out = psImageSlice( out, NULL,218 out = psImageSlice(out, NULL, 219 219 image, 220 220 mask, 1, … … 226 226 // Following should be an error 227 227 // XXX: Verify error 228 out = psImageSlice( out, NULL,228 out = psImageSlice(out, NULL, 229 229 image, 230 230 mask, 1, … … 240 240 // XXX: Verify error 241 241 stat->options = 0; 242 out = psImageSlice( out, NULL,242 out = psImageSlice(out, NULL, 243 243 image, 244 244 mask, 1, … … 253 253 // XXX: Verify error 254 254 stat->options = PS_STAT_SAMPLE_MEDIAN; 255 psImage* maskSz = psImageAlloc( r, c, PS_TYPE_MASK);256 out = psImageSlice( out, NULL,255 psImage* maskSz = psImageAlloc(r, c, PS_TYPE_MASK); 256 out = psImageSlice(out, NULL, 257 257 image, 258 258 maskSz, 1, … … 265 265 // Following should be an error unallowed mask type 266 266 // XXX: Verify error 267 psImage* maskS8 = psImageAlloc( c, r, PS_TYPE_S8);268 out = psImageSlice( out, NULL,267 psImage* maskS8 = psImageAlloc(c, r, PS_TYPE_S8); 268 out = psImageSlice(out, NULL, 269 269 image, 270 270 maskS8, 1, … … 276 276 //Added tests after subimage changes. 277 277 psFree(image); 278 image = psImageAlloc( c, r, PS_TYPE_F64);279 for ( psS32 row = 0;row < r;row++) {280 psF64 *imageRow = image->data.F64[ row];278 image = psImageAlloc(c, r, PS_TYPE_F64); 279 for (psS32 row = 0;row < r;row++) { 280 psF64 *imageRow = image->data.F64[row]; 281 281 psF64 rowOffset = row * 2; 282 for ( psS32 col = 0;col < c;col++) {283 imageRow[ col] = col + rowOffset;282 for (psS32 col = 0;col < c;col++) { 283 imageRow[col] = col + rowOffset; 284 284 } 285 285 } … … 441 441 float y = (float)startRow[n]+(float)i*deltaRow; 442 442 if (n == 1) { 443 // truth = psImagePixelInterpolate( image, x, y,443 // truth = psImagePixelInterpolate(image, x, y, 444 444 // NULL,0,0,PS_INTERPOLATE_FLAT); 445 445 psImageInterpolate(&imgVal, &varVal, &maskVal, x, y, tmpIntOptsNoMask); 446 446 truth = imgVal; 447 447 } else { 448 // truth = psImagePixelInterpolate( image, x, y,448 // truth = psImagePixelInterpolate(image, x, y, 449 449 // mask,1,0,PS_INTERPOLATE_FLAT); 450 450 psImageInterpolate(&imgVal, &varVal, &maskVal, x, y, tmpIntOptsMask); … … 520 520 521 521 522 // test ImageRadialCut()522 // test psImageRadialCut() 523 523 { 524 524 psMemId id = psMemGetId(); … … 557 557 if (fabs(result->data.F64[i] - (15.0+i*10)) > 1) { 558 558 diag("Result was not as expected for radii #%d (%g, expected %d +/- 1)", 559 result->data.F64[i], (15.0+i*10) );559 result->data.F64[i], (15.0+i*10)); 560 560 errorFlag = true; 561 561 } … … 574 574 if (fabs(result->data.F64[i] - (15.0+i*10)) > 1) { 575 575 diag("Result was not as expected for radii #%d (%g, expected %d +/- 1)", 576 result->data.F64[i], (15.0+i*10) );576 result->data.F64[i], (15.0+i*10)); 577 577 errorFlag = true; 578 578 } … … 709 709 // Following should generate error message(for row) 710 710 // XXX: Verify error 711 out = psImageRow(NULL, image, num);711 out = psImageRow(NULL, NULL, num); 712 712 ok(out == NULL, "psImageRow() returned NULL with NULL input image"); 713 713 714 714 // Following should generate error message(for col) 715 715 // XXX: Verify error 716 out = psImageCol(NULL, image, num);716 out = psImageCol(NULL, NULL, num); 717 717 ok(out == NULL, "psImagecol() returned NULL with NULL input image"); 718 719 718 image = psImageAlloc(3, 3, PS_TYPE_F64); 720 719 721 720 722 721 //Test for unallowed row0. 723 *(psS32*)&(image->row0) = -1;722 P_PSIMAGE_SET_ROW0(image, -2); 724 723 // Following should generate error message(for row) 725 724 // XXX: Verify error … … 810 809 811 810 //Test valid cases. 811 //XXX: We do not verify the data values. 812 812 P_PSIMAGE_SET_COL0(image, 10); 813 813 P_PSIMAGE_SET_ROW0(image, 5); … … 875 875 876 876 //Test for error with NULL image 877 empty = psImageCol(empty, emptyImage, 0);877 empty = psImageCol(empty, NULL, 0); 878 878 ok(empty == NULL, "psImageCol returned NULL for NULL image input"); 879 879 //Test for error with Out of Range Row … … 894 894 test1 = fabs(rowcol->data.F64[0]-66.6); 895 895 test2 = fabs(rowcol->data.F64[2]-666.66); 896 ok(!( (test1>TOLTST) || (test2>TOLTST)),896 ok(!((test1>TOLTST) || (test2>TOLTST)), 897 897 "psImageRow returned correct values"); 898 898 psFree(rowcol); -
trunk/psLib/test/imageops/tap_psImagePixelManip.c
r12440 r13123 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1. 6$ $Name: not supported by cvs2svn $9 * @date $Date: 2007-0 3-14 21:20:28$8 * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2007-05-02 04:14:33 $ 10 10 * 11 11 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 22 22 psLogSetFormat("HLNM"); 23 23 psLogSetLevel(PS_LOG_INFO); 24 plan_tests( 47);25 26 // test ImageClip()24 plan_tests(107); 25 26 // test psImageClip() 27 27 { 28 28 psMemId id = psMemGetId(); … … 44 44 // Verify the retuned integer is zero, psImage structure input is unmodified 45 45 // and program executions doesn't stop, if input parameter psImage structure 46 // pointer is null.46 // pointer is NULL. 47 47 // 48 48 // Verify the retuned integer is zero, psImage structure input is unmodified … … 111 111 // Verify the retuned integer is zero, psImage structure input is unmodified 112 112 // and program executions doesn't stop, if input parameter psImage structure 113 // pointer is null.113 // pointer is NULL. 114 114 retVal = psImageClip(NULL,min,-1.0f,max,-2.0f); 115 115 ok(retVal == 0, "Expected zero return for clips of a NULL image"); … … 144 144 // 145 145 // Verify the returned integer is zero and program execution doesn't stop, 146 // if the input parameter psImage structure pointer is null.146 // if the input parameter psImage structure pointer is NULL. 147 147 // create image 148 148 #define testImageClipNaNByType(datatype) \ … … 193 193 // Verify the retuned integer is zero, psImage structure input is unmodified 194 194 // and program executions doesn't stop, if input parameter psImage structure 195 // pointer is null.195 // pointer is NULL. 196 196 retVal = psImageClipNaN(NULL,-1.0f); 197 197 ok(retVal == 0, "Expected zero return for clips of a NULL image"); … … 286 286 testOverlayTypeOP(DATATYPE,=,"="); 287 287 288 289 // testOverlayType(F64); 290 // testOverlayType(F32); 291 // testOverlayType(S16); 292 // testOverlayType(S8); 293 // testOverlayType(U16); 294 // testOverlayType(U8); 288 testOverlayType(F64); 289 testOverlayType(F32); 290 testOverlayType(S16); 291 testOverlayType(S8); 292 testOverlayType(U16); 293 testOverlayType(U8); 295 294 296 295 // Verify the returned integer is equal to non-zero and the input psImage structure … … 351 350 // Verify the returned integer is equal to non-zero, the input psImage 352 351 // structure is unmodified and program execution doesn't stop, if the 353 // overlay specified is null.352 // overlay specified is NULL. 354 353 // Following should error as overlay is NULL 355 354 // XXX: Verify error … … 371 370 372 371 // Verify the returned integer is equal to non-zero and program execution 373 // doesn't stop, if the input parameter image is null.372 // doesn't stop, if the input parameter image is NULL. 374 373 // Following should error as image input is NULL 375 374 // XXX: Verify error … … 416 415 ok(retVal != 0, "psImageOverlaySection returned non-zero when checking divide-by-zero"); 417 416 errorFlag = false; 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 417 449 418 for (unsigned row=0;row<r;row++) -
trunk/psLib/test/imageops/tap_psImageStats.c
r11729 r13123 273 273 const int CHEBY_Y_DIM = 8; 274 274 const int THRESHOLD = 1; 275 psImage *imgIn = psImageAlloc( IMAGE_SIZE, IMAGE_SIZE, PS_TYPE_F32);276 psImage *imgOut = psImageAlloc( IMAGE_SIZE, IMAGE_SIZE, PS_TYPE_F32);277 for (int i = 0;i < IMAGE_SIZE;i++ ) {278 for (int j = 0;j < IMAGE_SIZE;j++ ) {275 psImage *imgIn = psImageAlloc(IMAGE_SIZE, IMAGE_SIZE, PS_TYPE_F32); 276 psImage *imgOut = psImageAlloc(IMAGE_SIZE, IMAGE_SIZE, PS_TYPE_F32); 277 for (int i = 0;i < IMAGE_SIZE;i++) { 278 for (int j = 0;j < IMAGE_SIZE;j++) { 279 279 imgIn->data.F32[ i ][ j ] = 4.0; 280 imgIn->data.F32[ i ][ j ] = ( float ) ( i + j);281 imgIn->data.F32[ i ][ j ] = ( float ) ( i + j ) + ( 4.0 * ( float ) i);280 imgIn->data.F32[ i ][ j ] = (float) (i + j); 281 imgIn->data.F32[ i ][ j ] = (float) (i + j) + (4.0 * (float) i); 282 282 imgOut->data.F32[ i ][ j ] = 0.0; 283 283 } 284 284 } 285 285 psPolynomial2D *my2DPoly = psPolynomial2DAlloc(PS_POLYNOMIAL_CHEB, CHEBY_X_DIM-1, CHEBY_Y_DIM-1); 286 my2DPoly = psImageFitPolynomial(my2DPoly, imgIn );286 my2DPoly = psImageFitPolynomial(my2DPoly, imgIn); 287 287 ok(my2DPoly != NULL, "psImageFitPolynomial() returned non-NULL"); 288 288 289 imgOut = psImageEvalPolynomial( imgOut, my2DPoly);289 imgOut = psImageEvalPolynomial(imgOut, my2DPoly); 290 290 bool errorFlag = false; 291 for (int i = 0;i < IMAGE_SIZE;i++ ) {292 for (int j = 0;j < IMAGE_SIZE;j++ ) {293 if ( fabs( imgOut->data.F32[ i ][ j ] - imgIn->data.F32[ i ][ j ] ) > THRESHOLD) {291 for (int i = 0;i < IMAGE_SIZE;i++) { 292 for (int j = 0;j < IMAGE_SIZE;j++) { 293 if (fabs(imgOut->data.F32[ i ][ j ] - imgIn->data.F32[ i ][ j ]) > THRESHOLD) { 294 294 diag("Pixel (%d, %d) is %.2f, should be %.2f\n", i, j, 295 295 imgOut->data.F32[ i ][ j ], … … 357 357 ok(hist2 == hist, "psImageHistogram() correctly recycled the input psHistogram"); 358 358 bool errorFlag = false; 359 for (int i = 0;i < numBins;i++ ) {359 for (int i = 0;i < numBins;i++) { 360 360 if (hist2->nums->data.F32[i] != (numCols * (numRows/numBins))) { 361 361 diag("ERROR: Bin number %d bounds: (%.1f - %.1f) data (%.2f)\n", i, … … 434 434 } 435 435 436 // Ensure psImageCountPixelMask returns -1 for NULL input image436 // Ensure psImageCountPixelMask returns -1 for wrong input image type 437 437 // Following should generate error 438 438 // XXX: Verify error … … 486 486 // -------------------------------------------------------------- 487 487 // psImageStats() 488 // Ensure psImageStats() return es NULL for NULL input image488 // Ensure psImageStats() returns NULL for NULL input image 489 489 // Following should generate error 490 490 // XXX: Verify error … … 499 499 } 500 500 501 // Ensure psImageStats() return es NULL for NULL psStats501 // Ensure psImageStats() returns NULL for NULL psStats 502 502 // Following should generate error 503 503 // XXX: Verify error -
trunk/psLib/test/imageops/tap_psImageStructManip.c
r11688 r13123 1 /** @file t st_psImageExtraction.c1 /** @file tap_psImageStructManip.c 2 2 * 3 3 * @brief Contains the tests for psImageExtraction.[ch] 4 4 * 5 *6 5 * @author Robert DeSonia, MHPCC 7 6 * 8 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $9 * @date $Date: 2007-0 2-08 01:21:50$7 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2007-05-02 04:14:33 $ 10 9 * 11 10 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 26 25 // psImageSubset shall create child image of a specified size from a 27 26 // parent psImage structure 28 29 27 // psImageSubset() 30 28 { … … 33 31 psS32 c = 128; 34 32 psS32 r = 256; 35 psRegion region1 = psRegionSet(0, c/2,0,r/2);36 psRegion region2 = psRegionSet(c/4, c/4+c/2,r/4,r/4+r/2);33 psRegion region1 = psRegionSet(0, c/2, 0, r/2); 34 psRegion region2 = psRegionSet(c/4, c/4+c/2, r/4, r/4+r/2); 37 35 38 36 psImage* original = psImageAlloc(c,r,PS_TYPE_U32); 39 for (psS32 row=0;row<r;row++) 40 { 37 for (psS32 row=0;row<r;row++) { 41 38 for (psS32 col=0;col<c;col++) { 42 39 original->data.F32[row][col] = row*1000+col; … … 63 60 64 61 bool errorFlag = false; 65 for (psS32 row=0;row<r/2;row++) 66 { 62 for (psS32 row=0;row<r/2;row++) { 67 63 for (psS32 col=0;col<c/2;col++) { 68 64 if (subset2->data.U32[row][col] != original->data.U32[row+r/4][col+c/4]) { … … 99 95 ok(subset2->children == NULL && subset3->children == NULL, "psImageSubset() set ->children correctly"); 100 96 101 102 97 // Verify the input psImage structure image only has the following members 103 98 // changed: 1) Nchildren is increased by one. 2) parent contains pointer psImage structure … … 107 102 "psImageSubset did properly store the children pointers."); 108 103 104 109 105 // Verify the returned psImage structure pointer is null and program 110 106 // execution doesn't stop, if the input parameter image is null. … … 114 110 psImage* subset1 = psImageSubset(NULL,region1); 115 111 ok(subset1 == NULL, "psImageSubset returned NULL when input image was NULL."); 112 116 113 117 114 // Verify the returned psImage structure pointer is null and program … … 153 150 ok(subset1 == NULL, 154 151 "psImageSubset returned NULL when subset origin was outside of image (row0=-1)"); 152 155 153 156 154 // Verify the returned psImage structure pointer is null and program … … 205 203 psU32 r = 256; 206 204 207 psImage* img = psImageAlloc(c,r,PS_TYPE_F32); 208 for (unsigned row=0;row<r;row++) 209 { 210 psF32* imgRow = img->data.F32[row]; 205 psImage *img = psImageAlloc(c,r,PS_TYPE_F32); 206 for (unsigned row=0;row<r;row++) { 211 207 for (unsigned col=0;col<c;col++) { 212 imgRow[col] = (psF32)(row+col); 213 } 214 } 215 psImage* img2 = psImageAlloc(c,r,PS_TYPE_F32); 216 for (unsigned row=0;row<r;row++) 217 { 218 psF32* img2Row = img2->data.F32[row]; 208 img->data.F32[row][col] = (psF32)(row+col); 209 } 210 } 211 psImage *img2 = psImageAlloc(c,r,PS_TYPE_F32); 212 for (unsigned row=0;row<r;row++) { 219 213 for (unsigned col=0;col<c;col++) { 220 img2Row[col] = 0.0f; 221 } 222 } 223 224 psImage* img3 = psImageCopy(img2,img,PS_TYPE_F32); 225 // Verify the returned psImage structure pointer is equal to the input parameter output. 214 img2->data.F32[row][col] = 0.0f; 215 } 216 } 217 218 psImage *img3 = psImageCopy(img2,img,PS_TYPE_F32); 219 // Verify the returned psImage structure pointer is equal to the input 220 // parameter output. 226 221 ok(img2 == img3, "psImageCopy(): recycled input image"); 227 222 228 // Verify the returned psImage structure is the same type as the input image structure229 // if the specified output argument is NULL.230 psImage *img4 = psImageCopy(NULL,img,PS_TYPE_F32);223 // Verify the returned psImage structure is the same type as the input image 224 // structure if the specified output argument is NULL. 225 psImage *img4 = psImageCopy(NULL,img,PS_TYPE_F32); 231 226 ok(img4 != NULL, "psImageCopy() returned non-NULL with NULL output argument"); 232 227 ok(img4->type.type == img->type.type, "psImageCopy() set the correct image type"); 233 228 bool errorFlag = false; 234 for (psU32 row=0;row<r;row++) 235 { 229 for (psU32 row=0;row<r;row++) { 236 230 psF32* imgInRow = img->data.F32[row]; 237 231 psF32* imgOutRow = img4->data.F32[row]; … … 326 320 psS32 halfR = r/2; 327 321 psS32 halfC = c/2; 328 psRegion centerHalf = {qtrC, qtrC+halfC,qtrR,qtrR+halfR};322 psRegion centerHalf = {qtrC, qtrC+halfC, qtrR, qtrR+halfR}; 329 323 330 324 psImage* image = psImageAlloc(c,r,PS_TYPE_F32); 331 for (psS32 row = 0; row < image->numRows; row++) 332 { 325 for (psS32 row = 0; row < image->numRows; row++) { 333 326 for (psS32 col = 0; col < image->numCols; col++) { 334 327 image->data.F32[row][col] = (psF32)col + (psF32)row/1000.0f; 335 328 } 336 329 } 337 338 330 // invoke psImageTrim with non-NULL image, and a valid region 339 331 // x0,y0->x1,y1 (using only positive values). Verify that: … … 350 342 351 343 bool errorFlag = false; 352 for (psS32 row = 0; row < image2->numRows; row++) 353 { 344 for (psS32 row = 0; row < image2->numRows; row++) { 354 345 for (psS32 col = 0; col < image2->numCols; col++) { 355 346 if (fabsf(image2->data.F32[row][col] - image->data.F32[row+qtrR][col+qtrC]) … … 379 370 image->numCols-qtrC, image->numRows-qtrR); 380 371 381 for (psS32 row = 0; row < image2->numRows; row++) 382 { 372 for (psS32 row = 0; row < image2->numRows; row++) { 383 373 for (psS32 col = 0; col < image2->numCols; col++) { 384 374 if (fabsf(image2->data.F32[row][col] - … … 394 384 ok(!errorFlag, "psImageTrim() set image data correctly"); 395 385 396 // 4. invoke psImageTrim with x1<0, y1<0. Verify: 386 387 // Invoke psImageTrim with x1<0, y1<0. Verify: 397 388 // a. the psImage size is (numCols+x1)-x0 by (numRows+y1)-y0. 398 389 // b. the pixel values coorespond to the region … … 405 396 image2->numCols, image2->numRows, 406 397 image->numCols-qtrC, image->numRows-qtrR); 407 408 for (psS32 row = 0; row < image2->numRows; row++) 409 { 398 for (psS32 row = 0; row < image2->numRows; row++) { 410 399 for (psS32 col = 0; col < image2->numCols; col++) { 411 400 if (fabsf(image2->data.F32[row][col] - … … 422 411 psFree(image1); 423 412 424 // 6. invoke psImageTrim with image=NULL Verify: 413 414 // Invoke psImageTrim with image=NULL Verify: 425 415 // a. execution does not cease. 426 416 // b. return value is NULL … … 428 418 // An error should follow... 429 419 // XXX: Verify errors 430 431 432 420 image2 = psImageTrim(NULL, psRegionSet(qtrC,0,qtrR,0)); 433 421 ok(image2 == NULL, "psImageTrim returned NULL given a NULL input image"); … … 438 426 439 427 428 // Verify when psRegion has a coord at -1 440 429 image1 = psImageCopy(NULL,image,PS_TYPE_F32); 441 430 image2 = psImageTrim(image1, psRegionSet(-1,0,0,0)); … … 447 436 448 437 438 // Verify when psRegion has a coord at -1 449 439 image1 = psImageCopy(NULL,image,PS_TYPE_F32); 450 440 image2 = psImageTrim(image1, psRegionSet(0,0,-1,0)); … … 456 446 457 447 448 // Verify when psRegion has a coord at outside the image range 458 449 image1 = psImageCopy(NULL,image,PS_TYPE_F32); 459 450 image2 = psImageTrim(image1, psRegionSet(0,image->numCols+1,0,0)); … … 465 456 466 457 458 // Verify when psRegion has a coord at outside the image range 467 459 image1 = psImageCopy(NULL,image,PS_TYPE_F32); 468 460 image2 = psImageTrim(image1, psRegionSet(0,0,0,image->numRows+1)); … … 474 466 475 467 468 // Verify when psRegion has a coord at outside the image range 476 469 image1 = psImageCopy(NULL,image,PS_TYPE_F32); 477 470 image2 = psImageTrim(image1, psRegionSet(0,0,0,(((psF32)image->numRows)*-1.0))); … … 483 476 484 477 478 // Verify when psRegion has a coord at outside the image range 485 479 image1 = psImageCopy(NULL,image,PS_TYPE_F32); 486 480 image2 = psImageTrim(image1, psRegionSet(0,(((psF32)image->numCols)*-1.0),0,0));
Note:
See TracChangeset
for help on using the changeset viewer.
