lsst.afw
tickets.DM-23835-g31c64b24f1
|
Go to the documentation of this file.
25 #if !defined(LSST_AFW_MATH_STATISTICS_H)
26 #define LSST_AFW_MATH_STATISTICS_H
40 #include "boost/iterator/iterator_adaptor.hpp"
41 #include "boost/tuple/tuple.hpp"
51 template <
typename,
typename,
typename>
101 bool isNanSafe =
true,
105 : _numSigmaClip(numSigmaClip),
108 _noGoodPixelsMask(0x0),
109 _isNanSafe(isNanSafe),
110 _useWeights(useWeights),
111 _calcErrorFromInputVariance(false),
112 _maskPropagationThresholds() {
119 assert(_numSigmaClip > 0);
120 assert(_numIter > 0);
143 assert(numSigmaClip > 0);
144 _numSigmaClip = numSigmaClip;
152 void setNanSafe(
bool isNanSafe) noexcept { _isNanSafe = isNanSafe; }
155 _calcErrorFromInputVariance = calcErrorFromInputVariance;
161 double _numSigmaClip;
164 int _noGoodPixelsMask;
167 bool _calcErrorFromInputVariance;
232 template <
typename ImageT,
typename MaskT,
typename VarianceT>
233 explicit Statistics(ImageT
const &img, MaskT
const &msk, VarianceT
const &var,
int const flags,
244 template <
typename ImageT,
typename MaskT,
typename VarianceT,
typename WeightT>
245 explicit Statistics(ImageT
const &img, MaskT
const &msk, VarianceT
const &var, WeightT
const &weights,
303 bool _weightsAreMultiplicative;
313 template <
typename ImageT,
typename MaskT,
typename VarianceT,
typename WeightT>
314 void doStatistics(ImageT
const &img, MaskT
const &msk, VarianceT
const &var, WeightT
const &weights,
323 template <
typename ValueT>
324 class infinite_iterator :
public boost::iterator_adaptor<infinite_iterator<ValueT>, const ValueT *,
325 const ValueT, boost::forward_traversal_tag> {
332 void increment() noexcept { ; }
338 template <
typename ValueT>
353 template <
typename Pixel>
358 return Statistics(img, msk, var, flags, sctrl);
365 template <
typename ImageT,
typename MaskT,
typename VarianceT>
368 return Statistics(img, msk, var, flags, sctrl);
375 template <
typename Pixel>
378 if (sctrl.getWeighted() || sctrl.getCalcErrorFromInputVariance()) {
390 template <
typename Pixel>
394 if (sctrl.getWeighted() || sctrl.getCalcErrorFromInputVariance() ||
395 (!sctrl.getWeightedIsSet() && (weights.
getWidth() != 0 && weights.
getHeight() != 0))) {
413 StatisticsControl
const &sctrl = StatisticsControl());
419 template <
typename Pixel>
428 return Statistics(img, msk, var, flags, sctrl);
435 template <
typename ValueT>
468 template <
typename EntryT>
476 return Statistics(img, msk, var, flags, sctrl);
483 template <
typename EntryT>
495 return Statistics(img, msk, var, weights, flags, sctrl);
502 template <
typename EntryT>
507 if (sctrl.getWeighted() || sctrl.getCalcErrorFromInputVariance()) {
519 template <
typename EntryT>
527 if (sctrl.getWeighted() || sctrl.getCalcErrorFromInputVariance()) {
estimate sample inter-quartile range
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
bool getCalcErrorFromInputVariance() const noexcept
lsst::afw::image::MaskedImage< EntryT >::MaskPtr getMask() const
ImageImposter(std::vector< ValueT > const &v)
Represent a 2-dimensional array of bitmask pixels.
infinite_iterator(const ValueT *p)
void setWeighted(bool useWeights) noexcept
void setNumIter(int numIter)
ImageImposter(ImageImposter< ValueT > const &img)
double getMaskPropagationThreshold(int bit) const
When pixels with the given bit are rejected, we count what fraction the rejected pixels would have co...
lsst::afw::image::VariancePixel WeightPixel
Property stringToStatisticsProperty(std::string const property)
Conversion function to switch a string to a Property (see Statistics.h)
x_iterator row_begin(int) const noexcept
bool getNanSafe() const noexcept
bool empty() const noexcept
int getHeight() const
Return the number of rows in the image.
bool getWeightedIsSet() const noexcept
int getAndMask() const noexcept
StatisticsControl(double numSigmaClip=3.0, int numIter=3, lsst::afw::image::MaskPixel andMask=0x0, bool isNanSafe=true, WeightsBoolean useWeights=WEIGHTS_NONE)
double getValue(Property const prop=NOTHING) const
Return the value of the desired property (if specified in the constructor)
void setMaskPropagationThreshold(int bit, double threshold)
double getNumSigmaClip() const noexcept
Statistics & operator=(Statistics const &)=default
x_iterator row_begin(int) const noexcept
Statistics makeStatistics(lsst::afw::image::Image< Pixel > const &img, lsst::afw::image::Mask< image::MaskPixel > const &msk, int const flags, StatisticsControl const &sctrl=StatisticsControl())
Handle a watered-down front-end to the constructor (no variance)
Value getResult(Property const prop=NOTHING) const
Return the value and error in the specified statistic (e.g.
estimate sample N-sigma clipped mean (N set in StatisticsControl, default=3)
estimate sample N-sigma clipped variance (N set in StatisticsControl, default=3)
This iterator will never increment.
A class to manipulate images, masks, and variance as a single object.
static MaskPixelT getPlaneBitMask(const std::vector< std::string > &names)
Return the bitmask corresponding to a vector of plane names OR'd together.
lsst::afw::image::MaskPixel getOrMask() const noexcept
infinite_iterator< ValueT > x_iterator
int getWidth() const noexcept
MaskImposter(ValueT val=0) noexcept
estimate sample N-sigma clipped stdev (N set in StatisticsControl, default=3)
float VariancePixel
default type for MaskedImage variance images
~Statistics() noexcept=default
void setNumSigmaClip(double numSigmaClip)
get the or-mask of all pixels used.
std::int32_t MaskPixel
default type for Masks and MaskedImage Masks
Include errors of requested quantities.
A base class for image defects.
VariancePtr getVariance() const
Return a (shared_ptr to) the MaskedImage's variance.
int getNumIter() const noexcept
x_iterator row_end(int) const noexcept
A Mask wrapper to provide an infinite_iterator for Mask::row_begin().
Pass parameters to a Statistics object.
std::pair< double, double > Value
The type used to report (value, error) for desired statistics.
A vector wrapper to provide a vector with the necessary methods and typedefs to be processed by Stati...
find mean value of square of pixel values
bool getWeighted() const noexcept
double getError(Property const prop=NOTHING) const
Return the error in the desired property (if specified in the constructor)
std::vector< ValueT >::const_iterator x_iterator
estimate sample standard deviation
lsst::afw::image::MaskedImage< EntryT >::ImagePtr getImage() const
Statistics(ImageT const &img, MaskT const &msk, VarianceT const &var, int const flags, StatisticsControl const &sctrl=StatisticsControl())
Constructor for Statistics object.
int getHeight() const noexcept
Extent< int, 2 > Extent2I
void setNanSafe(bool isNanSafe) noexcept
void setAndMask(int andMask)
std::vector< ValueT >::const_iterator fast_iterator
lsst::afw::image::MaskedImage< EntryT >::VariancePtr getVariance() const
ImagePtr getImage() const
Return a (shared_ptr to) the MaskedImage's image.
Property
control what is calculated
friend class boost::iterator_core_access
lsst::geom::Extent2I getDimensions() const noexcept
void setNoGoodPixelsMask(int noGoodPixelsMask)
void setCalcErrorFromInputVariance(bool calcErrorFromInputVariance) noexcept
MaskPtr getMask() const
Return a (shared_ptr to) the MaskedImage's mask.
find sum of pixels in the image
int getNoGoodPixelsMask() const noexcept
int getWidth() const
Return the number of columns in the image.