IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 28, 2009, 11:21:56 AM (17 years ago)
Author:
eugene
Message:

always handle psVectorStats false return status (is an error); check for NAN results and handle as possible

File:
1 edited

Legend:

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

    r21183 r23989  
    110110    out = psImageRecycle(out, outCols, outRows, in->type.type);
    111111
    112     #define PS_IMAGE_REBIN_CASE(TYPE) \
    113 case PS_TYPE_##TYPE: { \
    114         ps##TYPE *outRowData; \
    115         ps##TYPE *vecData = vec->data.TYPE; \
    116         psImageMaskType *inRowMask = NULL; \
    117         for (psS32 row = 0; row < outRows; row++) { \
    118             outRowData = out->data.TYPE[row]; \
    119             psS32 inCurrentRow = row * scale; \
    120             psS32 inNextRow = (row + 1) * scale; \
    121             for (psS32 col = 0; col < outCols; col++) { \
    122                 psS32 inCurrentCol = col * scale; \
    123                 psS32 inNextCol = (col + 1) * scale; \
    124                 psS32 n = 0; \
     112#define PS_IMAGE_REBIN_CASE(TYPE)                                       \
     113    case PS_TYPE_##TYPE: {                                              \
     114        ps##TYPE *outRowData;                                           \
     115        ps##TYPE *vecData = vec->data.TYPE;                             \
     116        psImageMaskType *inRowMask = NULL;                              \
     117        for (psS32 row = 0; row < outRows; row++) {                     \
     118            outRowData = out->data.TYPE[row];                           \
     119            psS32 inCurrentRow = row * scale;                           \
     120            psS32 inNextRow = (row + 1) * scale;                        \
     121            for (psS32 col = 0; col < outCols; col++) {                 \
     122                psS32 inCurrentCol = col * scale;                       \
     123                psS32 inNextCol = (col + 1) * scale;                    \
     124                psS32 n = 0;                                            \
    125125                for (psS32 inRow = inCurrentRow; inRow < inNextRow && inRow < inRows; inRow++) { \
    126                     ps##TYPE* inRowData = in->data.TYPE[inRow]; \
    127                     if (mask != NULL) { \
     126                    ps##TYPE* inRowData = in->data.TYPE[inRow];         \
     127                    if (mask != NULL) {                                 \
    128128                        inRowMask = mask->data.PS_TYPE_IMAGE_MASK_DATA[inRow]; \
    129                     } \
     129                    }                                                   \
    130130                    for (psS32 inCol = inCurrentCol; inCol < inNextCol && inCol < inCols; inCol++) { \
    131                         if (maskData != NULL) { \
     131                        if (maskData != NULL) {                         \
    132132                            maskData[n] = (inRowMask[inCol] & maskVal); \
    133                         } \
    134                         vecData[n++] = inRowData[inCol]; \
    135                     } \
    136                 } \
    137                 vec->n = n; \
    138                 if (maskVec) { \
    139                     maskVec->n = n; \
    140                 } \
    141                  psVectorStats(myStats, vec, NULL, maskVec, 0xff); /* the mask vector has only 0 or 1 */ \
    142                 outRowData[col] = (ps##TYPE)psStatsGetValue(myStats, statistic); \
    143             } \
    144         } \
    145     } \
     133                        }                                               \
     134                        vecData[n++] = inRowData[inCol];                \
     135                    }                                                   \
     136                }                                                       \
     137                vec->n = n;                                             \
     138                if (maskVec) {                                          \
     139                    maskVec->n = n;                                     \
     140                }                                                       \
     141                if (!psVectorStats(myStats, vec, NULL, maskVec, 0xff)) { /* the mask vector has only 0 or 1 */ \
     142                    psError(PS_ERR_UNKNOWN, false, "failure to measure stats"); \
     143                    psFree(out);                                        \
     144                    out = NULL;                                         \
     145                    goto escape;                                        \
     146                }                                                       \
     147                outRowData[col] = (ps##TYPE)psStatsGetValue(myStats, statistic); \
     148            }                                                           \
     149        }                                                               \
     150    }                                                                   \
    146151    break;
    147152
     
    161166            char* typeStr;
    162167            PS_TYPE_NAME(typeStr,in->type.type);
    163             psError(PS_ERR_BAD_PARAMETER_TYPE, true,
    164                     _("Specified psImage type, %s, is not supported."),
    165                     typeStr);
     168            psError(PS_ERR_BAD_PARAMETER_TYPE, true, _("Specified psImage type, %s, is not supported."), typeStr);
    166169            psFree(out);
    167170            out = NULL;
     
    169172    }
    170173
     174escape:
    171175    psFree(vec);
    172176    psFree(maskVec);
Note: See TracChangeset for help on using the changeset viewer.