IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 28303


Ignore:
Timestamp:
Jun 10, 2010, 4:50:08 PM (16 years ago)
Author:
eugene
Message:

merge fix for poor background from trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tags/ipp-20100610/ppStack/src/ppStackTarget.c

    r28256 r28303  
    164164
    165165        psStats *bg = psStatsAlloc(PS_STAT_ROBUST_MEDIAN); // Statistics for background
     166        float mean = NAN;                                  // Measured mean variance
    166167        if (!psImageBackground(bg, NULL, variance, mask, maskVal, rng)) {
    167             psError(PPSTACK_ERR_DATA, false, "Can't measure background for image.");
    168             psFree(rng);
    169             return NULL;
     168            psErrorClear();
     169            // Retry using all the available pixels
     170            bg->nSubsample = variance->numCols * variance->numRows + 1;
     171            if (!psImageStats(bg, variance, mask, maskVal)) {
     172                psLogMsg("ppStack", PS_LOG_DETAIL,
     173                         "Couldn't measure mean variance for image %d; retrying.", i);
     174                psErrorClear();
     175                // Retry with desperate statistic
     176                bg->options = PS_STAT_SAMPLE_MEAN;
     177                if (!psImageStats(bg, variance, mask, maskVal)) {
     178                    psWarning("Unable to measure mean variance for image %d --- rejecting.", i);
     179                    psErrorStackPrint(stderr, "Unable to measure mean variance for image %d", i);
     180                    options->inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i] |= PPSTACK_MASK_PSF;
     181                    goto DONE;
     182                } else {
     183                    // Desperate retry
     184                    mean = bg->sampleMean;
     185                }
     186            } else {
     187                // Retry with all available pixels
     188                mean = bg->robustMedian;
     189            }
     190        } else {
     191            // First attempt
     192            mean = bg->robustMedian;
    170193        }
    171194
     
    177200        }
    178201
     202    DONE:
     203        psFree(bg);
    179204        if (!ppStackFilesIterateUp(config)) {
    180205            psFree(rng);
Note: See TracChangeset for help on using the changeset viewer.