Changeset 13123 for trunk/psLib/test/imageops/tap_psImageStructManip.c
- Timestamp:
- May 1, 2007, 6:14:33 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.
