Changeset 2782 for trunk/psLib/src/math/psStats.c
- Timestamp:
- Dec 21, 2004, 2:54:28 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/math/psStats.c (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/math/psStats.c
r2780 r2782 9 9 * @author GLG, MHPCC 10 10 * 11 * @version $Revision: 1.10 6$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-12-2 1 23:25:14$11 * @version $Revision: 1.107 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-12-22 00:54:28 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 682 682 robustHistogram->bounds->data.F32[j+1]) / 2.0; 683 683 smooth->data.F32[i] += 684 ((float) robustHistogram->nums->data.U32[j])*684 robustHistogram->nums->data.F32[j] * 685 685 psGaussian(jMid, iMid, sigma, true); 686 686 } … … 1563 1563 modeBinNum = LQBinNum; 1564 1564 modeBinCount = robustHistogramVector->data.F32[LQBinNum]; 1565 sumN50 = (float)robustHistogram->nums->data.U32[LQBinNum];1565 sumN50 = robustHistogram->nums->data.F32[LQBinNum]; 1566 1566 for (i = LQBinNum + 1; i <= UQBinNum; i++) { 1567 1567 if (robustHistogramVector->data.F32[i] > modeBinCount) { … … 1569 1569 modeBinCount = robustHistogramVector->data.F32[i]; 1570 1570 } 1571 sumN50 += (float)robustHistogram->nums->data.U32[i];1571 sumN50 += robustHistogram->nums->data.F32[i]; 1572 1572 } 1573 1573 … … 1587 1587 } 1588 1588 1589 sumNfit += (float)robustHistogram->nums->data.U32[i];1589 sumNfit += robustHistogram->nums->data.F32[i]; 1590 1590 } 1591 1591 // XXX: divide by zero? … … 1796 1796 1797 1797 // Allocate the bins, and initialize them to zero. 1798 newHist->nums = psVectorAlloc(n, PS_TYPE_U32); 1799 newHist->nums->n = newHist->nums->nalloc; 1798 newHist->nums = psVectorAlloc(n, PS_TYPE_F32); 1800 1799 for (i = 0; i < newHist->nums->n; i++) { 1801 newHist->nums->data. U32[i] =0;1800 newHist->nums->data.F32[i] = 0.0; 1802 1801 } 1803 1802 … … 1839 1838 // Allocate the bins, and initialize them to zero. If there are N bounds, 1840 1839 // then there are N-1 bins. 1841 newHist->nums = psVectorAlloc((bounds->n) - 1, PS_TYPE_U32); 1842 newHist->nums->n = newHist->nums->nalloc; 1840 newHist->nums = psVectorAlloc((bounds->n) - 1, PS_TYPE_F32); 1843 1841 for (i = 0; i < newHist->nums->n; i++) { 1844 newHist->nums->data. U32[i] =0;1842 newHist->nums->data.F32[i] = 0.0; 1845 1843 } 1846 1844 … … 1858 1856 psFree(myHist->nums); 1859 1857 } 1858 1859 psS32 UpdateHistogramBins(psS32 binNum, 1860 psHistogram* out, 1861 psF32 data, 1862 psF32 error) 1863 { 1864 PS_PTR_CHECK_NULL(out, -1); 1865 PS_INT_CHECK_RANGE(binNum, 0, out->nums->n-1, -2); 1866 /* 1867 psF32 width = 2.35 * error; 1868 psF32 centerBinWidth = out->bounds->data.F32[binNum+1] - out->bounds->data.F32[binNum] 1869 psF32 boxcarCenter = (out->bounds->data.F32[binNum] + out->bounds->data.F32[binNum+1]) / 2.0; 1870 1871 if (width <= centerBinWidth) { 1872 out->nums->data.F32[binNum]+= 1.0; 1873 } else { 1874 out->nums->data.F32[binNum]+= centerBinWidth / width; 1875 // XXX: walk to the left, adding fractional values. 1876 // XXX: walk to the right, adding fractional values. 1877 1878 1879 } 1880 */ 1881 return(0); 1882 } 1883 1860 1884 1861 1885 /***************************************************************************** … … 1883 1907 PS_PTR_CHECK_NULL(out, NULL); 1884 1908 PS_VECTOR_CHECK_TYPE(out->bounds, PS_TYPE_F32, NULL); 1885 PS_VECTOR_CHECK_TYPE(out->nums, PS_TYPE_ U32, NULL);1909 PS_VECTOR_CHECK_TYPE(out->nums, PS_TYPE_F32, NULL); 1886 1910 PS_INT_CHECK_NON_NEGATIVE(out->nums->n, NULL); 1887 1911 PS_VECTOR_CHECK_NULL(in, out); … … 1913 1937 for (i = 0; i < inF32->n; i++) { 1914 1938 // Check if this pixel is masked, and if so, skip it. 1915 if ((mask == NULL) || 1916 ((mask != NULL) && (!(mask->data.U8[i] & maskVal)))) { 1939 if ((mask == NULL) || ((mask != NULL) && (!(mask->data.U8[i] & maskVal)))) { 1917 1940 if (inF32->data.F32[i] < out->bounds->data.F32[0]) { 1918 1941 // If this pixel is below minimum value, count it, then skip. … … 1927 1950 binSize = out->bounds->data.F32[1] - out->bounds->data.F32[0]; 1928 1951 binNum = (psS32)((inF32->data.F32[i] - out->bounds->data.F32[0]) / binSize); 1929 1930 // XXX: This if-statement really shouldn't be necessary. 1931 // However, due to numerical lack of precision, we 1932 // occasionally produce a binNum outside the range. 1933 if (binNum >= out->nums->n) { 1934 binNum = out->nums->n - 1; 1952 if (errors != NULL) { 1953 // XXX: Check return codes. 1954 UpdateHistogramBins(binNum, out, 1955 inF32->data.F32[i], 1956 errors->data.F32[i]); 1957 } else { 1958 // XXX: This if-statement really shouldn't be necessary. 1959 // However, due to numerical lack of precision, we 1960 // occasionally produce a binNum outside the range. 1961 if (binNum >= out->nums->n) { 1962 binNum = out->nums->n - 1; 1963 } 1964 (out->nums->data.F32[binNum])+= 1.0; 1935 1965 } 1936 1937 (out->nums->data.U32[binNum])++;1938 1966 1939 1967 } else { … … 1946 1974 "WARNING: psVectorHistogram(): element outside histogram bounds.\n"); 1947 1975 } else { 1948 (out->nums->data.U32[tmp])++; 1976 if (errors != NULL) { 1977 // XXX: Check return codes. 1978 UpdateHistogramBins(tmp, out, 1979 inF32->data.F32[i], 1980 errors->data.F32[i]); 1981 } else { 1982 (out->nums->data.F32[tmp])+= 1.0; 1983 } 1949 1984 } 1950 1985 }
Note:
See TracChangeset
for help on using the changeset viewer.
