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);
129 double getMaskPropagationThreshold(
int bit)
const;
130 void setMaskPropagationThreshold(
int bit,
double threshold);
138 bool getWeighted() const noexcept {
return _useWeights == WEIGHTS_TRUE ? true :
false; }
139 bool getWeightedIsSet() const noexcept {
return _useWeights != WEIGHTS_NONE ? true :
false; }
143 assert(numSigmaClip > 0);
144 _numSigmaClip = numSigmaClip;
152 void setNanSafe(
bool isNanSafe) noexcept { _isNanSafe = isNanSafe; }
153 void setWeighted(
bool useWeights) noexcept { _useWeights = useWeights ? WEIGHTS_TRUE : WEIGHTS_FALSE; }
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> {
331 friend class boost::iterator_core_access;
332 void increment() noexcept { ; }
338 template <
typename ValueT>
343 x_iterator
row_begin(
int)
const noexcept {
return x_iterator(_val); }
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))) {
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()) {
VariancePtr getVariance() const
Return a (shared_ptr to) the MaskedImage's variance.
double getNumSigmaClip() const noexcept
MaskImposter(ValueT val=0) noexcept
ImageImposter(ImageImposter< ValueT > const &img)
std::vector< ValueT >::const_iterator x_iterator
bool getNanSafe() const noexcept
x_iterator row_begin(int) const noexcept
lsst::afw::image::VariancePixel WeightPixel
get the or-mask of all pixels used.
void setNumSigmaClip(double numSigmaClip)
bool getCalcErrorFromInputVariance() const noexcept
bool empty() const noexcept
int getHeight() const
Return the number of rows in the image.
estimate sample standard deviation
int getHeight() const noexcept
find mean value of square of pixel values
int getNumIter() const noexcept
lsst::geom::Extent2I getDimensions() const noexcept
void setNoGoodPixelsMask(int noGoodPixelsMask)
We don't want anything.
lsst::afw::image::MaskedImage< EntryT >::ImagePtr getImage() const
Include errors of requested quantities.
x_iterator row_end(int) const noexcept
A class to evaluate image statistics.
void setNanSafe(bool isNanSafe) noexcept
ImagePtr getImage() const
Return a (shared_ptr to) the MaskedImage's image.
Statistics makeStatistics(lsst::afw::math::MaskedVector< EntryT > const &mv, std::vector< WeightPixel > const &vweights, int const flags, StatisticsControl const &sctrl=StatisticsControl())
The makeStatistics() overload to handle lsst::afw::math::MaskedVector<>
std::vector< ValueT >::const_iterator fast_iterator
estimate sample N-sigma clipped stdev (N set in StatisticsControl, default=3)
std::pair< double, double > Value
The type used to report (value, error) for desired statistics.
Property stringToStatisticsProperty(std::string const property)
Conversion function to switch a string to a Property (see Statistics.h)
infinite_iterator< ValueT > x_iterator
void setNumIter(int numIter)
StatisticsControl(double numSigmaClip=3.0, int numIter=3, lsst::afw::image::MaskPixel andMask=0x0, bool isNanSafe=true, WeightsBoolean useWeights=WEIGHTS_NONE)
Pass parameters to a Statistics object.
estimate sample N-sigma clipped mean (N set in StatisticsControl, default=3)
A base class for image defects.
Represent a 2-dimensional array of bitmask pixels.
estimate sample N-sigma clipped variance (N set in StatisticsControl, default=3)
A Mask wrapper to provide an infinite_iterator for Mask::row_begin().
int getWidth() const noexcept
A class to manipulate images, masks, and variance as a single object.
x_iterator row_begin(int) const noexcept
bool getWeightedIsSet() const noexcept
static MaskPixelT getPlaneBitMask(const std::vector< std::string > &names)
Return the bitmask corresponding to a vector of plane names OR'd together.
std::int32_t MaskPixel
default type for Masks and MaskedImage Masks
int getAndMask() const noexcept
lsst::afw::image::MaskedImage< EntryT >::VariancePtr getVariance() const
This iterator will never increment.
MaskPtr getMask() const
Return a (shared_ptr to) the MaskedImage's mask.
lsst::afw::image::MaskedImage< EntryT >::MaskPtr getMask() const
Extent< int, 2 > Extent2I
infinite_iterator(const ValueT *p)
estimate sample inter-quartile range
int getWidth() const
Return the number of columns in the image.
void setCalcErrorFromInputVariance(bool calcErrorFromInputVariance) noexcept
Reports invalid arguments.
A vector wrapper to provide a vector with the necessary methods and typedefs to be processed by Stati...
void setWeighted(bool useWeights) noexcept
find sum of pixels in the image
bool getWeighted() const noexcept
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects...
int getNoGoodPixelsMask() const noexcept
float VariancePixel
default type for MaskedImage variance images
Property
control what is calculated
ImageImposter(std::vector< ValueT > const &v)
void setAndMask(int andMask)