Changeset 13614 for trunk/psLib/test/imageops/tap_psImageGeomManip.c
- Timestamp:
- Jun 4, 2007, 10:25:32 AM (19 years ago)
- File:
-
- 1 edited
-
trunk/psLib/test/imageops/tap_psImageGeomManip.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/imageops/tap_psImageGeomManip.c
r13123 r13614 5 5 * @author Robert DeSonia, MHPCC 6 6 * 7 * @version $Revision: 1. 8$ $Name: not supported by cvs2svn $8 * @date $Date: 2007-0 5-02 04:14:33$7 * @version $Revision: 1.9 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2007-06-04 20:25:32 $ 9 9 * 10 10 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 16 16 #include "pstap.h" 17 17 #define VERBOSE 0 18 19 void genericImageRollTest(int numRows, int numCols) 20 { 21 psMemId id = psMemGetId(); 22 psImage *in; 23 psImage *out; 24 psImage *out2; 25 26 // The function psImageRoll shall generate a new psImage structure by 27 // rolling the input image the correponding number of pixels in the vertical 28 // and/or horizontal direction. The image output image shall be the same size 29 // as the input image. Values which roll off the image are wrapped to the 30 // other side. 31 // 32 // Verify the returned psImage structure contains expected values, if the 33 // input image contains known values and the roll performed is known. 34 // Cases should include no roll, vertical roll, horizontal roll and 35 // combination vertical/horizontal rolls. Positive and negative rolls 36 // should be performed. 37 38 in = psImageAlloc(numCols,numRows,PS_TYPE_F32); 39 for (psS32 row=0;row<numRows;row++) { 40 for (psS32 col=0;col<numCols;col++) { 41 in->data.F32[row][col] = (psF32)row+(psF32)col/1000.0f; 42 } 43 } 44 45 out = psImageRoll(NULL,in,0,0); 46 bool errorFlag = false; 47 for (psS32 row=0;row<numRows;row++) { 48 psF32 *inRow = in->data.F32[row]; 49 psF32 *outRow = out->data.F32[row]; 50 for (psS32 col=0;col<numCols;col++) { 51 if (inRow[col] != outRow[col]) { 52 diag("psImageRoll didn't produce expected result " 53 "at %d,%d (%f vs %f) for dx=0, dy=0", 54 col,row,inRow[col],outRow[col]); 55 errorFlag = true; 56 } 57 } 58 } 59 ok(!errorFlag, "psImageRoll() produced the correct data values (no roll)"); 60 61 errorFlag = false; 62 out2 = psImageRoll(out,in,numCols/4,0); 63 for (psS32 row=0;row<numRows;row++) 64 { 65 psF32 *inRow = in->data.F32[row]; 66 psF32 *outRow = out->data.F32[row]; 67 for (psS32 col=0;col<numCols;col++) { 68 if (inRow[(col+numCols/4) % numCols] != outRow[col]) { 69 diag("psImageRoll didn't produce expected result " 70 "at %d,%d (%f vs %f) for dx=numCols/4, dy=0", 71 col,row,inRow[(col+numCols/4) % numCols],outRow[col]); 72 errorFlag = true; 73 } 74 } 75 } 76 ok(!errorFlag, "psImageRoll() produced the correct data values (column roll only"); 77 78 // Verify the returned psImage structure pointer is equal to the input 79 // parameter out if provided. 80 ok(out2 == out, "psImageRoll did recycle the out psImage"); 81 82 errorFlag = false; 83 out = psImageRoll(out,in,0,numRows/4); 84 for (psS32 row=0;row<numRows;row++) 85 { 86 psF32 *inRow = in->data.F32[(row+numRows/4)%numRows]; 87 psF32 *outRow = out->data.F32[row]; 88 for (psS32 col=0;col<numCols;col++) { 89 if (inRow[col] != outRow[col]) { 90 diag("psImageRoll didn't produce expected result " 91 "at %d,%d (%f vs %f) for dx=0, dy=numRows/4", 92 col,row,inRow[col],outRow[col]); 93 errorFlag = true; 94 } 95 } 96 } 97 ok(!errorFlag, "psImageRoll() produced the correct data values (row roll onlt)"); 98 99 errorFlag = false; 100 out = psImageRoll(out,in,numCols/4,numRows/4); 101 for (psS32 row=0;row<numRows;row++) 102 { 103 psF32 *inRow = in->data.F32[(row+numRows/4)%numRows]; 104 psF32 *outRow = out->data.F32[row]; 105 for (psS32 col=0;col<numCols;col++) { 106 if (inRow[(col+numCols/4) % numCols] != outRow[col]) { 107 diag("psImageRoll didn't produce expected result " 108 "at %d,%d (%f vs %f) for dx=numCols/4, dy=numRows/4", 109 col,row,inRow[(col+numCols/4) % numCols],outRow[col]); 110 errorFlag = true; 111 } 112 } 113 } 114 ok(!errorFlag, "psImageRoll() produced the correct data values (column and row roll)"); 115 116 errorFlag = false; 117 out = psImageRoll(out,in,-numCols/4,0); 118 for (psS32 row=0;row<numRows;row++) 119 { 120 psF32 *inRow = in->data.F32[row]; 121 psF32 *outRow = out->data.F32[row]; 122 for (psS32 col=0;col<numCols;col++) { 123 if (inRow[(col+(numCols-numCols/4)) % numCols] != outRow[col]) { 124 diag("psImageRoll didn't produce expected result " 125 "at %d,%d (%f vs %f) for dx=-numCols/4, dy=0", 126 col,row,inRow[(col+(numCols-numCols/4)) % numCols],outRow[col]); 127 errorFlag = true; 128 } 129 } 130 } 131 ok(!errorFlag, "psImageRoll() produced the correct data values (negative column roll)"); 132 133 errorFlag = false; 134 out = psImageRoll(out,in,0,-numRows/4); 135 for (psS32 row=0;row<numRows;row++) 136 { 137 psF32 *inRow = in->data.F32[(row+numRows-numRows/4)%numRows]; 138 psF32 *outRow = out->data.F32[row]; 139 for (psS32 col=0;col<numCols;col++) { 140 if (inRow[col] != outRow[col]) { 141 diag("psImageRoll didn't produce expected result " 142 "at %d,%d (%f vs %f) for dx=0, dy=-numRows/4", 143 col,row,inRow[col],outRow[col]); 144 errorFlag = true; 145 } 146 } 147 } 148 ok(!errorFlag, "psImageRoll() produced the correct data values (negative row roll)"); 149 150 errorFlag = false; 151 out = psImageRoll(out,in,-numCols/4,-numRows/4); 152 for (psS32 row=0;row<numRows;row++) 153 { 154 psF32 *inRow = in->data.F32[(row+numRows-numRows/4)%numRows]; 155 psF32 *outRow = out->data.F32[row]; 156 for (psS32 col=0;col<numCols;col++) { 157 if (inRow[(col+numCols-numCols/4) % numCols] != outRow[col]) { 158 diag("psImageRoll didn't produce expected result " 159 "at %d,%d (%f vs %f) for dx=numCols/4, dy=numRows/4", 160 col,row,inRow[(col+numCols-numCols/4) % numCols],outRow[col]); 161 errorFlag = true; 162 } 163 } 164 } 165 ok(!errorFlag, "psImageRoll() produced the correct data values (negative column and row roll)"); 166 psFree(in); 167 psFree(out); 168 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 169 } 170 171 18 172 19 173 bool testImageShiftCase(psS32 cols, … … 152 306 psLogSetFormat("HLNM"); 153 307 psLogSetLevel(PS_LOG_INFO); 154 plan_tests(2 37);308 plan_tests(280); 155 309 156 310 // test psImageRebin() … … 366 520 if (1) { 367 521 psMemId id = psMemGetId(); 522 // Perform generic tests with various image sizes 523 genericImageRollTest(8, 1); 524 genericImageRollTest(1, 8); 525 genericImageRollTest(8, 8); 526 genericImageRollTest(8, 16); 527 genericImageRollTest(16, 8); 528 368 529 psImage *in; 369 530 psImage *out; … … 373 534 psS32 rows1 = 8; 374 535 psS32 cols1 = 8; 375 376 // The function psImageRoll shall generate a new psImage structure by377 // rolling the input image the correponding number of pixels in the vertical378 // and/or horizontal direction. The image output image shall be the same size379 // as the input image. Values which roll off the image are wrapped to the380 // other side.381 //382 // Verify the returned psImage structure contains expected values, if the383 // input image contains known values and the roll performed is known.384 // Cases should include no roll, vertical roll, horizontal roll and385 // combination vertical/horizontal rolls. Positive and negative rolls386 // should be performed.387 388 536 in = psImageAlloc(cols,rows,PS_TYPE_F32); 389 537 for (psS32 row=0;row<rows;row++) { … … 393 541 } 394 542 395 out = psImageRoll(NULL,in,0,0);396 543 bool errorFlag = false; 397 for (psS32 row=0;row<rows;row++) {398 psF32 *inRow = in->data.F32[row];399 psF32 *outRow = out->data.F32[row];400 for (psS32 col=0;col<cols;col++) {401 if (inRow[col] != outRow[col]) {402 diag("psImageRoll didn't produce expected result "403 "at %d,%d (%f vs %f) for dx=0, dy=0",404 col,row,inRow[col],outRow[col]);405 errorFlag = true;406 }407 }408 }409 ok(!errorFlag, "psImageRoll() produced the correct data values");410 411 errorFlag = false;412 out2 = psImageRoll(out,in,cols/4,0);413 for (psS32 row=0;row<rows;row++)414 {415 psF32 *inRow = in->data.F32[row];416 psF32 *outRow = out->data.F32[row];417 for (psS32 col=0;col<cols;col++) {418 if (inRow[(col+cols/4) % cols] != outRow[col]) {419 diag("psImageRoll didn't produce expected result "420 "at %d,%d (%f vs %f) for dx=cols/4, dy=0",421 col,row,inRow[(col+cols/4) % cols],outRow[col]);422 errorFlag = true;423 }424 }425 }426 ok(!errorFlag, "psImageRoll() produced the correct data values");427 428 // Verify the returned psImage structure pointer is equal to the input429 // parameter out if provided.430 ok(out2 == out, "psImageRoll didt recycle the out psImage");431 432 errorFlag = false;433 out = psImageRoll(out,in,0,rows/4);434 for (psS32 row=0;row<rows;row++)435 {436 psF32 *inRow = in->data.F32[(row+rows/4)%rows];437 psF32 *outRow = out->data.F32[row];438 for (psS32 col=0;col<cols;col++) {439 if (inRow[col] != outRow[col]) {440 diag("psImageRoll didn't produce expected result "441 "at %d,%d (%f vs %f) for dx=0, dy=rows/4",442 col,row,inRow[col],outRow[col]);443 errorFlag = true;444 }445 }446 }447 ok(!errorFlag, "psImageRoll() produced the correct data values");448 449 errorFlag = false;450 out = psImageRoll(out,in,cols/4,rows/4);451 for (psS32 row=0;row<rows;row++)452 {453 psF32 *inRow = in->data.F32[(row+rows/4)%rows];454 psF32 *outRow = out->data.F32[row];455 for (psS32 col=0;col<cols;col++) {456 if (inRow[(col+cols/4) % cols] != outRow[col]) {457 diag("psImageRoll didn't produce expected result "458 "at %d,%d (%f vs %f) for dx=cols/4, dy=rows/4",459 col,row,inRow[(col+cols/4) % cols],outRow[col]);460 errorFlag = true;461 }462 }463 }464 ok(!errorFlag, "psImageRoll() produced the correct data values");465 466 errorFlag = false;467 out = psImageRoll(out,in,-cols/4,0);468 for (psS32 row=0;row<rows;row++)469 {470 psF32 *inRow = in->data.F32[row];471 psF32 *outRow = out->data.F32[row];472 for (psS32 col=0;col<cols;col++) {473 if (inRow[(col+(cols-cols/4)) % cols] != outRow[col]) {474 diag("psImageRoll didn't produce expected result "475 "at %d,%d (%f vs %f) for dx=-cols/4, dy=0",476 col,row,inRow[(col+(cols-cols/4)) % cols],outRow[col]);477 errorFlag = true;478 }479 }480 }481 ok(!errorFlag, "psImageRoll() produced the correct data values");482 483 errorFlag = false;484 out = psImageRoll(out,in,0,-rows/4);485 for (psS32 row=0;row<rows;row++)486 {487 psF32 *inRow = in->data.F32[(row+rows-rows/4)%rows];488 psF32 *outRow = out->data.F32[row];489 for (psS32 col=0;col<cols;col++) {490 if (inRow[col] != outRow[col]) {491 diag("psImageRoll didn't produce expected result "492 "at %d,%d (%f vs %f) for dx=0, dy=-rows/4",493 col,row,inRow[col],outRow[col]);494 errorFlag = true;495 }496 }497 }498 ok(!errorFlag, "psImageRoll() produced the correct data values");499 500 errorFlag = false;501 out = psImageRoll(out,in,-cols/4,-rows/4);502 for (psS32 row=0;row<rows;row++)503 {504 psF32 *inRow = in->data.F32[(row+rows-rows/4)%rows];505 psF32 *outRow = out->data.F32[row];506 for (psS32 col=0;col<cols;col++) {507 if (inRow[(col+cols-cols/4) % cols] != outRow[col]) {508 diag("psImageRoll didn't produce expected result "509 "at %d,%d (%f vs %f) for dx=cols/4, dy=rows/4",510 col,row,inRow[(col+cols-cols/4) % cols],outRow[col]);511 errorFlag = true;512 }513 }514 }515 ok(!errorFlag, "psImageRoll() produced the correct data values");516 517 518 544 // Verify the returned psImage structure pointer is NULL and program 519 545 // execution doesn't stop, if input parameter input is NULL.
Note:
See TracChangeset
for help on using the changeset viewer.
