Changeset 2835
- Timestamp:
- Dec 27, 2004, 3:43:17 PM (22 years ago)
- Location:
- trunk/psLib
- Files:
-
- 2 edited
-
src/image/psImageManip.c (modified) (7 diffs)
-
test/image/tst_psImageManip.c (modified) (21 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/image/psImageManip.c
r2807 r2835 10 10 * @author Ross Harman, MHPCC 11 11 * 12 * @version $Revision: 1.3 1$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-12-2 3 19:14:15$12 * @version $Revision: 1.32 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-12-28 01:42:28 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 195 195 psU32 imageColLimit; 196 196 psElemType type; 197 psU32 pixelsOverlaid = 0; 197 198 198 199 if (image == NULL || overlay == NULL) { 199 200 psError(PS_ERR_BAD_PARAMETER_NULL, true, 200 201 PS_ERRORTEXT_psImage_IMAGE_NULL); 201 return 1;202 return pixelsOverlaid; 202 203 } 203 204 … … 205 206 psError(PS_ERR_BAD_PARAMETER_NULL, true, 206 207 PS_ERRORTEXT_psImageManip_OPERATION_NULL); 207 return 1;208 return pixelsOverlaid; 208 209 } 209 210 … … 218 219 PS_ERRORTEXT_psImageManip_OVERLAY_TYPE_MISMATCH, 219 220 typeStrOverlay, typeStr); 220 return 2;221 return pixelsOverlaid; 221 222 } 222 223 … … 238 239 col0, imageColLimit, row0, imageRowLimit, 239 240 imageNumCols, imageNumRows); 240 return 3; 241 } 242 243 switch (type) { 244 245 #define psImageOverlayCase(DATATYPE) \ 246 case PS_TYPE_##DATATYPE: \ 247 for (psU32 row=row0;row<imageRowLimit;row++) { \ 241 return pixelsOverlaid; 242 } 243 244 245 #define psImageOverlayLoop(DATATYPE,OP) { \ 246 for (int row=row0;row<imageRowLimit;row++) { \ 248 247 ps##DATATYPE* imageRow = image->data.DATATYPE[row]; \ 249 248 ps##DATATYPE* overlayRow = overlay->data.DATATYPE[row-row0]; \ 250 for (psU32 col=col0;col<imageColLimit;col++) { \ 251 switch (*op) { \ 252 case '+': \ 253 imageRow[col] += overlayRow[col-col0]; \ 254 break; \ 255 case '-': \ 256 imageRow[col] -= overlayRow[col-col0]; \ 257 break; \ 258 case '*': \ 259 imageRow[col] *= overlayRow[col-col0]; \ 260 break; \ 261 case '/': \ 262 imageRow[col] /= overlayRow[col-col0]; \ 263 break; \ 264 case '=': \ 265 imageRow[col] = overlayRow[col-col0]; \ 266 break; \ 267 default: \ 268 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ 269 PS_ERRORTEXT_psImageManip_OVERLAY_OPERATOR_INVALID, \ 270 op); \ 271 return 5; \ 272 } \ 273 } \ 274 } \ 275 break; 276 249 for (int col=col0;col<imageColLimit;col++) { \ 250 imageRow[col] OP overlayRow[col-col0]; \ 251 } \ 252 } \ 253 pixelsOverlaid += (imageRowLimit - row0) * (imageColLimit - col0); \ 254 } 255 256 #define psImageOverlayCase(DATATYPE) \ 257 case PS_TYPE_##DATATYPE: \ 258 switch (*op) { \ 259 case '+': \ 260 psImageOverlayLoop(DATATYPE,+=); \ 261 break; \ 262 case '-': \ 263 psImageOverlayLoop(DATATYPE,-=); \ 264 break; \ 265 case '*': \ 266 psImageOverlayLoop(DATATYPE,*=); \ 267 break; \ 268 case '/': \ 269 psImageOverlayLoop(DATATYPE,/=); \ 270 break; \ 271 case '=': \ 272 psImageOverlayLoop(DATATYPE,=); \ 273 break; \ 274 default: \ 275 psError(PS_ERR_BAD_PARAMETER_VALUE, true, \ 276 PS_ERRORTEXT_psImageManip_OVERLAY_OPERATOR_INVALID, \ 277 op); \ 278 return pixelsOverlaid; \ 279 } \ 280 break; 281 282 switch (type) { 277 283 psImageOverlayCase(U8); 278 284 psImageOverlayCase(U16); 279 // psImageOverlayCase(U32);Not a requirement280 // psImageOverlayCase(U64);Not a requirement285 psImageOverlayCase(U32); // Not a requirement 286 psImageOverlayCase(U64); // Not a requirement 281 287 psImageOverlayCase(S8); 282 288 psImageOverlayCase(S16); 283 // psImageOverlayCase(S32);Not a requirement284 // psImageOverlayCase(S64);Not a requirement289 psImageOverlayCase(S32); // Not a requirement 290 psImageOverlayCase(S64); // Not a requirement 285 291 psImageOverlayCase(F32); 286 292 psImageOverlayCase(F64); … … 294 300 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 295 301 typeStr); 296 return 6;297 } 298 } 299 300 return 0;302 return pixelsOverlaid; 303 } 304 } 305 306 return pixelsOverlaid; 301 307 } 302 308 … … 832 838 833 839 /* optimized public domain rotation routine by Karl Lager 834 * 835 * float cosT,sinT; 836 * cosT = cos(t); 837 * sinT = sin(t); 838 * for (y = min_y; y <= max_y; y++) { 839 * x' = min_x * cosT + y * sinT + x1'; 840 * y' = y * cosT - min_x * sinT + y1'; 841 * for (x = min_x; x <= max_x; x++) { 840 * 841 * float cosT,sinT; 842 * cosT = cos(t); 843 * sinT = sin(t); 844 * for (y = min_y; y <= max_y; y++) { 845 * x' = min_x * cosT + y * sinT + x1'; 846 * y' = y * cosT - min_x * sinT + y1'; 847 * for (x = min_x; x <= max_x; x++) { 842 848 * if (x', y') is in the bounds of the bitmap, get pixel 843 * (x', y') and plot the pixel to (x, y) on screen. 844 * x' += cosT; 845 * y' -= sinT; 849 * (x', y') and plot the pixel to (x, y) on screen. 850 * x' += cosT; 851 * y' -= sinT; 846 852 * } 847 * } 853 * } 848 854 */ 849 855 -
trunk/psLib/test/image/tst_psImageManip.c
r2754 r2835 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1.3 2$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-12- 18 00:01:08$8 * @version $Revision: 1.33 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-12-28 01:43:17 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 331 331 1. Create a complex image with a wide range of complex values 332 332 333 2. call psImageClipComplexRegion with min and max where there is at least 333 2. call psImageClipComplexRegion with min and max where there is at least 334 334 2 pixels in the image above) that is: 335 335 a) real(p) < real(min) && complex(p) < complex(min), … … 347 347 4. verify that all pixels in case (d) are unchanged from input 348 348 349 5. verify that all pixels in case (e), (f), (g), (h), and (i) have the 349 5. verify that all pixels in case (e), (f), (g), (h), and (i) have the 350 350 value vmax 351 351 … … 606 606 */ 607 607 608 609 610 608 #define testOverlayTypeOP(DATATYPE,OP,OPSTRING) \ 611 609 img = psImageAlloc(c,r,PS_TYPE_##DATATYPE); \ … … 624 622 } \ 625 623 retVal = psImageOverlaySection(img,img2,c/4,r/4,OPSTRING); \ 626 if (retVal != 0) { \ 627 psError(PS_ERR_UNKNOWN, true,"psImageOverlaySection returned non-zero %s op",OPSTRING); \ 624 if (retVal == 0) { \ 625 psError(PS_ERR_UNKNOWN, true,"psImageOverlaySection returned zero with %s op", \ 626 OPSTRING); \ 628 627 return 1; \ 629 628 } \ … … 705 704 "within image boundaries"); 706 705 retVal = psImageOverlaySection(img,img2,c/4,r/4,"+"); 707 if (retVal == 0) {708 psError(PS_ERR_UNKNOWN, true,"psImageOverlaySection returned zero even though"709 " overlay too big");706 if (retVal != 0) { 707 psError(PS_ERR_UNKNOWN, true,"psImageOverlaySection did not return " 708 "zero even though overlay too big"); 710 709 return 3; 711 710 } … … 728 727 psLogMsg(__func__,PS_LOG_INFO,"Following should error as overlay is NULL"); 729 728 retVal = psImageOverlaySection(img,NULL,c/4,r/4,"+"); 730 if (retVal == 0) {731 psError(PS_ERR_UNKNOWN, true,"psImageOverlaySection returned zero even though"732 " overlay too big");729 if (retVal != 0) { 730 psError(PS_ERR_UNKNOWN, true,"psImageOverlaySection did not return " 731 "zero even though overlay too big"); 733 732 return 5; 734 733 } … … 750 749 psLogMsg(__func__,PS_LOG_INFO,"Following should error as image input is NULL"); 751 750 retVal = psImageOverlaySection(NULL,img2,c/4,r/4,"+"); 752 if (retVal == 0) {753 psError(PS_ERR_UNKNOWN, true,"psImageOverlaySection returned zero even though "751 if (retVal != 0) { 752 psError(PS_ERR_UNKNOWN, true,"psImageOverlaySection returned non-zero even though " 754 753 "overlay too big"); 755 754 return 7; … … 763 762 psLogMsg(__func__,PS_LOG_INFO,"Following should error as operator is invalid"); 764 763 retVal = psImageOverlaySection(img,img2,0,0,"$"); 765 if (retVal == 0) {766 psError(PS_ERR_UNKNOWN, true,"psImageOverlaySection returned zero even though "764 if (retVal != 0) { 765 psError(PS_ERR_UNKNOWN, true,"psImageOverlaySection returned non-zero even though " 767 766 "overlay operator is invalid"); 768 767 return 8; … … 776 775 psLogMsg(__func__,PS_LOG_INFO,"Following should error as operator is invalid"); 777 776 retVal = psImageOverlaySection(img,img2,0,0,NULL); 778 if(retVal == 0) {779 psError(PS_ERR_UNKNOWN, true,"psImageOverlaySection returned zero even though "777 if(retVal != 0) { 778 psError(PS_ERR_UNKNOWN, true,"psImageOverlaySection returned non-zero even though " 780 779 "overlay operator is NULL"); 781 780 return 9; … … 783 782 784 783 /* 785 Verify the return integer is equal to non-zero and program execution 784 Verify the return integer is equal to non-zero and program execution 786 785 doesn't stop, if overlay image is a different type than the input image 787 786 */ … … 789 788 "a different type"); 790 789 retVal = psImageOverlaySection(img,img3,0,0,"+"); 791 if(retVal == 0) {792 psError(PS_ERR_UNKNOWN, true,"psImageOverlaySection returned zero eventhough "790 if(retVal != 0) { 791 psError(PS_ERR_UNKNOWN, true,"psImageOverlaySection returned nonzero eventhough " 793 792 " overlay image type is different than input image."); 794 793 return 10; 795 }796 797 /*798 Verify the return integer is equal to non-zero and program execution799 doesn't stop, if invalid input and overlay images800 */801 psLogMsg(__func__,PS_LOG_INFO,"Following should error as overlay and "802 "image are not valid for the psImageOverlaySection function.");803 retVal = psImageOverlaySection(img3,img4,0,0,"+");804 if(retVal == 0) {805 psError(PS_ERR_UNKNOWN, true,"psImageOverlaySection returned zero eventhough "806 "overlay and image type are invalid type.");807 return 11;808 794 } 809 795 … … 819 805 } 820 806 retVal = psImageOverlaySection(img,img2,0,0,"/"); 821 if (retVal != 0) {822 psError(PS_ERR_UNKNOWN, true,"psImageOverlaySection returned non-zero when "807 if (retVal == 0) { 808 psError(PS_ERR_UNKNOWN, true,"psImageOverlaySection returned zero when " 823 809 "checking divide-by-zero."); 824 810 return 12; … … 837 823 838 824 /* 839 This function shall generate a rescaled version of a psImage structure 825 This function shall generate a rescaled version of a psImage structure 840 826 derived from a specified statistics method. 841 827 */ … … 852 838 853 839 /* 854 Verify the returned psImage structure contains expected values, if the 855 input parameter input contains known data, the input scale is a known 856 value with a known statistical method specified in stats. Cases should 857 include at least two different scales and statistical methods. Comparison 858 of expected values should include a delta to allow testing on different 840 Verify the returned psImage structure contains expected values, if the 841 input parameter input contains known data, the input scale is a known 842 value with a known statistical method specified in stats. Cases should 843 include at least two different scales and statistical methods. Comparison 844 of expected values should include a delta to allow testing on different 859 845 platforms. 860 846 */ … … 1094 1080 1095 1081 /* 1096 The function psImageRoll shall generate a new psImage structure by 1082 The function psImageRoll shall generate a new psImage structure by 1097 1083 rolling the input image the correponding number of pixels in the vertical 1098 1084 and/or horizontal direction. The image output image shall be the same size 1099 as the input image. Values which roll off the image are wrapped to the 1085 as the input image. Values which roll off the image are wrapped to the 1100 1086 other side. 1101 1087 1102 Verify the returned psImage structure contains expected values, if the 1103 input image contains known values and the roll performed is known. 1104 Cases should include no roll, vertical roll, horizontal roll and 1105 combination vertical/horizontal rolls. Positive and negative rolls 1088 Verify the returned psImage structure contains expected values, if the 1089 input image contains known values and the roll performed is known. 1090 Cases should include no roll, vertical roll, horizontal roll and 1091 combination vertical/horizontal rolls. Positive and negative rolls 1106 1092 should be performed. 1107 1093 */ … … 1274 1260 /* 1275 1261 1276 This function shall calculate a new psImage structure based upon the 1277 rotation of a given psImage structure. The center of rotation shall be the 1262 This function shall calculate a new psImage structure based upon the 1263 rotation of a given psImage structure. The center of rotation shall be the 1278 1264 center pixel of the input image. 1279 1265 1280 The following steps of the testpoint are done manually via inspection of 1266 The following steps of the testpoint are done manually via inspection of 1281 1267 temp/fOut.fits & temp/sOut.fits. 1282 1268 1283 * Verify the returned psImage structure contains expected values, if 1284 the input parameter psImage contains known values. Cases should 1285 include rotations of 0, 45, 90, 135, 180, 225, 270, 315, 360 and at leat one 1269 * Verify the returned psImage structure contains expected values, if 1270 the input parameter psImage contains known values. Cases should 1271 include rotations of 0, 45, 90, 135, 180, 225, 270, 315, 360 and at leat one 1286 1272 other arbitrary angle. Cases of the input image should include image 1287 1273 with a center pixel and an image without a center pixel. … … 1541 1527 /* psImageShift: 1542 1528 1543 This functions shall generate a new psImage structure by shifting the 1544 input psImage structure a specified number of pixels in the horizontal 1529 This functions shall generate a new psImage structure by shifting the 1530 input psImage structure a specified number of pixels in the horizontal 1545 1531 and/or vertical directions. 1546 1532 1547 Verify the returned psImage structure contains expected values, if the 1548 input psImage structure contains known values and a know shift in the 1549 vertical and/or horizontal directions. Cases should include no shift, 1550 vertical only(up,down), horizontal only(right, left), and combination 1551 shift. Cases should include fractional shifts. Comparison of expected 1552 values should include a delta to allow for testing on different 1533 Verify the returned psImage structure contains expected values, if the 1534 input psImage structure contains known values and a know shift in the 1535 vertical and/or horizontal directions. Cases should include no shift, 1536 vertical only(up,down), horizontal only(right, left), and combination 1537 shift. Cases should include fractional shifts. Comparison of expected 1538 values should include a delta to allow for testing on different 1553 1539 platforms. 1554 1540 1555 Verify the returned psImage structure contains values for pixels not in 1541 Verify the returned psImage structure contains values for pixels not in 1556 1542 the original image set to the input parameter exposed. 1557 1543 … … 1590 1576 1591 1577 /* 1592 Verify the returned psImage structure pointer is equal to the input 1578 Verify the returned psImage structure pointer is equal to the input 1593 1579 parameter out if provided. 1594 1580 */ … … 1603 1589 1604 1590 /* 1605 Verify the returned psImage structure pointer is null and program 1591 Verify the returned psImage structure pointer is null and program 1606 1592 execution doesn't stop, if the input psImage structure pointer is null. 1607 1593 */ … … 1820 1806 psErrorClear(); 1821 1807 psImage* invImage = psImageAlloc(cols,rows,PS_TYPE_PTR); 1808 memset(invImage->rawDataBuffer,0,cols*rows*sizeof(psPtr)); // make sure the image is of all NULLs 1822 1809 result = psImageResample(result,invImage,2,PS_INTERPOLATE_FLAT); 1823 1810 if (result != NULL) {
Note:
See TracChangeset
for help on using the changeset viewer.
