Changeset 5137 for trunk/psLib/src
- Timestamp:
- Sep 26, 2005, 12:35:54 PM (21 years ago)
- Location:
- trunk/psLib/src
- Files:
-
- 7 edited
-
imageops/psImageStats.c (modified) (2 diffs)
-
imageops/psImageStats.h (modified) (2 diffs)
-
mathtypes/psImage.h (modified) (2 diffs)
-
mathtypes/psVector.c (modified) (2 diffs)
-
mathtypes/psVector.h (modified) (2 diffs)
-
types/psPixels.c (modified) (3 diffs)
-
types/psPixels.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/imageops/psImageStats.c
r5096 r5137 9 9 * @author GLG, MHPCC 10 10 * 11 * @version $Revision: 1.8 0$ $Name: not supported by cvs2svn $12 * @date $Date: 2005-09-2 2 22:49:29$11 * @version $Revision: 1.81 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2005-09-26 22:35:53 $ 13 13 * 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 638 638 // count number of pixels with given mask value 639 639 long psImageCountPixelMask (psImage *mask, 640 psRegion region, 640 641 psMaskType value) 641 642 { 642 643 long Npixels = 0; 643 644 for (long i = 0; i < mask->numRows; i++) { 645 for (long j = 0; j < mask->numCols; j++) { 646 if (mask->data.U8[i][j] & value) { 647 Npixels ++; 648 } 649 } 644 int x0 = 0; 645 int y0 = 0; 646 int x1 = 0; 647 int y1 = 0; 648 psElemType type; 649 if (mask == NULL) { 650 psError(PS_ERR_BAD_PARAMETER_NULL, true, 651 PS_ERRORTEXT_psImage_IMAGE_NULL); 652 return -1; 653 } 654 if (region.x1 > mask->numCols || region.y1 > mask->numRows) { 655 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 656 "psRegion input is outside of image boundary\n"); 657 return -1; 658 } 659 if (region.x0 <= 0 || region.x1 <= 0 || region.y0 <= 0 || region.y1 <= 0) { 660 region = psRegionForImage(mask, region); 661 } 662 if (region.x0 > region.x1 || region.y0 > region.y1) { 663 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 664 "Invalid region. Lower boundary greater than upper boundary.\n"); 665 return -1; 666 } 667 if (region.x0 == region.x1 || region.y0 == region.y1) { 668 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 669 "psRegion input contains 0 pixels\n"); 670 return -1; 671 } 672 673 x0 = (int)(roundf(region.x0)); 674 x1 = (int)(roundf(region.x1)); 675 y0 = (int)(roundf(region.y0)); 676 y1 = (int)(roundf(region.y1)); 677 678 type = mask->type.type; 679 680 switch (type) { 681 case PS_TYPE_U8: 682 for (long i = x0; i < x1; i++) { 683 for (long j = y0; j < y1; j++) { 684 if (mask->data.U8[i][j] & value) { 685 Npixels ++; 686 } 687 } 688 } 689 break; 690 case PS_TYPE_S8: 691 case PS_TYPE_S16: 692 case PS_TYPE_S32: 693 case PS_TYPE_S64: 694 case PS_TYPE_U16: 695 case PS_TYPE_U32: 696 case PS_TYPE_U64: 697 case PS_TYPE_F32: 698 case PS_TYPE_F64: 699 case PS_TYPE_C32: 700 case PS_TYPE_C64: 701 default: 702 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 703 PS_ERRORTEXT_psImage_IMAGE_MASK_TYPE, type, PS_TYPE_U8); 704 return -1; 650 705 } 651 706 return (Npixels); 652 } 653 707 708 709 } 710 -
trunk/psLib/src/imageops/psImageStats.h
r5089 r5137 9 9 * @author GLG, MHPCC 10 10 * 11 * @version $Revision: 1.2 6$ $Name: not supported by cvs2svn $12 * @date $Date: 2005-09-2 2 02:32:00$11 * @version $Revision: 1.27 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2005-09-26 22:35:53 $ 13 13 * 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 85 85 ); 86 86 87 /** Returns the number of pixels in the image region which satisfy any of the mask bits. 88 * 89 * An error (eg, invalid image, invalid region) results in a return value of -1. 90 * The vector must be U8. 91 * 92 * @return long: the number of pixels counted 93 */ 87 94 long psImageCountPixelMask( 88 psImage *mask, 89 psMaskType value 95 psImage *mask, ///< input image to count 96 psRegion region, ///< input region of image 97 psMaskType value ///< the mask value to satisfy 90 98 ); 91 99 -
trunk/psLib/src/mathtypes/psImage.h
r5101 r5137 11 11 * @author Ross Harman, MHPCC 12 12 * 13 * @version $Revision: 1.7 1$ $Name: not supported by cvs2svn $14 * @date $Date: 2005-09-2 3 00:04:36$13 * @version $Revision: 1.72 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2005-09-26 22:35:53 $ 15 15 * 16 16 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 109 109 ; 110 110 111 112 111 /** Checks the type of a particular pointer. 113 112 * -
trunk/psLib/src/mathtypes/psVector.c
r5114 r5137 9 9 * @author Robert DeSonia, MHPCC 10 10 * 11 * @version $Revision: 1.5 6$ $Name: not supported by cvs2svn $12 * @date $Date: 2005-09-2 4 00:17:44$11 * @version $Revision: 1.57 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2005-09-26 22:35:53 $ 13 13 * 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 948 948 } 949 949 950 // count number of pixels with given mask value 951 long psVectorCountPixelMask (psVector *mask, 952 psMaskType value) 953 { 954 long Npixels = 0; 955 if (mask == NULL) { 956 psError(PS_ERR_BAD_PARAMETER_NULL, true, PS_ERRORTEXT_psVector_NULL); 957 Npixels = -1; 958 return Npixels; 959 } 960 961 psElemType type; 962 type = mask->type.type; 963 964 switch (type) { 965 case PS_TYPE_U8: 966 for (long i = 0; i < mask->n; i++) { 967 if (mask->data.U8[i] & value) { 968 Npixels ++; 969 } 970 } 971 break; 972 case PS_TYPE_S8: 973 case PS_TYPE_S16: 974 case PS_TYPE_S32: 975 case PS_TYPE_S64: 976 case PS_TYPE_U16: 977 case PS_TYPE_U32: 978 case PS_TYPE_U64: 979 case PS_TYPE_F32: 980 case PS_TYPE_F64: 981 case PS_TYPE_C32: 982 case PS_TYPE_C64: 983 default: 984 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 985 PS_ERRORTEXT_psVector_UNSUPPORTED_TYPE, type); 986 return -1; 987 } 988 return (Npixels); 989 } 990 -
trunk/psLib/src/mathtypes/psVector.h
r5114 r5137 11 11 * @author Ross Harman, MHPCC 12 12 * 13 * @version $Revision: 1.4 8$ $Name: not supported by cvs2svn $14 * @date $Date: 2005-09-2 4 00:17:44$13 * @version $Revision: 1.49 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2005-09-26 22:35:53 $ 15 15 * 16 16 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 247 247 ); 248 248 249 /** Returns the number of pixels in the vector which satisfy any of the mask bits. 250 * 251 * An error (eg, invalid vector) results in a return value of -1. The vector must be U8. 252 * 253 * @return long: the number of pixels counted 254 */ 255 long psVectorCountPixelMask( 256 psVector *mask, ///< input vector to count 257 psMaskType value ///< the mask value to satisfy 258 ); 259 249 260 /// @} 250 261 -
trunk/psLib/src/types/psPixels.c
r5114 r5137 7 7 * @author Robert DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1.1 8$ $Name: not supported by cvs2svn $10 * @date $Date: 2005-09-2 4 00:17:44$9 * @version $Revision: 1.19 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2005-09-26 22:35:53 $ 11 11 * 12 12 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 345 345 return false; 346 346 } 347 if(position < 0) 347 if(position < 0) { 348 348 position += pixels->n; 349 } 349 350 if(position < 0) { 350 351 psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid position. Negative number too large\n"); … … 382 383 return out; 383 384 } 384 if (position < 0) 385 if (position < 0) { 385 386 position += pixels->n; 387 } 386 388 if (position < 0) { 387 389 psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid position. Negative number too large\n"); -
trunk/psLib/src/types/psPixels.h
r5114 r5137 7 7 * @author Robert DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1.1 4$ $Name: not supported by cvs2svn $10 * @date $Date: 2005-09-2 4 00:17:44$9 * @version $Revision: 1.15 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2005-09-26 22:35:53 $ 11 11 * 12 12 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
Note:
See TracChangeset
for help on using the changeset viewer.
