Changeset 6806
- Timestamp:
- Apr 6, 2006, 12:55:18 PM (20 years ago)
- Location:
- trunk/psLib
- Files:
-
- 4 edited
-
src/imageops/psImageGeomManip.c (modified) (3 diffs)
-
src/imageops/psImagePixelExtract.c (modified) (10 diffs)
-
test/imageops/tst_psImagePixelExtract.c (modified) (2 diffs)
-
test/imageops/verified/tst_psImagePixelExtract.stderr (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/imageops/psImageGeomManip.c
r6778 r6806 10 10 * @author Ross Harman, MHPCC 11 11 * 12 * @version $Revision: 1.2 2$ $Name: not supported by cvs2svn $13 * @date $Date: 2006-04-0 5 01:49:40$12 * @version $Revision: 1.23 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2006-04-06 22:55:18 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 753 753 row0 = input->row0; 754 754 col0 = input->col0; 755 row1 = input->row0 + input->numRows ;756 col1 = input->col0 + input->numCols ;755 row1 = input->row0 + input->numRows - 1; 756 col1 = input->col0 + input->numCols - 1; 757 757 } 758 758 if (col1 < 1) { … … 782 782 row0 = output->row0; 783 783 col0 = output->col0; 784 row1 = row0+numRows ;785 col1 = col0+numCols ;784 row1 = row0+numRows -1; 785 col1 = col0+numCols -1; 786 786 } 787 787 -
trunk/psLib/src/imageops/psImagePixelExtract.c
r6805 r6806 8 8 * @author Robert DeSonia, MHPCC 9 9 * 10 * @version $Revision: 1.1 7$ $Name: not supported by cvs2svn $11 * @date $Date: 2006-04-06 04:12:27$10 * @version $Revision: 1.18 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2006-04-06 22:55:18 $ 12 12 * 13 13 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 334 334 } 335 335 336 //If [0,0,0,0] specified, the whole image is to be included 337 if (row0 == 0 && col0 == 0 && row1 == 0 && col1 == 0) { 338 row0 = input->row0; 339 col0 = input->col0; 340 row1 = input->row0 + input->numRows - 1; 341 col1 = input->col0 + input->numCols - 1; 342 } 343 336 344 //Make sure x0 of region is inside image. If so, set col0 to corresponding index number. 337 345 if (col0 >= input->col0 && col0 < (input->col0 + input->numCols) ) { … … 341 349 "Specified psRegion parameter, x0=%f, is out of range [%d,%d].\n", 342 350 region.x0, input->col0, input->col0+input->numCols-1); 351 psFree(out); 343 352 return NULL; 344 353 } … … 350 359 "Specified psRegion parameter, y0=%f, is out of range [%d,%d].\n", 351 360 region.y0, input->row0, input->row0+input->numRows-1); 352 return NULL; 353 } 354 355 //If [0,0,0,0] specified, the whole image is to be included 356 if (row0 == 0 && col0 == 0 && row1 == 0 && col1 == 0) { 357 row0 = input->row0; 358 col0 = input->col0; 359 row1 = input->row0 + input->numRows; 360 col1 = input->col0 + input->numCols; 361 psFree(out); 362 return NULL; 361 363 } 362 364 … … 368 370 "Specified psRegion parameter, x1=%f=%d, is out of range [%d,%d].\n", 369 371 region.x1, col1+input->col0, input->col0, input->col0+input->numCols-1); 372 psFree(out); 370 373 return NULL; 371 374 } … … 376 379 "Specified psRegion parameter, x1=%f=%d, is out of range [%d,%d].\n", 377 380 region.x1, col1, input->col0, input->col0+input->numCols-1); 381 psFree(out); 378 382 return NULL; 379 383 } … … 385 389 "Specified psRegion parameter, y1=%f=%d, is out of range [%d,%d].\n", 386 390 region.y1, row1+input->row0, input->row0, input->row0+input->numRows-1); 391 psFree(out); 387 392 return NULL; 388 393 } … … 393 398 "Specified psRegion parameter, y1=%f=%d, is out of range [%d,%d].\n", 394 399 region.y1, row1, input->row0, input->row0+input->numRows-1); 400 psFree(out); 395 401 return NULL; 396 402 } … … 406 412 region.y0, row0, region.y1, row1); 407 413 } 414 psFree(out); 408 415 return NULL; 409 416 } else if (col0 == col1 && row0 == row1) { 410 417 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 411 418 "Invalid psRegion specified. Region contains only 1 pixel.\n"); 419 psFree(out); 412 420 return NULL; 413 421 } … … 679 687 row0 = input->row0; 680 688 col0 = input->col0; 681 row1 = input->row0 + input->numRows ;682 col1 = input->col0 + input->numCols ;689 row1 = input->row0 + input->numRows - 1; 690 col1 = input->col0 + input->numCols - 1; 683 691 } 684 692 -
trunk/psLib/test/imageops/tst_psImagePixelExtract.c
r6778 r6806 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1. 8$ $Name: not supported by cvs2svn $9 * @date $Date: 2006-04-0 5 01:49:41$8 * @version $Revision: 1.9 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2006-04-06 22:55:18 $ 10 10 * 11 11 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 341 341 } 342 342 343 //Added tests after subimage changes. 344 psFree(image); 345 image = psImageAlloc( c, r, PS_TYPE_F64 ); 346 for ( psS32 row = 0;row < r;row++ ) { 347 psF64 *imageRow = image->data.F64[ row ]; 348 psF64 rowOffset = row * 2; 349 for ( psS32 col = 0;col < c;col++ ) { 350 imageRow[ col ] = col + rowOffset; 351 } 352 } 353 image->col0 = 1; 354 image->row0 = 1; 355 psFree(out); 356 out = NULL; 357 out = psImageSlice(out,positions,image,mask,1, 358 psRegionSet(1,c,1,r),PS_CUT_X_POS,stat); 359 if (out == NULL) { 360 psError(PS_ERR_BAD_PARAMETER_NULL, false, 361 "psImageSlice failed to return the correct psVector. Got NULL instead.\n"); 362 return 112; 363 } 364 psFree(out); 365 out = NULL; 366 //Return NULL for incorrect image inputs. 367 image->row0 = -1; 368 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message"); 369 out = psImageSlice(out,positions,image,mask,1, 370 psRegionSet(1,c,1,r),PS_CUT_X_POS,stat); 371 if (out != NULL) { 372 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 373 "psImageSlice failed to return NULL for invalid specified input.\n"); 374 return 113; 375 } 376 image->col0 = -1; 377 image->row0 = 1; 378 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message"); 379 out = psImageSlice(out,positions,image,mask,1, 380 psRegionSet(1,c,1,r),PS_CUT_X_POS,stat); 381 if (out != NULL) { 382 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 383 "psImageSlice failed to return NULL for invalid specified input.\n"); 384 return 114; 385 } 386 image->col0 = 1; 387 //Return NULL for incorrect region inputs. 388 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message"); 389 out = psImageSlice(out,positions,image,mask,1, 390 psRegionSet(0,c,1,r),PS_CUT_X_POS,stat); 391 if (out != NULL) { 392 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 393 "psImageSlice failed to return NULL for invalid specified input.\n"); 394 return 115; 395 } 396 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message"); 397 out = psImageSlice(out,positions,image,mask,1, 398 psRegionSet(1,c,1,r+1),PS_CUT_X_POS,stat); 399 if (out != NULL) { 400 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 401 "psImageSlice failed to return NULL for invalid specified input.\n"); 402 return 116; 403 } 404 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message"); 405 out = psImageSlice(out,positions,image,mask,1, 406 psRegionSet(1,c,1,-r-2),PS_CUT_X_POS,stat); 407 if (out != NULL) { 408 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 409 "psImageSlice failed to return NULL for invalid specified input.\n"); 410 return 117; 411 } 412 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message"); 413 out = psImageSlice(out,positions,image,mask,1, 414 psRegionSet(c,1,1,r),PS_CUT_X_POS,stat); 415 if (out != NULL) { 416 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 417 "psImageSlice failed to return NULL for invalid specified input.\n"); 418 return 118; 419 } 420 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message"); 421 out = psImageSlice(out,positions,image,mask,1, 422 psRegionSet(1,1,1,1),PS_CUT_X_POS,stat); 423 if (out != NULL) { 424 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 425 "psImageSlice failed to return NULL for invalid specified input.\n"); 426 return 119; 427 } 428 429 //Make sure that regions match appropriately... 430 out = psImageSlice(out,positions,image,mask,1, 431 psRegionSet(1,-1,1,-1),PS_CUT_Y_NEG,stat); 432 psVector *out2 = NULL; 433 out2 = psImageSlice(out2,positions,image,mask,1, 434 psRegionSet(0,0,0,0),PS_CUT_Y_NEG,stat); 435 if (out == NULL) { 436 psError(PS_ERR_BAD_PARAMETER_NULL, false, 437 "psImageSlice incorrectly returned NULL for valid inputs.\n"); 438 return 120; 439 } else if (out2 == NULL) { 440 psError(PS_ERR_BAD_PARAMETER_NULL, false, 441 "psImageSlice incorrectly returned NULL for valid inputs.\n"); 442 return 121; 443 } else if (out->n != out2->n) { 444 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 445 "psImageSlice failed to return matching vectors for equivalent inputs.\n"); 446 return 122; 447 } else if (out->data.F64[out->n-1] != out2->data.F64[out2->n-1] ) { 448 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 449 "psImageSlice failed to return matching vectors for equivalent inputs.\n"); 450 return 123; 451 } 452 psFree(out2); 453 343 454 psFree( image ); 344 455 psFree( positions ); -
trunk/psLib/test/imageops/verified/tst_psImagePixelExtract.stderr
r6770 r6806 49 49 <DATE><TIME>|<HOST>|E|psImageSlice (FILE:LINENO) 50 50 Input psImage mask type, psS8, is not the supported mask datatype of psU8. 51 <DATE><TIME>|<HOST>|I|testImageSlice 52 Following should generate error message 53 <DATE><TIME>|<HOST>|E|psImageSlice (FILE:LINENO) 54 psImage input is invalid. row0 cannot be negative. 55 <DATE><TIME>|<HOST>|I|testImageSlice 56 Following should generate error message 57 <DATE><TIME>|<HOST>|E|psImageSlice (FILE:LINENO) 58 psImage input is invalid. col0 cannot be negative. 59 <DATE><TIME>|<HOST>|I|testImageSlice 60 Following should generate error message 61 <DATE><TIME>|<HOST>|E|psImageSlice (FILE:LINENO) 62 Specified psRegion parameter, x0=0.000000, is out of range [1,300]. 63 <DATE><TIME>|<HOST>|I|testImageSlice 64 Following should generate error message 65 <DATE><TIME>|<HOST>|E|psImageSlice (FILE:LINENO) 66 Specified psRegion parameter, y1=201.000000=201, is out of range [1,200]. 67 <DATE><TIME>|<HOST>|I|testImageSlice 68 Following should generate error message 69 <DATE><TIME>|<HOST>|E|psImageSlice (FILE:LINENO) 70 Specified psRegion parameter, y1=-202.000000=-1, is out of range [1,200]. 71 <DATE><TIME>|<HOST>|I|testImageSlice 72 Following should generate error message 73 <DATE><TIME>|<HOST>|E|psImageSlice (FILE:LINENO) 74 Invalid psRegion specified. x0=300.000000=299 is greater than x1=1.000000=0. 75 <DATE><TIME>|<HOST>|I|testImageSlice 76 Following should generate error message 77 <DATE><TIME>|<HOST>|E|psImageSlice (FILE:LINENO) 78 Invalid psRegion specified. Region contains only 1 pixel. 51 79 52 80 ---> TESTPOINT PASSED (psImage{psImageSlice} | tst_psImagePixelExtract.c)
Note:
See TracChangeset
for help on using the changeset viewer.
