IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 13, 2009, 1:53:56 PM (17 years ago)
Author:
Paul Price
Message:

Using covariance factor to set the correct variance level for the combination. Adding additional recipe parameter to provide the fraction of values to discard when performing a 'olympic weighted mean'.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppStack/src/ppStackMatch.c

    r21366 r21477  
    170170    assert(kernels && !*kernels);
    171171    assert(config);
     172    *weighting = 0.0;
    172173
    173174    psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSTACK_RECIPE); // ppStack recipe
     
    260261        pmSubtractionAnalysis(readout->analysis, kernels, region,
    261262                              readout->image->numCols, readout->image->numRows);
     263
     264        psKernel *kernel = pmSubtractionKernel(kernels, 0.0, 0.0, false); // Convolution kernel
     265        psKernel *covar = psImageCovarianceCalculate(kernel, readout->covariance); // New covariance matrix
     266        psFree(readout->covariance);
     267        readout->covariance = covar;
     268        psFree(kernel);
     269
    262270    } else {
    263271#endif
     
    541549        }
    542550        psFree(iter);
    543         *chi2 /= num;
     551        *chi2 /= psImageCovarianceFactor(readout->covariance) * num;
    544552    }
    545553
     
    579587        (void)psBinaryOp(readout->image, readout->image, "-",
    580588                         psScalarAlloc(psStatsGetValue(bg, PS_STAT_ROBUST_MEDIAN), PS_TYPE_F32));
    581         *weighting = 1.0 / PS_SQR(psStatsGetValue(bg, PS_STAT_ROBUST_STDEV));
    582         psMetadataAddF32(readout->analysis, PS_LIST_TAIL, "PPSTACK.WEIGHTING", 0,
    583                          "Weighting by 1/noise^2 for stack",
    584                          1.0 / PS_SQR(psStatsGetValue(bg, PS_STAT_ROBUST_STDEV)));
    585     }
     589    }
     590
     591    // Measure the variance level for the weighting
     592    if (!psImageBackground(bg, NULL, readout->variance, readout->mask, maskVal | maskBad, rng)) {
     593        psError(PS_ERR_UNKNOWN, false, "Can't measure mean variance for image.");
     594        psFree(output);
     595        return false;
     596    }
     597    *weighting = 1.0 / (psStatsGetValue(bg, PS_STAT_ROBUST_MEDIAN) *
     598                        psImageCovarianceFactor(readout->covariance));
     599    psMetadataAddF32(readout->analysis, PS_LIST_TAIL, "PPSTACK.WEIGHTING", 0,
     600                     "Weighting by 1/noise^2 for stack", *weighting);
     601
    586602    psFree(bg);
    587603
Note: See TracChangeset for help on using the changeset viewer.