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

Location:
trunk/psModules/src/imcombine
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/imcombine/pmImageCombine.c

    r21183 r23989  
    132132        // Combine all the pixels, using the specified stat.
    133133        if (!psVectorStats(stats, pixelData, pixelErrors, pixelMasks, 0xff)) {
     134            psError(PS_ERR_UNKNOWN, false, "failure to measure stats");
     135            return false;
     136        }
     137        if (isnan(stats->sampleMean)) {
    134138            combine->data.F32[y][x] = NAN;
    135139            psFree(buffer);
     
    137141        }
    138142        float combinedPixel = stats->sampleMean; // Value of the combination
    139 
     143       
    140144        if (iter == 0) {
    141145            // Save the value produced with no rejection, since it may be useful later
     
    364368    // Get the median
    365369    psStats *stats = psStatsAlloc(PS_STAT_SAMPLE_MEDIAN);
    366     psVectorStats(stats, pixels, NULL, mask, 1);
     370    if (!psVectorStats(stats, pixels, NULL, mask, 1)) {
     371        psError(PS_ERR_UNKNOWN, false, "failure to measure stats");
     372    }
    367373    float median = stats->sampleMedian;
    368374    psFree(stats);
  • trunk/psModules/src/imcombine/pmReadoutCombine.c

    r21363 r23989  
    384384            // Combination
    385385            if (!psVectorStats(stats, pixels, errors, mask, 1)) {
    386                 // Can't do much about it, but it's not worth worrying about
    387                 psErrorClear();
     386                psError(PS_ERR_UNKNOWN, false, "error in pixel stats");
     387                return false;
     388            }
     389           
     390            outputImage[yOut][xOut] = psStatsGetValue(stats, params->combine);
     391
     392            if (isnan(outputImage[yOut][xOut])) {
    388393                outputImage[yOut][xOut] = NAN;
    389394                outputMask[yOut][xOut] = params->blank;
     395                sigma->data.F32[yOut][xOut] = NAN;
    390396                if (params->variances) {
    391397                    outputVariance[yOut][xOut] = NAN;
    392398                }
    393                 sigma->data.F32[yOut][xOut] = NAN;
    394             } else {
    395                 outputImage[yOut][xOut] = psStatsGetValue(stats, params->combine);
    396                 outputMask[yOut][xOut] = isfinite(outputImage[yOut][xOut]) ? 0 : params->blank;
    397                 if (params->variances) {
    398                     float stdev = psStatsGetValue(stats, combineStdev);
    399                     outputVariance[yOut][xOut] = PS_SQR(stdev); // Variance
    400                     // XXXX this is not the correct formal error.
    401                     // also, the weighted mean is not obviously the correct thing here
    402                 }
    403                 sigma->data.F32[yOut][xOut] = psStatsGetValue(stats, combineStdev);
    404             }
     399                continue;
     400            }
     401            outputMask[yOut][xOut] = 0;
     402            sigma->data.F32[yOut][xOut] = psStatsGetValue(stats, combineStdev);
     403            if (params->variances) {
     404                float stdev = psStatsGetValue(stats, combineStdev);
     405                outputVariance[yOut][xOut] = PS_SQR(stdev); // Variance
     406                // XXXX this is not the correct formal error.
     407                // also, the weighted mean is not obviously the correct thing here
     408            }
    405409        }
    406410    }
  • trunk/psModules/src/imcombine/pmSubtraction.c

    r23839 r23989  
    822822    psFree(mask);
    823823
     824    // XXX raise an error?
     825    if (isnan(stats->sampleMean)) {
     826        psFree(stats);
     827        return -1;
     828    }
     829
    824830    double mean, rms;                 // Mean and RMS of deviations
    825831    if (numStamps < MIN_SAMPLE_STATS) {
  • trunk/psModules/src/imcombine/pmSubtractionMatch.c

    r23944 r23989  
    830830    psFree(mask);
    831831
     832    // XXX raise an error here or not?
     833    if (isnan(stats->robustMedian)) {
     834        psFree(stats);
     835        return PM_SUBTRACTION_MODE_ERR;
     836    }
     837
    832838    psLogMsg("psModules.imcombine", PS_LOG_INFO, "Median width ratio: %lf", stats->robustMedian);
    833839    pmSubtractionMode mode = (stats->robustMedian <= 1.0 ? PM_SUBTRACTION_MODE_1 : PM_SUBTRACTION_MODE_2);
    834840    psFree(stats);
    835841
    836     // XXX EAM : I think Paul left some test code in here.  I've commented these lines out
    837     // return PM_SUBTRACTION_MODE_2;
    838     // exit(1);
    839 
    840842    return mode;
    841843}
Note: See TracChangeset for help on using the changeset viewer.