Changeset 2105
- Timestamp:
- Oct 13, 2004, 3:22:59 PM (22 years ago)
- Location:
- trunk/psLib
- Files:
-
- 9 edited
-
src/image/psImage.c (modified) (2 diffs)
-
src/image/psImage.h (modified) (2 diffs)
-
src/image/psImageExtraction.c (modified) (2 diffs)
-
src/image/psImageManip.c (modified) (3 diffs)
-
src/mathtypes/psImage.c (modified) (2 diffs)
-
src/mathtypes/psImage.h (modified) (2 diffs)
-
test/image/tst_psImageManip.c (modified) (4 diffs)
-
test/image/verified/tst_psImageExtraction.stderr (modified) (2 diffs)
-
test/image/verified/tst_psImageManip.stderr (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/image/psImage.c
r2067 r2105 10 10 * @author Ross Harman, MHPCC 11 11 * 12 * @version $Revision: 1. 49$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-10-1 3 00:10:50$12 * @version $Revision: 1.50 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-10-14 01:22:59 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 441 441 psF64 unexposedValue) \ 442 442 { \ 443 int intX = (int) round((psF64)(x) - 0.5 ); \444 int intY = (int) round((psF64)(y) - 0.5 ); \443 int intX = (int) round((psF64)(x) - 0.5 + FLT_EPSILON); \ 444 int intY = (int) round((psF64)(y) - 0.5 + FLT_EPSILON); \ 445 445 int lastX = input->numCols - 1; \ 446 446 int lastY = input->numRows - 1; \ -
trunk/psLib/src/image/psImage.h
r2067 r2105 11 11 * @author Ross Harman, MHPCC 12 12 * 13 * @version $Revision: 1.4 0$ $Name: not supported by cvs2svn $14 * @date $Date: 2004-10-1 3 00:10:50$13 * @version $Revision: 1.41 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2004-10-14 01:22:59 $ 15 15 * 16 16 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 31 31 */ 32 32 typedef enum { 33 PS_INTERPOLATE_FLAT ,///< 'flat' interpolation (nearest pixel)33 PS_INTERPOLATE_FLAT = 1, ///< 'flat' interpolation (nearest pixel) 34 34 PS_INTERPOLATE_BILINEAR, ///< bi-linear interpolation 35 35 PS_INTERPOLATE_BICUBIC, ///< bi-cubic interpolation 36 PS_INTERPOLATE_SINC ///< sinc interpolation 36 PS_INTERPOLATE_SINC, ///< sinc interpolation 37 PS_INTERPOLATE_NUM_MODES ///< end-marker of list of modes; not a valid interpolation mode 37 38 } psImageInterpolateMode; 38 39 -
trunk/psLib/src/image/psImageExtraction.c
r2093 r2105 9 9 * @author Robert DeSonia, MHPCC 10 10 * 11 * @version $Revision: 1.2 5$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-10-1 3 23:34:57$11 * @version $Revision: 1.26 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-10-14 01:22:59 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 543 543 } 544 544 545 if (mode < PS_INTERPOLATE_FLAT || mode >= PS_INTERPOLATE_NUM_MODES) { 546 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageResample", 547 PS_ERR_BAD_PARAMETER_VALUE, true, 548 PS_ERRORTEXT_psImageManip_INTERPOLATION_MODE_UNSUPPORTED, 549 mode); 550 psFree(out); 551 return NULL; 552 } 553 545 554 if (mask != NULL) { 546 555 if (numRows != mask->numRows || numCols != mask->numCols) { -
trunk/psLib/src/image/psImageManip.c
r1941 r2105 10 10 * @author Ross Harman, MHPCC 11 11 * 12 * @version $Revision: 1.2 7$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-10- 02 02:08:00$12 * @version $Revision: 1.28 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-10-14 01:22:59 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 569 569 return NULL; 570 570 } 571 572 if (scale < 1) { 573 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageResample", 574 PS_ERR_BAD_PARAMETER_VALUE, true, 575 PS_ERRORTEXT_psImageManip_SCALE_NOT_POSITIVE, 576 scale); 577 psFree(out); 578 return NULL; 579 } 580 581 if (mode < PS_INTERPOLATE_FLAT || mode >= PS_INTERPOLATE_NUM_MODES) { 582 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageResample", 583 PS_ERR_BAD_PARAMETER_VALUE, true, 584 PS_ERRORTEXT_psImageManip_INTERPOLATION_MODE_UNSUPPORTED, 585 mode); 586 psFree(out); 587 return NULL; 588 } 589 571 590 // create an output image of the same size 572 591 // and type … … 582 601 float inRow = (float)row * invScale; \ 583 602 for (int col=0;col<outCols;col++) { \ 584 rowData[col] = psImagePixelInterpolate(in, inRow,(float)col*invScale,NULL,0,0,mode); \603 rowData[col] = psImagePixelInterpolate(in,(float)col*invScale,inRow,NULL,0,0,mode); \ 585 604 } \ 586 605 } \ -
trunk/psLib/src/mathtypes/psImage.c
r2067 r2105 10 10 * @author Ross Harman, MHPCC 11 11 * 12 * @version $Revision: 1. 49$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-10-1 3 00:10:50$12 * @version $Revision: 1.50 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-10-14 01:22:59 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 441 441 psF64 unexposedValue) \ 442 442 { \ 443 int intX = (int) round((psF64)(x) - 0.5 ); \444 int intY = (int) round((psF64)(y) - 0.5 ); \443 int intX = (int) round((psF64)(x) - 0.5 + FLT_EPSILON); \ 444 int intY = (int) round((psF64)(y) - 0.5 + FLT_EPSILON); \ 445 445 int lastX = input->numCols - 1; \ 446 446 int lastY = input->numRows - 1; \ -
trunk/psLib/src/mathtypes/psImage.h
r2067 r2105 11 11 * @author Ross Harman, MHPCC 12 12 * 13 * @version $Revision: 1.4 0$ $Name: not supported by cvs2svn $14 * @date $Date: 2004-10-1 3 00:10:50$13 * @version $Revision: 1.41 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2004-10-14 01:22:59 $ 15 15 * 16 16 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 31 31 */ 32 32 typedef enum { 33 PS_INTERPOLATE_FLAT ,///< 'flat' interpolation (nearest pixel)33 PS_INTERPOLATE_FLAT = 1, ///< 'flat' interpolation (nearest pixel) 34 34 PS_INTERPOLATE_BILINEAR, ///< bi-linear interpolation 35 35 PS_INTERPOLATE_BICUBIC, ///< bi-cubic interpolation 36 PS_INTERPOLATE_SINC ///< sinc interpolation 36 PS_INTERPOLATE_SINC, ///< sinc interpolation 37 PS_INTERPOLATE_NUM_MODES ///< end-marker of list of modes; not a valid interpolation mode 37 38 } psImageInterpolateMode; 38 39 -
trunk/psLib/test/image/tst_psImageManip.c
r1943 r2105 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1.2 8$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-10- 02 02:23:05$8 * @version $Revision: 1.29 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-10-14 01:22:59 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 34 34 static int testImageShift(void); 35 35 static int testImageShiftCase(int cols, int rows, float colShift,float rowShift); 36 static int testImageResample(void); 36 37 37 38 testDescription tests[] = { … … 44 45 {testImageRotate,560,"psImageRotate",0,false}, 45 46 {testImageShift,561,"psImageShift",0,false}, 47 {testImageResample,743,"psImageResample",0,false}, 46 48 {NULL} 47 49 }; … … 1704 1706 return 0; 1705 1707 } 1708 1709 static int testImageResample(void) 1710 { 1711 1712 int rows = 60; 1713 int cols = 80; 1714 psImage* result = NULL; 1715 int scale = 4; 1716 psErr* err; 1717 1718 psImage* image = psImageAlloc(cols,rows,PS_TYPE_F32); 1719 for(int row=0;row<rows;row++) { 1720 psF32* imageRow = image->data.F32[row]; 1721 for (int col=0;col<cols;col++) { 1722 imageRow[col] = row+2*col; 1723 } 1724 } 1725 result = psImageCopy(NULL,image,PS_TYPE_F64); 1726 psImage* orig = result; 1727 result = psImageResample(result,image,scale,PS_INTERPOLATE_FLAT); 1728 1729 if (result == NULL) { 1730 psLogMsg(__func__,PS_LOG_ERROR, 1731 "NULL return unexpected"); 1732 return 1; 1733 } 1734 1735 if (result != orig) { 1736 psLogMsg(__func__,PS_LOG_ERROR,"failure to recycle image."); 1737 return 2; 1738 } 1739 1740 if (result->type.type != PS_TYPE_F32) { 1741 psLogMsg(__func__,PS_LOG_ERROR,"unexpected type"); 1742 return 3; 1743 } 1744 1745 1746 if (result->numCols != image->numCols*scale || 1747 result->numRows != image->numRows*scale) { 1748 psLogMsg(__func__,PS_LOG_ERROR,"The size of the result is %dx%d, but %dx%d was expected.", 1749 result->numCols,result->numRows, 1750 image->numCols*scale, image->numRows*scale); 1751 return 4; 1752 } 1753 1754 psF32 truthValue; 1755 for(int row=0;row<result->numRows;row++) { 1756 for (int col=0;col<result->numCols;col++) { 1757 truthValue = psImagePixelInterpolate(image, 1758 (float)col/(float)scale,(float)row/(float)scale, 1759 NULL,0,-1,PS_INTERPOLATE_FLAT); 1760 if (fabs(truthValue - result->data.F32[row][col]) > FLT_EPSILON) { 1761 psLogMsg(__func__,PS_LOG_ERROR,"value bad at (%d,%d). Got %g, expected %g.", 1762 col,row,result->data.F32[row][col], truthValue); 1763 return 5; 1764 } 1765 } 1766 } 1767 1768 // verify that image=null is handled properly. 1769 psErrorClear(); 1770 result = psImageResample(result,NULL,scale,PS_INTERPOLATE_FLAT); 1771 1772 if (result != NULL) { 1773 psLogMsg(__func__,PS_LOG_ERROR, 1774 "return was not NULL, as expected."); 1775 return 6; 1776 } 1777 err = psErrorLast(); 1778 if (err->code != PS_ERR_BAD_PARAMETER_NULL) { 1779 psLogMsg(__func__,PS_LOG_ERROR, 1780 "error message was not appropriate type."); 1781 return 7; 1782 } 1783 psFree(err); 1784 1785 // verify that scale < 1 is handled properly 1786 psErrorClear(); 1787 result = psImageResample(result,image,0,PS_INTERPOLATE_FLAT); 1788 1789 if (result != NULL) { 1790 psLogMsg(__func__,PS_LOG_ERROR, 1791 "return was not NULL, as expected."); 1792 return 8; 1793 } 1794 err = psErrorLast(); 1795 if (err->code != PS_ERR_BAD_PARAMETER_VALUE) { 1796 psLogMsg(__func__,PS_LOG_ERROR, 1797 "error message was not appropriate type."); 1798 return 9; 1799 } 1800 psFree(err); 1801 1802 // verify that invalid interpolation mode is handled properly 1803 psErrorClear(); 1804 result = psImageResample(result,image,2,0); 1805 1806 if (result != NULL) { 1807 psLogMsg(__func__,PS_LOG_ERROR, 1808 "return was not NULL, as expected."); 1809 return 10; 1810 } 1811 err = psErrorLast(); 1812 if (err->code != PS_ERR_BAD_PARAMETER_VALUE) { 1813 psLogMsg(__func__,PS_LOG_ERROR, 1814 "error message was not appropriate type."); 1815 return 11; 1816 } 1817 psFree(err); 1818 1819 psFree(image); 1820 psFree(result); 1821 1822 return 0; 1823 } 1824 -
trunk/psLib/test/image/verified/tst_psImageExtraction.stderr
r2095 r2105 138 138 Following should be an error. 139 139 <DATE><TIME>|<HOST>|E|psLib.image.psImageSlice 140 Input psImage mask size, 2000x1000, does not match psImage input size, 1 869636978x1635018016.141 <DATE><TIME>|<HOST>|I|testImageSlice 142 Following should be an error. 143 <DATE><TIME>|<HOST>|E|psLib.image.psImageSlice 144 Input psImage mask size, 2000x1000, does not match psImage input size, 1 869636978x1635018016.140 Input psImage mask size, 2000x1000, does not match psImage input size, 1919250543x543519841. 141 <DATE><TIME>|<HOST>|I|testImageSlice 142 Following should be an error. 143 <DATE><TIME>|<HOST>|E|psLib.image.psImageSlice 144 Input psImage mask size, 2000x1000, does not match psImage input size, 1919250543x543519841. 145 145 <DATE><TIME>|<HOST>|I|testImageSlice 146 146 Following should be an error. … … 150 150 Following should be an error. 151 151 <DATE><TIME>|<HOST>|E|psLib.image.psImageSlice 152 Input psImage mask size, 2000x1000, does not match psImage input size, 1 869636978x1635018016.153 <DATE><TIME>|<HOST>|I|testImageSlice 154 Following should be an error. 155 <DATE><TIME>|<HOST>|E|psLib.image.psImageSlice 156 Input psImage mask size, 2000x1000, does not match psImage input size, 1 869636978x1635018016.157 <DATE><TIME>|<HOST>|I|testImageSlice 158 Following should be an error. 159 <DATE><TIME>|<HOST>|E|psLib.image.psImageSlice 160 Input psImage mask size, 2000x1000, does not match psImage input size, 1 869636978x1635018016.161 <DATE><TIME>|<HOST>|I|testImageSlice 162 Following should be an error. 163 <DATE><TIME>|<HOST>|E|psLib.image.psImageSlice 164 Input psImage mask size, 2000x1000, does not match psImage input size, 1 869636978x1635018016.165 <DATE><TIME>|<HOST>|I|testImageSlice 166 Following should be an error. 167 <DATE><TIME>|<HOST>|E|psLib.image.psImageSlice 168 Input psImage mask size, 2000x1000, does not match psImage input size, 1 869636978x1635018016.152 Input psImage mask size, 2000x1000, does not match psImage input size, 1919250543x543519841. 153 <DATE><TIME>|<HOST>|I|testImageSlice 154 Following should be an error. 155 <DATE><TIME>|<HOST>|E|psLib.image.psImageSlice 156 Input psImage mask size, 2000x1000, does not match psImage input size, 1919250543x543519841. 157 <DATE><TIME>|<HOST>|I|testImageSlice 158 Following should be an error. 159 <DATE><TIME>|<HOST>|E|psLib.image.psImageSlice 160 Input psImage mask size, 2000x1000, does not match psImage input size, 1919250543x543519841. 161 <DATE><TIME>|<HOST>|I|testImageSlice 162 Following should be an error. 163 <DATE><TIME>|<HOST>|E|psLib.image.psImageSlice 164 Input psImage mask size, 2000x1000, does not match psImage input size, 1919250543x543519841. 165 <DATE><TIME>|<HOST>|I|testImageSlice 166 Following should be an error. 167 <DATE><TIME>|<HOST>|E|psLib.image.psImageSlice 168 Input psImage mask size, 2000x1000, does not match psImage input size, 1919250543x543519841. 169 169 <DATE><TIME>|<HOST>|I|testImageSlice 170 170 Following should be an error mask size != image size. -
trunk/psLib/test/image/verified/tst_psImageManip.stderr
r1943 r2105 307 307 ---> TESTPOINT PASSED (psImage{psImageShift} | tst_psImageManip.c) 308 308 309 /***************************** TESTPOINT ******************************************\ 310 * TestFile: tst_psImageManip.c * 311 * TestPoint: psImage{psImageResample} * 312 * TestType: Positive * 313 \**********************************************************************************/ 314 315 <DATE><TIME>|<HOST>|E|psLib.image.psImageResample 316 Can not operate on a NULL psImage. 317 <DATE><TIME>|<HOST>|E|psLib.image.psImageResample 318 Specified scale value, 0, must be a positive value. 319 <DATE><TIME>|<HOST>|E|psLib.image.psImageResample 320 Specified interpolation mode, 0, is unsupported. 321 322 ---> TESTPOINT PASSED (psImage{psImageResample} | tst_psImageManip.c) 323
Note:
See TracChangeset
for help on using the changeset viewer.
