IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 16, 2006, 2:56:48 PM (20 years ago)
Author:
gusciora
Message:

* empty log message *

File:
1 edited

Legend:

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

    r6322 r6437  
    1616 * use ->min and ->max (PS_STAT_USE_RANGE)
    1717 *
    18  *  @version $Revision: 1.167 $ $Name: not supported by cvs2svn $
    19  *  @date $Date: 2006-02-03 22:05:22 $
     18 *  @version $Revision: 1.168 $ $Name: not supported by cvs2svn $
     19 *  @date $Date: 2006-02-17 00:56:48 $
    2020 *
    2121 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    440440unmasked element within the specified min/max range).  Otherwise, return
    441441"false".
    442  
    443 XXX: Can you use psVectorCountPixelMask here?
    444442 *****************************************************************************/
    445 bool p_psVectorCheckNonEmpty(const psVector* myVector,
    446                              const psVector* maskVector,
    447                              psU32 maskVal,
    448                              psStats* stats)
     443bool p_psVectorCheckNonEmpty(
     444    const psVector* myVector,
     445    const psVector* maskVector,
     446    psU32 maskVal,
     447    psStats* stats)
    449448{
    450449    psTrace(__func__, 4, "---- %s() begin ----\n", __func__);
     
    496495number of non-masked pixels in the vector that fall within the min/max
    497496range, if specified.
    498  
    499 XXX: Can you use psVectorCountPixelMask here?
    500497 *****************************************************************************/
    501498psS32 p_psVectorNValues(const psVector* myVector,
     
    644641robustHistogram with a Gaussian of width sigma.  It returns a psVector of the
    645642smoothed data.
    646  
    647 XXX: Only PS_TYPE_F32 is supported.
    648  
    649 XXX: Write a general routine which smoothes a psVector.  This routine should
    650 call that.  Is that possible?
    651643 *****************************************************************************/
    652644psVector *p_psVectorSmoothHistGaussian(
     
    985977    -1: error
    986978    -2: warning
    987  
    988 XXX: Use static vectors for tmpMask.
    989979 *****************************************************************************/
    990980psS32 p_psVectorClippedStats(const psVector* myVector,
     
    12241214
    12251215        //
    1226         // Ensure that the y values are monotonic.
    1227         //
    1228         // XXX: This routine should probably be rewritten in a more general fashion
    1229         // so that the following checks are not necessary.
     1216        // Ensure that the y value lies within range of the y values.
    12301217        //
    12311218        if (! (((y->data.F64[0] <= yVal) && (yVal <= y->data.F64[2])) ||
     
    12361223        }
    12371224
     1225        //
     1226        // Ensure that the y values are monotonic.
     1227        //
    12381228        if (((y->data.F64[0] < y->data.F64[1]) && !(y->data.F64[1] <= y->data.F64[2])) ||
    12391229                ((y->data.F64[0] > y->data.F64[1]) && !(y->data.F64[1] >= y->data.F64[2]))) {
     
    12891279        } else if (binNum == (xVec->n - 2)) {
    12901280            // XXX: Is this right?
    1291             tmpFloat = 0.5 * (xVec->data.F32[binNum] +
    1292                               xVec->data.F32[binNum + 1]);
     1281            tmpFloat = 0.5 * (xVec->data.F32[binNum] + xVec->data.F32[binNum + 1]);
    12931282        }
    12941283    }
     
    16771666    tmpScalar.data.F32 = totalDataPoints * 0.25f;
    16781667    if (tmpScalar.data.F32 <= cumulativeRobustHistogram->nums->data.F32[0]) {
    1679         // XXX: Special case where its in first bin.  Must code last bin.
     1668        // Special case where its in first bin.  The last bin should be handled automatically.
    16801669        binLo25 = 0;
    16811670    } else {
     
    16841673    tmpScalar.data.F32 = totalDataPoints * 0.75f;
    16851674    if (tmpScalar.data.F32 <= cumulativeRobustHistogram->nums->data.F32[0]) {
    1686         // XXX: Special case where its in first bin.  Must code last bin.
     1675        // Special case where its in first bin.  The last bin should be handled automatically.
    16871676        binHi25 = 0;
    16881677    } else {
     
    17041693    // Interpolate to find these two positions exactly: these are the upper
    17051694    // and lower quartile positions.
    1706     // XXX: Check for errors.
    17071695    //
    17081696    psF32 binLo25F32 = fitQuadraticSearchForYThenReturnX(
     
    17111699                           binLo25,
    17121700                           totalDataPoints * 0.25f);
     1701
    17131702    psF32 binHi25F32 = fitQuadraticSearchForYThenReturnX(
    17141703                           *(psVector* *)&cumulativeRobustHistogram->bounds,
     
    17161705                           binHi25,
    17171706                           totalDataPoints * 0.75f);
     1707
     1708    if (isnan(binLo25F32) || isnan(binHi25F32)) {
     1709        psError(PS_ERR_UNKNOWN, false, "could not determine the robustUQ: fitQuadraticSearchForYThenReturnX() returned a NAN.\n");
     1710        psFree(tmpStatsMinMax);
     1711        psFree(robustHistogram);
     1712        psFree(cumulativeRobustHistogram);
     1713        psFree(tmpMaskVec);
     1714        psTrace(__func__, 4, "---- %s(1) end  ----\n", __func__);
     1715        return(1);
     1716    }
     1717
    17181718    stats->robustLQ = binLo25F32;
    17191719    stats->robustUQ = binHi25F32;
    17201720    psTrace(__func__, 6, "The 25 and 75 percent data point exact positions are (%f, %f).\n", binLo25F32, binHi25F32);
    1721 
    17221721    psS32 N50 = 0;
    17231722    for (psS32 i = 0 ; i < myVector->n ; i++) {
     
    18631862        }
    18641863
    1865         // XXX: Use the min/max routines for this
    1866         psF32 minY = FLT_MAX;
    1867         psF32 maxY = -FLT_MAX;
    1868         for (psS32 i = 0 ; i < y->n ; i++) {
    1869             if (y->data.F32[i] > maxY) {
    1870                 maxY = y->data.F32[i];
    1871             }
    1872             if (y->data.F32[i] < minY) {
    1873                 minY = y->data.F32[i];
    1874             }
    1875         }
     1864        rc = p_psVectorMin(y, NULL, 0, tmpStatsMinMax);
     1865        rc|= p_psVectorMax(y, NULL, 0, tmpStatsMinMax);
     1866        if ((rc != 0) || isnan(tmpStatsMinMax->min) || isnan(tmpStatsMinMax->max)) {
     1867            psError(PS_ERR_UNKNOWN, false, "Failed to calculate the min/max of the input vector.\n");
     1868            psFree(tmpMaskVec);
     1869            psFree(robustHistogram);
     1870            psFree(cumulativeRobustHistogram);
     1871            psFree(tmpStatsMinMax);
     1872            psTrace(__func__, 4, "---- %s(1) end  ----\n", __func__);
     1873            return(1);
     1874        }
     1875
    18761876        //
    18771877        // Normalize y to [0.0:1.0] (since the psMinimizeLMChi2Gauss1D() functions is [0.0:1.0])
     
    18791879        //
    18801880        for (psS32 i = 0 ; i < y->n ; i++) {
    1881             y->data.F32[i]= (y->data.F32[i] - minY) / (maxY - minY);
     1881            y->data.F32[i]= (y->data.F32[i] - tmpStatsMinMax->min) / (tmpStatsMinMax->max - tmpStatsMinMax->min);
    18821882        }
    18831883
     
    22952295                        }
    22962296                    } else {
    2297                         // XXX: This if-statement really shouldn't be necessary.
     2297                        // This if-statement really shouldn't be necessary.
    22982298                        // However, due to numerical lack of precision, we
    22992299                        // occasionally produce a binNum outside the range.
     
    24352435XXX: Should we free stats if the asserts fail?
    24362436 *****************************************************************************/
    2437 psStats* psVectorStats(psStats* stats,
    2438                        const psVector* in,
    2439                        const psVector* errors,
    2440                        const psVector* mask,
    2441                        psMaskType maskVal)
     2437psStats* psVectorStats(
     2438    psStats* stats,
     2439    const psVector* in,
     2440    const psVector* errors,
     2441    const psVector* mask,
     2442    psMaskType maskVal)
    24422443{
    24432444    psTrace(__func__, 3,"---- %s() begin  ----\n", __func__);
Note: See TracChangeset for help on using the changeset viewer.