Changeset 6750
- Timestamp:
- Mar 31, 2006, 4:43:57 PM (20 years ago)
- Location:
- trunk/psLib
- Files:
-
- 13 edited
-
src/imageops/psImageGeomManip.c (modified) (2 diffs)
-
src/imageops/psImageGeomManip.h (modified) (2 diffs)
-
src/imageops/psImagePixelExtract.c (modified) (14 diffs)
-
src/imageops/psImageStats.c (modified) (10 diffs)
-
src/mathtypes/psImage.c (modified) (4 diffs)
-
src/types/psPixels.c (modified) (3 diffs)
-
test/imageops/tst_psImagePixelExtract.c (modified) (5 diffs)
-
test/imageops/tst_psImageStats.c (modified) (3 diffs)
-
test/imageops/verified/tst_psImageInterpolate.stderr (modified) (1 diff)
-
test/imageops/verified/tst_psImagePixelExtract.stderr (modified) (3 diffs)
-
test/imageops/verified/tst_psImageStats.stderr (modified) (1 diff)
-
test/types/tst_psPixels.c (modified) (2 diffs)
-
test/types/verified/tst_psPixels.stderr (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/imageops/psImageGeomManip.c
r6484 r6750 10 10 * @author Ross Harman, MHPCC 11 11 * 12 * @version $Revision: 1.2 0$ $Name: not supported by cvs2svn $13 * @date $Date: 2006-0 2-24 23:43:15$12 * @version $Revision: 1.21 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2006-04-01 02:43:57 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 749 749 col0 = region.x0; 750 750 col1 = region.x1; 751 //If [0,0,0,0] specified, the whole image is to be included 752 if (row0 == 0 && col0 == 0 && row1 == 0 && col1 == 0) { 753 row0 = input->row0; 754 col0 = input->col0; 755 row1 = input->row0 + input->numRows; 756 col1 = input->col0 + input->numCols; 757 } 751 758 if (col1 < 1) { 752 col1 += input-> numCols;759 col1 += input->col0 + input->numCols; 753 760 } 754 761 755 762 if (row1 < 1) { 756 row1 += input-> numRows;763 row1 += input->row0 + input->numRows; 757 764 } 758 765 -
trunk/psLib/src/imageops/psImageGeomManip.h
r6354 r6750 8 8 * @author Robert DeSonia, MHPCC 9 9 * 10 * @version $Revision: 1.1 4$ $Name: not supported by cvs2svn $11 * @date $Date: 2006-0 2-08 01:03:35$10 * @version $Revision: 1.15 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2006-04-01 02:43:57 $ 12 12 * 13 13 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 150 150 const psPlaneTransform *outToIn, ///< the transform to apply 151 151 psRegion region, ///< the size of the transformed image 152 const psPixels* pixels, /**< if not NULL, consists of psPixelCoords and specifies which pixels in 153 * output image shall be transformed; otherwise, entire image generated*/ 152 const psPixels* pixels, /**< if not NULL, consists of psPixelCoords and specifies 153 * which pixels in output image shall be transformed; 154 * otherwise, entire image generated*/ 154 155 psImageInterpolateMode mode, ///< the interpolation scheme to be used 155 double exposedValue ///< Exposed value to which non-corresponding pixels are set156 double exposedValue ///< Exposed value to which non-corresponding pixels are set 156 157 ); 157 158 -
trunk/psLib/src/imageops/psImagePixelExtract.c
r6631 r6750 8 8 * @author Robert DeSonia, MHPCC 9 9 * 10 * @version $Revision: 1.1 3$ $Name: not supported by cvs2svn $11 * @date $Date: 2006-0 3-17 20:38:19$10 * @version $Revision: 1.14 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2006-04-01 02:43:57 $ 12 12 * 13 13 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 57 57 return NULL; 58 58 } 59 PS_ASSERT_INT_NONNEGATIVE(input->col0, NULL); 60 PS_ASSERT_INT_NONNEGATIVE(input->row0, NULL); 61 PS_ASSERT_INT_POSITIVE(input->numCols, NULL); 62 PS_ASSERT_INT_POSITIVE(input->numRows, NULL); 59 if (input->col0 < 0) { 60 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 61 "psImage input is invalid. col0 cannot be negative.\n"); 62 psFree(out); 63 return NULL; 64 } 65 if (input->row0 < 0) { 66 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 67 "psImage input is invalid. row0 cannot be negative.\n"); 68 psFree(out); 69 return NULL; 70 } 71 if (input->numCols < 1) { 72 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 73 "psImage input is invalid. numCols must be greater than 0.\n"); 74 psFree(out); 75 return NULL; 76 } 77 if (input->numRows < 1) { 78 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 79 "psImage input is invalid. numRows must be greater than 0.\n"); 80 psFree(out); 81 return NULL; 82 } 63 83 if (row >= (input->numRows + input->row0) ) { 64 84 psError(PS_ERR_BAD_PARAMETER_NULL, true, 65 85 "Specified row number is out of range for specified image.\n"); 86 psFree(out); 66 87 return NULL; 67 88 } else if ( row < input->row0 && row >= 0 ) { 68 89 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 69 90 "Specified row number is out of range for specified image.\n"); 91 psFree(out); 70 92 return NULL; 71 93 } else if ( row < 0 ) { … … 74 96 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 75 97 "Specified row number is out of range for specified image.\n"); 98 psFree(out); 76 99 return NULL; 77 100 } … … 164 187 return NULL; 165 188 } 166 PS_ASSERT_INT_NONNEGATIVE(input->col0, NULL); 167 PS_ASSERT_INT_NONNEGATIVE(input->row0, NULL); 168 PS_ASSERT_INT_POSITIVE(input->numCols, NULL); 169 PS_ASSERT_INT_POSITIVE(input->numRows, NULL); 189 if (input->col0 < 0) { 190 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 191 "psImage input is invalid. col0 cannot be negative.\n"); 192 psFree(out); 193 return NULL; 194 } 195 if (input->row0 < 0) { 196 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 197 "psImage input is invalid. row0 cannot be negative.\n"); 198 psFree(out); 199 return NULL; 200 } 201 if (input->numCols < 1) { 202 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 203 "psImage input is invalid. numCols must be greater than 0.\n"); 204 psFree(out); 205 return NULL; 206 } 207 if (input->numRows < 1) { 208 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 209 "psImage input is invalid. numRows must be greater than 0.\n"); 210 psFree(out); 211 return NULL; 212 } 170 213 if (column >= (input->numCols + input->col0) ) { 171 214 psError(PS_ERR_BAD_PARAMETER_NULL, true, 172 215 "Specified column number is out of range for specified image.\n"); 216 psFree(out); 173 217 return NULL; 174 218 } else if ( column < input->col0 && column >= 0 ) { 175 219 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 176 220 "Specified column number is out of range for specified image.\n"); 221 psFree(out); 177 222 return NULL; 178 223 } else if ( column < 0 ) { … … 181 226 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 182 227 "Specified column number is out of range for specified image.\n"); 228 psFree(out); 183 229 return NULL; 184 230 } … … 263 309 return NULL; 264 310 } 265 PS_ASSERT_INT_NONNEGATIVE(input->col0, NULL); 266 PS_ASSERT_INT_NONNEGATIVE(input->row0, NULL); 267 PS_ASSERT_INT_POSITIVE(input->numCols, NULL); 268 PS_ASSERT_INT_POSITIVE(input->numRows, NULL); 311 if (input->col0 < 0) { 312 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 313 "psImage input is invalid. col0 cannot be negative.\n"); 314 psFree(out); 315 return NULL; 316 } 317 if (input->row0 < 0) { 318 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 319 "psImage input is invalid. row0 cannot be negative.\n"); 320 psFree(out); 321 return NULL; 322 } 323 if (input->numCols < 1) { 324 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 325 "psImage input is invalid. numCols must be greater than 0.\n"); 326 psFree(out); 327 return NULL; 328 } 329 if (input->numRows < 1) { 330 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 331 "psImage input is invalid. numRows must be greater than 0.\n"); 332 psFree(out); 333 return NULL; 334 } 269 335 /* 270 336 if (col1 < 1) { 271 337 col1 += input->numCols; 272 338 } 273 339 274 340 if (row1 < 1) { 275 341 row1 += input->numRows; 276 342 } 277 343 278 344 if ( col0 < 0 || 279 345 row0 < 0 || … … 296 362 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 297 363 "Specified psRegion parameter, x0=%f, is out of range [%d,%d].\n", 298 region.x0, input->col0, input->col0+input->numCols );364 region.x0, input->col0, input->col0+input->numCols-1); 299 365 return NULL; 300 366 } … … 305 371 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 306 372 "Specified psRegion parameter, y0=%f, is out of range [%d,%d].\n", 307 region.y0, input->row0, input->row0+input->numRows );373 region.y0, input->row0, input->row0+input->numRows-1); 308 374 return NULL; 309 375 } … … 315 381 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 316 382 "Specified psRegion parameter, x1=%f=%d, is out of range [%d,%d].\n", 317 region.x1, col1+input->col0, input->col0, input->col0+input->numCols );383 region.x1, col1+input->col0, input->col0, input->col0+input->numCols-1); 318 384 return NULL; 319 385 } … … 323 389 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 324 390 "Specified psRegion parameter, x1=%f=%d, is out of range [%d,%d].\n", 325 region.x1, col1, input->col0, input->col0+input->numCols );391 region.x1, col1, input->col0, input->col0+input->numCols-1); 326 392 return NULL; 327 393 } … … 332 398 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 333 399 "Specified psRegion parameter, y1=%f=%d, is out of range [%d,%d].\n", 334 region.y1, row1+input->row0, input->row0, input->row0+input->numRows );400 region.y1, row1+input->row0, input->row0, input->row0+input->numRows-1); 335 401 return NULL; 336 402 } … … 340 406 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 341 407 "Specified psRegion parameter, y1=%f=%d, is out of range [%d,%d].\n", 342 region.y1, row1, input->row0, input->row0+input->numRows );408 region.y1, row1, input->row0, input->row0+input->numRows-1); 343 409 return NULL; 344 410 } … … 583 649 return NULL; 584 650 } 585 // PS_ASSERT_INT_NONNEGATIVE(input->col0, NULL); 586 // PS_ASSERT_INT_NONNEGATIVE(input->row0, NULL); 587 // PS_ASSERT_INT_POSITIVE(input->numCols, NULL); 588 // PS_ASSERT_INT_POSITIVE(input->numRows, NULL); 651 if (input->col0 < 0) { 652 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 653 "psImage input is invalid. col0 cannot be negative.\n"); 654 psFree(out); 655 return NULL; 656 } 657 if (input->row0 < 0) { 658 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 659 "psImage input is invalid. row0 cannot be negative.\n"); 660 psFree(out); 661 return NULL; 662 } 663 if (input->numCols < 1) { 664 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 665 "psImage input is invalid. numCols must be greater than 0.\n"); 666 psFree(out); 667 return NULL; 668 } 669 if (input->numRows < 1) { 670 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 671 "psImage input is invalid. numRows must be greater than 0.\n"); 672 psFree(out); 673 return NULL; 674 } 589 675 psS32 numCols = input->numCols; 590 676 psS32 numRows = input->numRows; … … 598 684 } 599 685 600 601 float startCol = region.x0; 602 float startRow = region.y0; 603 float endCol = region.x1; 604 float endRow = region.y1; 605 if (startCol < 0 || startCol >= numCols || 606 startRow < 0 || startRow >= numRows || 607 endCol < 0 || endCol >= numCols || 608 endRow < 0 || endRow >= numRows) { 609 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 610 PS_ERRORTEXT_psImage_LINE_NOT_IN_IMAGE, 611 startCol,startRow,endCol,endRow, 612 numCols-1,numRows-1); 613 psFree(out); 614 return NULL; 615 } 686 float col0 = region.x0; 687 float row0 = region.y0; 688 float col1 = region.x1; 689 float row1 = region.y1; 690 691 //Make sure x0 of region is inside image. If so, set col0 to corresponding index number. 692 if (col0 >= input->col0 && col0 < (input->col0 + input->numCols) ) { 693 col0 -= input->col0; 694 } else { 695 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 696 "Specified psRegion parameter, x0=%f, is out of range [%d,%d].\n", 697 region.x0, input->col0, input->col0+input->numCols); 698 psFree(out); 699 return NULL; 700 } 701 //Make sure y0 of region is inside image. If so, set row0 to corresponding index number. 702 if (row0 >= input->row0 && row0 < (input->row0 + input->numRows) ) { 703 row0 -= input->row0; 704 } else { 705 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 706 "Specified psRegion parameter, y0=%f, is out of range [%d,%d].\n", 707 region.y0, input->row0, input->row0+input->numRows); 708 psFree(out); 709 return NULL; 710 } 711 /* 712 //Make sure x1 of region is valid. If negative, index from tail (if valid). 713 if (col1 < 0) { 714 col1 += input->numCols; 715 if (col1 < 0) { 716 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 717 "Specified psRegion parameter, x1=%f=%f, is out of range [%d,%d].\n", 718 region.x1, col1+input->col0, input->col0, input->col0+input->numCols); 719 psFree(out); 720 return NULL; 721 } 722 } else if (col1 >= input->col0 && col1 < (input->col0 + input->numCols) ) { 723 col1 -= input->col0; 724 } else { 725 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 726 "Specified psRegion parameter, x1=%f=%f, is out of range [%d,%d].\n", 727 region.x1, col1, input->col0, input->col0+input->numCols); 728 psFree(out); 729 return NULL; 730 } 731 //Make sure y1 of region is valid. If negative, index from tail (if valid). 732 if (row1 < 0) { 733 row1 += input->numRows; 734 if (row1 < 0) { 735 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 736 "Specified psRegion parameter, y1=%f=%f, is out of range [%d,%d].\n", 737 region.y1, row1+input->row0, input->row0, input->row0+input->numRows); 738 psFree(out); 739 return NULL; 740 } 741 } else if (row1 >= input->row0 && row1 < (input->row0 + input->numRows) ) { 742 row1 -= input->row0; 743 } else { 744 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 745 "Specified psRegion parameter, y1=%f=%f, is out of range [%d,%d].\n", 746 region.y1, row1, input->row0, input->row0+input->numRows); 747 psFree(out); 748 return NULL; 749 } 750 */ 751 /* //Now make sure that the region makes sense. 752 if (col0 > col1 || row0 > row1) { 753 if (col0 > col1) { 754 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 755 "Invalid psRegion specified. x0=%f=%f is greater than x1=%f=%f.\n", 756 region.x0, col0, region.x1, col1); 757 } else { 758 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 759 "Invalid psRegion specified. y0=%f=%f is greater than y1=%f=%f.\n", 760 region.y0, row0, region.y1, row1); 761 } 762 psFree(out); 763 return NULL; 764 } else if (col0 == col1 && row0 == row1) { 765 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 766 "Invalid psRegion specified. Region contains only 1 pixel.\n"); 767 psFree(out); 768 return NULL; 769 } 770 */ 771 if (col1 < 0 || row1 < 0 || col0 < 0 || row0 < 0 || col0 >= numCols || col1 >= numCols || 772 row0 >= numRows || row1 >= numRows) { 773 psFree(out); 774 return NULL; 775 } 776 float startCol = col0; 777 float startRow = row0; 778 float endCol = col1; 779 float endRow = row1; 780 /* 781 float startCol = region.x0; 782 float startRow = region.y0; 783 float endCol = region.x1; 784 float endRow = region.y1; 785 if (startCol < 0 || startCol >= numCols || 786 startRow < 0 || startRow >= numRows || 787 endCol < 0 || endCol >= numCols || 788 endRow < 0 || endRow >= numRows) { 789 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 790 PS_ERRORTEXT_psImage_LINE_NOT_IN_IMAGE, 791 startCol,startRow,endCol,endRow, 792 numCols-1,numRows-1); 793 psFree(out); 794 return NULL; 795 } 796 */ 616 797 617 798 if (mode < PS_INTERPOLATE_FLAT ) { -
trunk/psLib/src/imageops/psImageStats.c
r6346 r6750 9 9 * @author GLG, MHPCC 10 10 * 11 * @version $Revision: 1.9 0$ $Name: not supported by cvs2svn $12 * @date $Date: 2006-0 2-07 23:14:21$11 * @version $Revision: 1.91 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2006-04-01 02:43:57 $ 13 13 * 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 267 267 // We scale the pixel positions to values 268 268 // between -1.0 and 1.0 269 rScalingFactors = calcScaleFactors(input->numRows); 270 cScalingFactors = calcScaleFactors(input->numCols); 269 // rScalingFactors = calcScaleFactors(input->numRows); 270 // cScalingFactors = calcScaleFactors(input->numCols); 271 rScalingFactors = calcScaleFactors(input->row0 + input->numRows); 272 cScalingFactors = calcScaleFactors(input->col0 + input->numCols); 271 273 272 274 // Determine how many Chebyshev polynomials … … 283 285 for (j = 0; j < (1 + coeffs->nY); j++) { 284 286 sums[i][j] = 0.0; 285 for (x = 0; x < input->numRows; x++) { 286 for (y = 0; y < input->numCols; y++) { 287 // for (x = 0; x < input->numRows; x++) { 288 // for (y = 0; y < input->numCols; y++) { 289 for (x = input->row0; x < (input->row0 + input->numRows); x++) { 290 for (y = input->col0; y < (input->col0 + input->numCols); y++) { 287 291 double pixel = 0.0; 288 292 if (input->type.type == PS_TYPE_S8) { … … 399 403 // nodes->data.F64[x][y] = psImagePixelInterpolate(input, yNode, xNode, NULL, 0, 0.0, PS_INTERPOLATE_BILINEAR); 400 404 // nodes->data.F64[x][y] = psImagePixelInterpolate(input, yTmp, xTmp, NULL, 0, 0.0, PS_INTERPOLATE_BILINEAR); 401 nodes->data.F64[x][y] = psImagePixelInterpolate(input, yOrig, xOrig, NULL, 0, 0.0, PS_INTERPOLATE_BILINEAR); 405 nodes->data.F64[x][y] = psImagePixelInterpolate(input, yOrig, xOrig, NULL, 406 0, 0.0, PS_INTERPOLATE_BILINEAR); 402 407 } 403 408 } … … 505 510 // We scale the pixel positions to values between -1.0 and 1.0 506 511 // Use static data structures here. 507 rScalingFactors = calcScaleFactors(input->numRows); 508 cScalingFactors = calcScaleFactors(input->numCols); 512 // rScalingFactors = calcScaleFactors(input->numRows); 513 // cScalingFactors = calcScaleFactors(input->numCols); 514 rScalingFactors = calcScaleFactors(input->numRows+input->row0); 515 cScalingFactors = calcScaleFactors(input->numCols+input->col0); 509 516 510 517 // Determine how many Chebyshev polynomials … … 517 524 chebPolys = p_psCreateChebyshevPolys(maxChebyPoly + 1); 518 525 519 for (x = 0; x < input->numRows; x++) { 520 for (y = 0; y < input->numCols; y++) { 526 // for (x = 0; x < input->numRows; x++) { 527 // for (y = 0; y < input->numCols; y++) { 528 for (x = input->row0; x < (input->row0 + input->numRows); x++) { 529 for (y = input->col0; y < (input->col0 + input->numCols); y++) { 521 530 polySum = 0.0; 522 531 for (i = 0; i < (1 + coeffs->nX); i++) { … … 563 572 for (int col = 0; col < input->numCols ; col++) { 564 573 if (input->type.type == PS_TYPE_S8) { 565 input->data.S8[row][col] = (psS8) psPolynomial2DEval(coeffs, (psF32) row, (psF32) col); 574 input->data.S8[row][col] = (psS8) psPolynomial2DEval(coeffs, 575 (psF32) (row + input->row0), (psF32) (col + input->col0)); 566 576 } else if (input->type.type == PS_TYPE_U16) { 567 input->data.U16[row][col] = (psS16) psPolynomial2DEval(coeffs, (psF32) row, (psF32) col); 577 input->data.U16[row][col] = (psS16) psPolynomial2DEval(coeffs, 578 (psF32) (row + input->row0), (psF32) (col + input->col0)); 568 579 } else if (input->type.type == PS_TYPE_F32) { 569 input->data.F32[row][col] = psPolynomial2DEval(coeffs, (psF32) row, (psF32) col); 580 input->data.F32[row][col] = psPolynomial2DEval(coeffs, 581 (psF32) (row + input->row0), (psF32) (col + input->col0)); 570 582 } else if (input->type.type == PS_TYPE_F64) { 571 input->data.F64[row][col] = (psF64) psPolynomial2DEval(coeffs, (psF32) row, (psF32) col); 583 input->data.F64[row][col] = (psF64) psPolynomial2DEval(coeffs, 584 (psF32) (row + input->row0), (psF32) (col + input->col0)); 572 585 } 573 586 } … … 617 630 int y1 = 0; 618 631 psElemType type; 619 if (mask == NULL) {620 psError(PS_ERR_BAD_PARAMETER_NULL, true,621 PS_ERRORTEXT_psImage_IMAGE_NULL);622 return -1;623 }624 632 625 633 // this is not a valid error: a psRegion with ranges outside the valid pixels … … 641 649 642 650 // rationalize the region 643 region = psRegionForImage(mask, region); 644 645 if (region.x0 == region.x1 || region.y0 == region.y1) { 646 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 647 "psRegion input contains 0 pixels\n"); 651 652 /* 653 if (mask == NULL) { 654 psError(PS_ERR_BAD_PARAMETER_NULL, true, 655 PS_ERRORTEXT_psImage_IMAGE_NULL); 656 return -1; 657 } 658 region = psRegionForImage(mask, region); 659 660 if (region.x0 == region.x1 || region.y0 == region.y1) { 661 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 662 "psRegion input contains 0 pixels\n"); 663 return -1; 664 } 665 */ 666 PS_ASSERT_IMAGE_NON_NULL(mask, -1); 667 PS_ASSERT_INT_NONNEGATIVE(mask->col0, -1); 668 PS_ASSERT_INT_NONNEGATIVE(mask->row0, -1); 669 PS_ASSERT_INT_POSITIVE(mask->numCols, -1); 670 PS_ASSERT_INT_POSITIVE(mask->numRows, -1); 671 672 /* x0 = (int)(roundf(region.x0)); 673 x1 = (int)(roundf(region.x1)); 674 y0 = (int)(roundf(region.y0)); 675 y1 = (int)(roundf(region.y1)); 676 */ 677 int col0 = (int)(roundf(region.x0)); 678 int col1 = (int)(roundf(region.x1)); 679 int row0 = (int)(roundf(region.y0)); 680 int row1 = (int)(roundf(region.y1)); 681 //If (0,0,0,0) specified, the whole image is to be used. 682 if (col0 == 0 && col1 == 0 && row0 == 0 && row1 == 0) { 683 col0 = mask->col0; 684 col1 = mask->col0 + mask->numCols - 1; 685 row0 = mask->row0; 686 row1 = mask->row0 + mask->numRows - 1; 687 } 688 689 //Make sure x0 of region is inside image. If so, set col0 to corresponding index number. 690 if (col0 >= mask->col0 && col0 < (mask->col0 + mask->numCols) ) { 691 col0 -= mask->col0; 692 } else { 693 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 694 "Specified psRegion parameter, x0=%f, is out of range [%d,%d].\n", 695 region.x0, mask->col0, mask->col0+mask->numCols-1); 648 696 return -1; 649 697 } 650 651 x0 = (int)(roundf(region.x0)); 652 x1 = (int)(roundf(region.x1)); 653 y0 = (int)(roundf(region.y0)); 654 y1 = (int)(roundf(region.y1)); 698 //Make sure y0 of region is inside image. If so, set row0 to corresponding index number. 699 if (row0 >= mask->row0 && row0 < (mask->row0 + mask->numRows) ) { 700 row0 -= mask->row0; 701 } else { 702 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 703 "Specified psRegion parameter, y0=%f, is out of range [%d,%d].\n", 704 region.y0, mask->row0, mask->row0+mask->numRows-1); 705 return -1; 706 } 707 708 //Make sure x1 of region is valid. If negative, index from tail (if valid). 709 if (col1 < 0) { 710 col1 += mask->numCols; 711 if (col1 < 0) { 712 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 713 "Specified psRegion parameter, x1=%f=%d, is out of range [%d,%d].\n", 714 region.x1, col1+mask->col0, mask->col0, mask->col0+mask->numCols-1); 715 return -1; 716 } 717 } else if (col1 >= mask->col0 && col1 < (mask->col0 + mask->numCols) ) { 718 col1 -= mask->col0; 719 } else { 720 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 721 "Specified psRegion parameter, x1=%f=%d, is out of range [%d,%d].\n", 722 region.x1, col1, mask->col0, mask->col0+mask->numCols-1); 723 return -1; 724 } 725 //Make sure y1 of region is valid. If negative, index from tail (if valid). 726 if (row1 < 0) { 727 row1 += mask->numRows; 728 if (row1 < 0) { 729 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 730 "Specified psRegion parameter, y1=%f=%d, is out of range [%d,%d].\n", 731 region.y1, row1+mask->row0, mask->row0, mask->row0+mask->numRows-1); 732 return -1; 733 } 734 } else if (row1 >= mask->row0 && row1 < (mask->row0 + mask->numRows) ) { 735 row1 -= mask->row0; 736 } else { 737 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 738 "Specified psRegion parameter, y1=%f=%d, is out of range [%d,%d].\n", 739 region.y1, row1, mask->row0, mask->row0+mask->numRows-1); 740 return -1; 741 } 742 //Now make sure that the region makes sense. 743 if (col0 > col1 || row0 > row1) { 744 if (col0 > col1) { 745 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 746 "Invalid psRegion specified. x0=%f=%d is greater than x1=%f=%d.\n", 747 region.x0, col0, region.x1, col1); 748 } else { 749 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 750 "Invalid psRegion specified. y0=%f=%d is greater than y1=%f=%d.\n", 751 region.y0, row0, region.y1, row1); 752 } 753 return -1; 754 }/* else if (col0 == col1 && row0 == row1) { 755 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 756 "Invalid psRegion specified. Region contains only 1 pixel.\n"); 757 return -1; 758 } 759 */ 760 x0 = col0; 761 x1 = col1; 762 y0 = row0; 763 y1 = row1; 655 764 656 765 type = mask->type.type; … … 664 773 case PS_TYPE_U8: 665 774 case PS_TYPE_U16: 666 for (long j = y0; j < y1; j++) {667 for (long i = x0; i < x1; i++) {775 for (long j = y0; j <= y1; j++) { 776 for (long i = x0; i <= x1; i++) { 668 777 if (mask->data.PS_TYPE_MASK_DATA[j][i] & value) { 669 778 Npixels ++; -
trunk/psLib/src/mathtypes/psImage.c
r6631 r6750 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1. 99$ $Name: not supported by cvs2svn $12 * @date $Date: 2006-0 3-17 20:38:19$11 * @version $Revision: 1.100 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2006-04-01 02:43:57 $ 13 13 * 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 173 173 { 174 174 175 if (image == NULL) { 176 return in; 175 // if (image == NULL) { 176 // return in; 177 // } 178 PS_ASSERT_IMAGE_NON_NULL(image, in); 179 //if the region is [0,0,0,0], the whole image (or subimage) is to be included. 180 if (in.x0 == 0 && in.x1 == 0 && in.y0 == 0 && in.y1 == 0) { 181 in.x0 = image->col0; 182 in.x1 = image->col0 + image->numCols - 1; 183 in.y0 = image->row0; 184 in.y1 = image->row0 + image->numRows - 1; 185 return (in); 177 186 } 178 187 … … 195 204 // flip start and end if out of order 196 205 if (in.x0 > in.x1) { 206 psError (PS_ERR_BAD_PARAMETER_VALUE, true, 207 "Invalid region in psRegionForImage. x0 > x1. Values have been swapped.\n"); 197 208 PS_SWAP (in.x0, in.x1); 198 209 } 199 210 if (in.y0 > in.y1) { 211 psError (PS_ERR_BAD_PARAMETER_VALUE, true, 212 "Invalid region in psRegionForImage. y0 > y1. Values have been swapped.\n"); 200 213 PS_SWAP (in.y0, in.y1); 201 214 } … … 717 730 { 718 731 719 if (input == NULL) { 720 psError(PS_ERR_BAD_PARAMETER_NULL,true, 721 PS_ERRORTEXT_psImage_IMAGE_NULL); 722 return unexposedValue; 732 /* if (input == NULL) { 733 psError(PS_ERR_BAD_PARAMETER_NULL,true, 734 PS_ERRORTEXT_psImage_IMAGE_NULL); 735 return unexposedValue; 736 } 737 */ 738 PS_ASSERT_IMAGE_NON_NULL(input, unexposedValue); 739 if (input->row0 != 0 || input->col0 != 0) { 740 x += input->col0; 741 y += input->row0; 723 742 } 724 743 -
trunk/psLib/src/types/psPixels.c
r6500 r6750 7 7 * @author Robert DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1.2 2$ $Name: not supported by cvs2svn $10 * @date $Date: 2006-0 2-28 02:53:03$9 * @version $Revision: 1.23 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2006-04-01 02:43:57 $ 11 11 * 12 12 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 168 168 float y1 = region.y1; 169 169 170 if ( (x0 < 0 || x1 < 0) || (y0 < 0 || y1 < 0) ) { 171 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 172 PS_ERRORTEXT_psPixels_REGION_INVALID, 173 (int)y0,(int)y1,(int)x0,(int)x1); 174 psFree(out); 175 return NULL; 176 } 177 170 178 // determine the output image size 171 179 int numRows = y1-y0; 172 180 int numCols = x1-x0; 181 numRows += 1; 182 numCols += 1; 173 183 if (numRows < 1 || numCols < 1) { 174 184 psError(PS_ERR_BAD_PARAMETER_VALUE, true, … … 205 215 float y = data[p].y; 206 216 // pixel in region? 207 if (x >= x0 && x < x1 && y >= y0 && y <y1) {217 if (x >= x0 && x <= x1 && y >= y0 && y <= y1) { 208 218 outData[(int)(y-y0)][(int)(x-x0)] |= maskVal; 209 219 } -
trunk/psLib/test/imageops/tst_psImagePixelExtract.c
r6484 r6750 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1. 5$ $Name: not supported by cvs2svn $9 * @date $Date: 2006-0 2-24 23:43:15$8 * @version $Revision: 1.6 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2006-04-01 02:43:57 $ 10 10 * 11 11 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 21 21 static psS32 testImageCut(void); 22 22 static psS32 testImageRadialCut(void); 23 static psS32 testImageRowColError(void); 23 24 static psS32 testImageRowColF32(void); 24 25 static psS32 testImageRowColF64(void); … … 37 38 {testImageSlice, 552, "psImageSlice", 0, false}, 38 39 {testImageCut, 555, "psImageCut", 0, false}, 39 {testImageRadialCut, 557, "psImageRadialCut", 0, false}, 40 {testImageRadialCut, 556, "psImageRadialCut", 0, false}, 41 {testImageRowColError, 557, "testImageRowColError", 0, false}, 40 42 {testImageRowColF32, 558, "psImageRowColF32", 0, false}, 41 43 {testImageRowColF64, 559, "psImageRowColF64", 0, false}, … … 765 767 } 766 768 767 psS32 testImageRowColF64(void) 768 { 769 psVector *rowcol = NULL; 770 psVector *empty = NULL; 769 psS32 testImageRowColError(void) 770 { 771 771 psImage *image = NULL; 772 psImage *emptyImage = NULL; 772 psVector *out = NULL; 773 int num = 0; 774 775 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message"); 776 out = psImageRow(NULL, image, num); 777 if (out != NULL) { 778 return 1; 779 } 780 773 781 774 782 image = psImageAlloc(3, 3, PS_TYPE_F64); 775 rowcol = psVectorAlloc(3, PS_TYPE_F64);776 783 *(psS32*)&(image->row0) = 5; 784 *(psS32*)&(image->col0) = 10; 777 785 image->data.F64[0][0] = 666.666; 778 786 image->data.F64[1][0] = 66.6; … … 785 793 image->data.F64[2][2] = 66.66; 786 794 795 796 797 psFree(out); 798 psFree(image); 799 return 0; 800 } 801 802 psS32 testImageRowColF64(void) 803 { 804 psVector *rowcol = NULL; 805 psVector *empty = NULL; 806 psImage *image = NULL; 807 psImage *emptyImage = NULL; 808 809 image = psImageAlloc(3, 3, PS_TYPE_F64); 810 rowcol = psVectorAlloc(3, PS_TYPE_F64); 811 812 image->data.F64[0][0] = 666.666; 813 image->data.F64[1][0] = 66.6; 814 image->data.F64[2][0] = 6.66; 815 image->data.F64[0][1] = 6.6; 816 image->data.F64[1][1] = 6.666; 817 image->data.F64[2][1] = 66.666; 818 image->data.F64[0][2] = 666.6; 819 image->data.F64[1][2] = 666.66; 820 image->data.F64[2][2] = 66.66; 821 787 822 //Test for error with NULL image 788 823 empty = psImageCol(empty, emptyImage, 0); -
trunk/psLib/test/imageops/tst_psImageStats.c
r6306 r6750 543 543 psRegion reg; 544 544 reg.x0 = 0; 545 reg.x1 = 1;545 reg.x1 = 0; 546 546 reg.y0 = 0; 547 reg.y1 = 5; 547 reg.y1 = 4; 548 549 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message"); 548 550 numPix = psImageCountPixelMask(in, reg, 1); 549 550 551 if (numPix != -1) { 551 552 psError(PS_ERR_BAD_PARAMETER_VALUE, false, … … 587 588 if (numPix2 != 2) { 588 589 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 589 "psImageCountPixelMask returned incorrect pixel count %ld \n", numPix2);590 "psImageCountPixelMask returned incorrect pixel count %ld (!=2)\n", numPix2); 590 591 return 4; 591 592 } … … 613 614 reg.x1 = 1; 614 615 reg.y1 = 1; 616 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message"); 615 617 numPix2 = psImageCountPixelMask(in2, reg, 1); 616 618 if (numPix2 != -1) { -
trunk/psLib/test/imageops/verified/tst_psImageInterpolate.stderr
r4547 r6750 17 17 Following should generate an error message 18 18 <DATE><TIME>|<HOST>|E|psImagePixelInterpolate (FILE:LINENO) 19 Can not operate on a NULL psImage.19 Unallowable operation: psImage input or its data is NULL. 20 20 <DATE><TIME>|<HOST>|I|testInterpolateError 21 21 Following should generate an error message -
trunk/psLib/test/imageops/verified/tst_psImagePixelExtract.stderr
r6631 r6750 24 24 Following should be an error. 25 25 <DATE><TIME>|<HOST>|E|psImageSlice (FILE:LINENO) 26 Specified psRegion parameter, x0=301.000000, is out of range [0, 300].27 <DATE><TIME>|<HOST>|I|testImageSlice 28 Following should be an error. 29 <DATE><TIME>|<HOST>|E|psImageSlice (FILE:LINENO) 30 Specified psRegion parameter, y0=201.000000, is out of range [0, 200].31 <DATE><TIME>|<HOST>|I|testImageSlice 32 Following should be an error. 33 <DATE><TIME>|<HOST>|E|psImageSlice (FILE:LINENO) 34 Specified psRegion parameter, x1=301.000000=301, is out of range [0, 300].35 <DATE><TIME>|<HOST>|I|testImageSlice 36 Following should be an error. 37 <DATE><TIME>|<HOST>|E|psImageSlice (FILE:LINENO) 38 Specified psRegion parameter, y1=201.000000=201, is out of range [0, 200].26 Specified psRegion parameter, x0=301.000000, is out of range [0,299]. 27 <DATE><TIME>|<HOST>|I|testImageSlice 28 Following should be an error. 29 <DATE><TIME>|<HOST>|E|psImageSlice (FILE:LINENO) 30 Specified psRegion parameter, y0=201.000000, is out of range [0,199]. 31 <DATE><TIME>|<HOST>|I|testImageSlice 32 Following should be an error. 33 <DATE><TIME>|<HOST>|E|psImageSlice (FILE:LINENO) 34 Specified psRegion parameter, x1=301.000000=301, is out of range [0,299]. 35 <DATE><TIME>|<HOST>|I|testImageSlice 36 Following should be an error. 37 <DATE><TIME>|<HOST>|E|psImageSlice (FILE:LINENO) 38 Specified psRegion parameter, y1=201.000000=201, is out of range [0,199]. 39 39 <DATE><TIME>|<HOST>|I|testImageSlice 40 40 Following should be an error. … … 61 61 The following should be an error. 62 62 <DATE><TIME>|<HOST>|E|psImageCut (FILE:LINENO) 63 Specified line, (-1.000000,10.000000)->(240.000000,180.000000), does not entirely lie in psImage's boundaries, [0:299,0:199]. 64 <DATE><TIME>|<HOST>|I|testImageCut 65 The following should be an error. 66 <DATE><TIME>|<HOST>|E|psImageCut (FILE:LINENO) 67 Specified line, (300.000000,10.000000)->(240.000000,180.000000), does not entirely lie in psImage's boundaries, [0:299,0:199]. 68 <DATE><TIME>|<HOST>|I|testImageCut 69 The following should be an error. 70 <DATE><TIME>|<HOST>|E|psImageCut (FILE:LINENO) 71 Specified line, (20.000000,10.000000)->(-1.000000,180.000000), does not entirely lie in psImage's boundaries, [0:299,0:199]. 72 <DATE><TIME>|<HOST>|I|testImageCut 73 The following should be an error. 74 <DATE><TIME>|<HOST>|E|psImageCut (FILE:LINENO) 75 Specified line, (20.000000,10.000000)->(300.000000,180.000000), does not entirely lie in psImage's boundaries, [0:299,0:199]. 76 <DATE><TIME>|<HOST>|I|testImageCut 77 The following should be an error. 78 <DATE><TIME>|<HOST>|E|psImageCut (FILE:LINENO) 79 Specified line, (20.000000,-1.000000)->(240.000000,180.000000), does not entirely lie in psImage's boundaries, [0:299,0:199]. 80 <DATE><TIME>|<HOST>|I|testImageCut 81 The following should be an error. 82 <DATE><TIME>|<HOST>|E|psImageCut (FILE:LINENO) 83 Specified line, (20.000000,200.000000)->(240.000000,180.000000), does not entirely lie in psImage's boundaries, [0:299,0:199]. 84 <DATE><TIME>|<HOST>|I|testImageCut 85 The following should be an error. 86 <DATE><TIME>|<HOST>|E|psImageCut (FILE:LINENO) 87 Specified line, (20.000000,10.000000)->(240.000000,-1.000000), does not entirely lie in psImage's boundaries, [0:299,0:199]. 88 <DATE><TIME>|<HOST>|I|testImageCut 89 The following should be an error. 90 <DATE><TIME>|<HOST>|E|psImageCut (FILE:LINENO) 91 Specified line, (20.000000,10.000000)->(240.000000,200.000000), does not entirely lie in psImage's boundaries, [0:299,0:199]. 63 Specified psRegion parameter, x0=-1.000000, is out of range [0,300]. 64 <DATE><TIME>|<HOST>|I|testImageCut 65 The following should be an error. 66 <DATE><TIME>|<HOST>|E|psImageCut (FILE:LINENO) 67 Specified psRegion parameter, x0=300.000000, is out of range [0,300]. 68 <DATE><TIME>|<HOST>|I|testImageCut 69 The following should be an error. 70 <DATE><TIME>|<HOST>|I|testImageCut 71 The following should be an error. 72 <DATE><TIME>|<HOST>|I|testImageCut 73 The following should be an error. 74 <DATE><TIME>|<HOST>|E|psImageCut (FILE:LINENO) 75 Specified psRegion parameter, y0=-1.000000, is out of range [0,200]. 76 <DATE><TIME>|<HOST>|I|testImageCut 77 The following should be an error. 78 <DATE><TIME>|<HOST>|E|psImageCut (FILE:LINENO) 79 Specified psRegion parameter, y0=200.000000, is out of range [0,200]. 80 <DATE><TIME>|<HOST>|I|testImageCut 81 The following should be an error. 82 <DATE><TIME>|<HOST>|I|testImageCut 83 The following should be an error. 92 84 <DATE><TIME>|<HOST>|I|testImageCut 93 85 Following should be an error (NULL image). … … 148 140 /***************************** TESTPOINT ******************************************\ 149 141 * TestFile: tst_psImagePixelExtract.c * 142 * TestPoint: psImage{testImageRowColError} * 143 * TestType: Positive * 144 \**********************************************************************************/ 145 146 <DATE><TIME>|<HOST>|I|testImageRowColError 147 Following should generate error message 148 <DATE><TIME>|<HOST>|E|psImageRow (FILE:LINENO) 149 Can not operate on a NULL psImage. 150 151 ---> TESTPOINT PASSED (psImage{testImageRowColError} | tst_psImagePixelExtract.c) 152 153 /***************************** TESTPOINT ******************************************\ 154 * TestFile: tst_psImagePixelExtract.c * 150 155 * TestPoint: psImage{psImageRowColF32} * 151 156 * TestType: Positive * -
trunk/psLib/test/imageops/verified/tst_psImageStats.stderr
r5839 r6750 622 622 \**********************************************************************************/ 623 623 624 <HOST>|I|testImageCountPixel 625 Following should generate error message 624 626 <HOST>|E|psImageCountPixelMask (FILE:LINENO) 625 Can not operate on a NULL psImage. 627 Unallowable operation: psImage mask or its data is NULL. 628 <HOST>|I|testImageCountPixel 629 Following should generate error message 626 630 <HOST>|E|psImageCountPixelMask (FILE:LINENO) 627 psRegion input contains 0 pixels631 Specified psRegion parameter, x0=1.000000, is out of range [0,0]. 628 632 629 633 ---> TESTPOINT PASSED (psImage{psImageCountPixel} | tst_psImageStats.c) -
trunk/psLib/test/types/tst_psPixels.c
r6500 r6750 5 5 * @author Robert DeSonia, MHPCC 6 6 * 7 * @version $Revision: 1. 4$7 * @version $Revision: 1.5 $ 8 8 * $Name: not supported by cvs2svn $ 9 * @date $Date: 2006-0 2-28 02:53:03$9 * @date $Date: 2006-04-01 02:43:57 $ 10 10 * 11 11 * Copyright 2005 Maui High Performance Computing Center, University of Hawaii … … 378 378 psError(PS_ERR_UNKNOWN,true,"Did not expect non-NULL for invalid range"); 379 379 return 21; 380 } 381 // Test for invalid region 382 psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error for invalid range"); 383 mask = psPixelsToMask(mask,pixels,psRegionSet(0,-1,0,10),1); 384 if(mask != NULL) { 385 psError(PS_ERR_UNKNOWN,true,"Did not expect non-NULL for invalid range"); 386 return 22; 380 387 } 381 388 -
trunk/psLib/test/types/verified/tst_psPixels.stderr
r6500 r6750 44 44 <DATE><TIME>|<HOST>|E|psPixelsToMask (FILE:LINENO) 45 45 Specified psRegion, [10:0,10:0], does not specify a valid region. 46 <DATE><TIME>|<HOST>|I|testPixelsToMask 47 Following should generate an error for invalid range 48 <DATE><TIME>|<HOST>|E|psPixelsToMask (FILE:LINENO) 49 Specified psRegion, [0:10,0:-1], does not specify a valid region. 46 50 47 51 ---> TESTPOINT PASSED (psPixels{psPixelsToMask} | tst_psPixels.c)
Note:
See TracChangeset
for help on using the changeset viewer.
