IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 27, 2006, 2:44:05 PM (20 years ago)
Author:
Paul Price
Message:

Replacing p_psGetStatValue with two functions: psStatsSingleOption returns the single option that is set, or 0 if no matching option is set; psStatsGetValue returns the value for a requested statistic. Tests seem to pass with the new code.

Location:
trunk/psLib/src/imageops
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/imageops/psImageGeomManip.c

    r7766 r7999  
    1010 *  @author Ross Harman, MHPCC
    1111 *
    12  *  @version $Revision: 1.26 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2006-06-30 02:20:06 $
     12 *  @version $Revision: 1.27 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2006-07-28 00:44:05 $
    1414 *
    1515 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    4848    psMaskType* maskData = NULL;
    4949    psStats* myStats;
    50     double statVal;
    5150
    5251    if (in == NULL) {
     
    7271    }
    7372
    74     if (p_psGetStatValue(stats, &statVal) == false) {
     73    psStatsOptions statistic = psStatsSingleOption(stats->options); // Statistics option to use
     74    if (statistic == 0) {
    7575        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
    7676                PS_ERRORTEXT_psImage_BAD_STAT,
     
    108108    out = psImageRecycle(out, outCols, outRows, in->type.type);
    109109
    110     #define PS_IMAGE_REBIN_CASE(type) \
    111 case PS_TYPE_##type: { \
    112         ps##type* outRowData; \
    113         ps##type* vecData = vec->data.type; \
    114         psMaskType* inRowMask = NULL; \
     110    #define PS_IMAGE_REBIN_CASE(TYPE) \
     111case PS_TYPE_##TYPE: { \
     112        ps##TYPE *outRowData; \
     113        ps##TYPE *vecData = vec->data.TYPE; \
     114        psMaskType *inRowMask = NULL; \
    115115        for (psS32 row = 0; row < outRows; row++) { \
    116             outRowData = out->data.type[row]; \
    117             psS32 inCurrentRow = row*scale; \
    118             psS32 inNextRow = (row+1)*scale; \
     116            outRowData = out->data.TYPE[row]; \
     117            psS32 inCurrentRow = row * scale; \
     118            psS32 inNextRow = (row + 1) * scale; \
    119119            for (psS32 col = 0; col < outCols; col++) { \
    120                 psS32 inCurrentCol = col*scale; \
    121                 psS32 inNextCol = (col+1)*scale; \
     120                psS32 inCurrentCol = col * scale; \
     121                psS32 inNextCol = (col + 1) * scale; \
    122122                psS32 n = 0; \
    123123                for (psS32 inRow = inCurrentRow; inRow < inNextRow && inRow < inRows; inRow++) { \
    124                     ps##type* inRowData = in->data.type[inRow]; \
     124                    ps##TYPE* inRowData = in->data.TYPE[inRow]; \
    125125                    if (mask != NULL) { \
    126126                        inRowMask = mask->data.PS_TYPE_MASK_DATA[inRow]; \
     
    134134                } \
    135135                vec->n = n; \
    136                 myStats = psVectorStats(myStats,vec,NULL,maskVec,maskVal); \
    137                 p_psGetStatValue(myStats,&statVal); \
    138                 outRowData[col] = (ps##type)statVal; \
     136                myStats = psVectorStats(myStats, vec, NULL, maskVec, maskVal); \
     137                outRowData[col] = (ps##TYPE)psStatsGetValue(myStats, statistic); \
    139138            } \
    140139        } \
  • trunk/psLib/src/imageops/psImagePixelExtract.c

    r7125 r7999  
    88 *  @author Robert DeSonia, MHPCC
    99 *
    10  *  @version $Revision: 1.24 $ $Name: not supported by cvs2svn $
    11  *  @date $Date: 2006-05-16 23:12:20 $
     10 *  @version $Revision: 1.25 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2006-07-28 00:44:05 $
    1212 *
    1313 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    210210                       const psStats* stats)
    211211{
    212     double statVal;
    213212    psStats* myStats;
    214213    psElemType type;
     
    375374    }
    376375
    377     // verify that the stats struct specifies a
    378     // single stats operation
    379     if (p_psGetStatValue(stats, &statVal) == false) {
     376    // verify that the stats struct specifies a single stats operation
     377    psStatsOptions statistic = psStatsSingleOption(stats->options);
     378    if (statistic == 0) {
    380379        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
    381380                PS_ERRORTEXT_psImage_BAD_STAT,stats->options);
     
    439438                } \
    440439                myStats = psVectorStats(myStats,imgVec,NULL,maskVec,maskVal); \
    441                 (void)p_psGetStatValue(myStats,&statVal); \
    442                 *outData = statVal; \
     440                *outData = psStatsGetValue(myStats, statistic); \
    443441                if (outPosition != NULL) { \
    444442                    outPosition->x = c; \
     
    520518            }
    521519            myStats = psVectorStats(myStats, imgVec, NULL, maskVec, maskVal);
    522             (void)p_psGetStatValue(myStats, &statVal);  // we know it works cause we tested it above
    523             *outData = statVal;
     520            *outData = psStatsGetValue(myStats, statistic);
    524521            if (outPosition != NULL) {
    525522                outPosition->y = r;
     
    741738                           const psStats* stats)
    742739{
    743     double statVal;
    744 
    745740    /* check the parameters */
    746741
     
    808803    }
    809804
    810     // verify that the stats struct specifies a
    811     // single stats operation
    812     if (p_psGetStatValue(stats, &statVal) == false) {
     805    // verify that the stats struct specifies a single stats operation
     806    psStatsOptions statistic = psStatsSingleOption(stats->options);
     807    if (statistic == 0) {
    813808        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
    814809                PS_ERRORTEXT_psImage_BAD_STAT,
     
    914909    for (psS32 r = 0; r < numOut; r++) {
    915910        myStats = psVectorStats(myStats,buffer[r], NULL, bufferMask[r],maskVal);
    916         (void)p_psGetStatValue(myStats,&statVal);
    917         outData[r] = statVal;
     911        outData[r] = psStatsGetValue(myStats, statistic);
    918912    }
    919913
Note: See TracChangeset for help on using the changeset viewer.