Class lsst::afw::math::Statistics¶
-
class
Statistics
¶ A class to evaluate image statistics
The basic strategy is to construct a Statistics object from an Image and a statement of what we want to know. The desired results can then be returned using Statistics methods. A StatisticsControl object is used to pass parameters. The statistics currently implemented are listed in the enum Properties in Statistics.h.
// sets NumSigclip (3.0), and NumIter (3) for clipping lsst::afw::math::StatisticsControl sctrl(3.0, 3); sctrl.setNumSigmaClip(4.0); // reset number of standard deviations for N-sigma clipping sctrl.setNumIter(5); // reset number of iterations for N-sigma clipping sctrl.setAndMask(0x1); // ignore pixels with these mask bits set sctrl.setNanSafe(true); // check for NaNs & Infs, a bit slower (default=true) lsst::afw::math::Statistics statobj = lsst::afw::math::makeStatistics(*img, afwMath::NPOINT | afwMath::MEAN | afwMath::MEANCLIP, sctrl); double const n = statobj.getValue(lsst::afw::math::NPOINT); std::pair<double, double> const mean = statobj.getResult(lsst::afw::math::MEAN); // Returns (value, error) double const meanError = statobj.getError(lsst::afw::math::MEAN); // just the error
- Note
Factory function: We used a helper function,
makeStatistics
, rather that the constructor directly so that the compiler could deduce the types cf.std::make_pair()
- Note
Inputs: The class Statistics is templated, and makeStatistics() can take either: (1) an image, (2) a maskedImage, or (3) a std::vector<> Overloaded makeStatistics() functions then wrap what they were passed in Image/Mask-like classes and call the Statistics constructor.
- Note
Clipping: The clipping is done iteratively with numSigmaClip and numIter specified in the StatisticsControl object. The first clip (ie. the first iteration) is performed at: median +/- numSigmaClip*IQ_TO_STDEV*IQR, where IQ_TO_STDEV=~0.74 is the conversion factor between the IQR and sigma for a Gaussian distribution. All subsequent iterations perform clips at mean +/- numSigmaClip*stdev.