Changeset 13123 for trunk/psLib/test/imageops/tap_psImagePixelExtract.c
- Timestamp:
- May 1, 2007, 6:14:33 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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);
Note:
See TracChangeset
for help on using the changeset viewer.
