IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 21, 2004, 2:54:28 PM (22 years ago)
Author:
gusciora
Message:

Modified histogram->nums to be of type F32, not U32.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/math/psStats.c

    r2780 r2782  
    99 *  @author GLG, MHPCC
    1010 *
    11  *  @version $Revision: 1.106 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2004-12-21 23:25:14 $
     11 *  @version $Revision: 1.107 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2004-12-22 00:54:28 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    682682                    robustHistogram->bounds->data.F32[j+1]) / 2.0;
    683683            smooth->data.F32[i] +=
    684                 ((float) robustHistogram->nums->data.U32[j]) *
     684                robustHistogram->nums->data.F32[j] *
    685685                psGaussian(jMid, iMid, sigma, true);
    686686        }
     
    15631563    modeBinNum = LQBinNum;
    15641564    modeBinCount = robustHistogramVector->data.F32[LQBinNum];
    1565     sumN50 = (float)robustHistogram->nums->data.U32[LQBinNum];
     1565    sumN50 = robustHistogram->nums->data.F32[LQBinNum];
    15661566    for (i = LQBinNum + 1; i <= UQBinNum; i++) {
    15671567        if (robustHistogramVector->data.F32[i] > modeBinCount) {
     
    15691569            modeBinCount = robustHistogramVector->data.F32[i];
    15701570        }
    1571         sumN50 += (float)robustHistogram->nums->data.U32[i];
     1571        sumN50 += robustHistogram->nums->data.F32[i];
    15721572    }
    15731573
     
    15871587        }
    15881588
    1589         sumNfit += (float)robustHistogram->nums->data.U32[i];
     1589        sumNfit += robustHistogram->nums->data.F32[i];
    15901590    }
    15911591    // XXX: divide by zero?
     
    17961796
    17971797    // 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);
    18001799    for (i = 0; i < newHist->nums->n; i++) {
    1801         newHist->nums->data.U32[i] = 0;
     1800        newHist->nums->data.F32[i] = 0.0;
    18021801    }
    18031802
     
    18391838    // Allocate the bins, and initialize them to zero.  If there are N bounds,
    18401839    // 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);
    18431841    for (i = 0; i < newHist->nums->n; i++) {
    1844         newHist->nums->data.U32[i] = 0;
     1842        newHist->nums->data.F32[i] = 0.0;
    18451843    }
    18461844
     
    18581856    psFree(myHist->nums);
    18591857}
     1858
     1859psS32 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
    18601884
    18611885/*****************************************************************************
     
    18831907    PS_PTR_CHECK_NULL(out, NULL);
    18841908    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);
    18861910    PS_INT_CHECK_NON_NEGATIVE(out->nums->n, NULL);
    18871911    PS_VECTOR_CHECK_NULL(in, out);
     
    19131937    for (i = 0; i < inF32->n; i++) {
    19141938        // 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)))) {
    19171940            if (inF32->data.F32[i] < out->bounds->data.F32[0]) {
    19181941                // If this pixel is below minimum value, count it, then skip.
     
    19271950                    binSize = out->bounds->data.F32[1] - out->bounds->data.F32[0];
    19281951                    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;
    19351965                    }
    1936 
    1937                     (out->nums->data.U32[binNum])++;
    19381966
    19391967                } else {
     
    19461974                                 "WARNING: psVectorHistogram(): element outside histogram bounds.\n");
    19471975                    } 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                        }
    19491984                    }
    19501985                }
Note: See TracChangeset for help on using the changeset viewer.