IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 21142


Ignore:
Timestamp:
Jan 19, 2009, 4:56:04 PM (17 years ago)
Author:
eugene
Message:

handle masked pixels correctly in the stats

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branch_20081230/ppStats/src/ppStatsReadout.c

    r21087 r21142  
    6464        psVector *sampleValues = psVectorAlloc(numSamples, PS_TYPE_F32); // Vector of samples
    6565        psVector *sampleMask = psVectorAlloc(numSamples, PS_TYPE_VECTOR_MASK);  // Corresponding mask
    66         if (!mask) {
    67             psVectorInit(sampleMask, 0);
    68         }
     66        psVectorInit(sampleMask, 0);
     67
    6968        for (int i = 0; i < numSamples; i++) {
    7069            int j = i * sampleSpace;
     
    7271            int x = j % image->numCols;
    7372            sampleValues->data.F32[i] = image->data.F32[y][x];
    74             if ((!mask || !(mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & data->maskVal)) && !isfinite(sampleValues->data.F32[i])) {
    75                 if (!warnNonFinite) {
    76                     psWarning("Unmasked non-finite value detected at %d,%d; suppressing further warnings", x, y);
    77                     warnNonFinite = true;
    78                 }
     73
     74            // ignore the sampleMask if there is no input mask
     75            if (!mask) continue;
     76
     77            // if this pixel is masked, set the sample mask
     78            if (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & data->maskVal) {
     79                sampleMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 1;
     80                continue;
     81            }
     82
     83            // mask any unmasked NAN/INF values
     84            if (!isfinite(sampleValues->data.F32[i])) {
     85                // warn for the first unmasked NAN/INF value
     86                if (!warnNonFinite) {
     87                    psWarning("Unmasked non-finite value detected at %d,%d; suppressing further warnings", x, y);
     88                    warnNonFinite = true;
     89                }
    7990                sampleMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 1;
    80             } else if (mask) {
    81               sampleMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 1;
    82             }
     91            }
    8392        }
    8493        if (!psVectorStats(data->stats, sampleValues, NULL, sampleMask, 1)) {
Note: See TracChangeset for help on using the changeset viewer.