25 #if !defined(LSST_AFW_MATH_STATISTICS_H)
26 #define LSST_AFW_MATH_STATISTICS_H
43 #include "boost/iterator/iterator_adaptor.hpp"
44 #include "boost/tuple/tuple.hpp"
52 template<
typename>
class Image;
53 template<
typename,
typename,
typename>
class MaskedImage;
96 typedef std::shared_ptr<StatisticsControl>
Ptr;
97 typedef std::shared_ptr<StatisticsControl>
const ConstPtr;
100 double numSigmaClip = 3.0,
103 bool isNanSafe =
true,
117 }
catch(lsst::pex::exceptions::InvalidParameterError) {
215 typedef std::pair<double, double>
Value;
217 template<
typename ImageT,
typename MaskT,
typename VarianceT>
220 VarianceT
const &var,
224 template<
typename ImageT,
typename MaskT,
typename VarianceT,
typename WeightT>
227 VarianceT
const &var,
228 WeightT
const &weights,
258 template<
typename ImageT,
typename MaskT,
typename VarianceT,
typename WeightT>
261 VarianceT
const &var,
262 WeightT
const &weights,
272 template <
typename ValueT>
274 :
public boost::iterator_adaptor<infinite_iterator<ValueT>,
275 const ValueT*, const ValueT,
276 boost::forward_traversal_tag> {
288 template<
typename ValueT>
303 template<
typename Pixel>
310 return Statistics(img, msk, var, flags, sctrl);
318 template<
typename ImageT,
typename MaskT,
typename VarianceT>
321 VarianceT
const &var,
325 return Statistics(img, msk, var, flags, sctrl);
332 template<
typename Pixel>
339 if (sctrl.getWeighted() || sctrl.getCalcErrorFromInputVariance()) {
351 template<
typename Pixel>
359 if (sctrl.getWeighted() || sctrl.getCalcErrorFromInputVariance() ||
360 (!sctrl.getWeightedIsSet() && (weights.
getWidth() != 0 && weights.
getHeight() != 0))) {
383 template<
typename Pixel>
392 return Statistics(img, msk, var, flags, sctrl);
400 template<
typename ValueT>
405 typedef typename std::vector<ValueT>::const_iterator
x_iterator;
423 std::vector<ValueT>
const &
_v;
431 template<
typename EntryT>
439 return Statistics(img, msk, var, flags, sctrl);
446 template<
typename EntryT>
448 std::vector<WeightPixel>
const &vweights,
458 return Statistics(img, msk, var, weights, flags, sctrl);
465 template<
typename EntryT>
470 if (sctrl.getWeighted() || sctrl.getCalcErrorFromInputVariance()) {
482 template<
typename EntryT>
484 std::vector<WeightPixel>
const &vweights,
490 if (sctrl.getWeighted() || sctrl.getCalcErrorFromInputVariance()) {
ImageImposter(ImageImposter< ValueT > const &img)
Statistics makeStatistics(std::vector< EntryT > const &v, int const flags, StatisticsControl const &sctrl=StatisticsControl())
The makeStatistics() overload to handle std::vector<>
double getNumSigmaClip() const
lsst::afw::image::MaskPixel getOrMask() const
std::vector< ValueT >::const_iterator x_iterator
MaskImposter(ValueT val=0)
bool _weightsAreMultiplicative
lsst::afw::image::VariancePixel WeightPixel
get the or-mask of all pixels used.
void setNumSigmaClip(double numSigmaClip)
void doStatistics(ImageT const &img, MaskT const &msk, VarianceT const &var, WeightT const &weights, int const flags, StatisticsControl const &sctrl)
afw::geom::Extent2I getDimensions() const
WeightsBoolean _useWeights
x_iterator row_begin(int) const
estimate sample standard deviation
find mean value of square of pixel values
ImagePtr getImage(bool const noThrow=false) const
Return a (Ptr to) the MaskedImage's image.
void setMaskPropagationThreshold(int bit, double threshold)
When pixels with the given bit are rejected, we count what fraction the rejected pixels would have co...
void setNoGoodPixelsMask(int noGoodPixelsMask)
Statistics makeStatistics(lsst::afw::image::Image< Pixel > const &img, int const flags, StatisticsControl const &sctrl=StatisticsControl())
The makeStatistics() overload to handle regular (non-masked) Images.
std::shared_ptr< StatisticsControl > Ptr
We don't want anything.
StatisticsControl(double numSigmaClip=3.0, int numIter=3, lsst::afw::image::MaskPixel andMask=0x0, bool isNanSafe=true, int useWeights=WEIGHTS_NONE)
bool getCalcErrorFromInputVariance() const
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<>
Include errors of requested quantities.
Statistics makeStatistics(lsst::afw::math::MaskedVector< EntryT > const &mv, int const flags, StatisticsControl const &sctrl=StatisticsControl())
The makeStatistics() overload to handle lsst::afw::math::MaskedVector<>
A class to evaluate image statistics.
Statistics(ImageT const &img, MaskT const &msk, VarianceT const &var, int const flags, StatisticsControl const &sctrl=StatisticsControl())
Constructor for Statistics object.
VariancePtr getVariance(bool const noThrow=false) const
Return a (Ptr to) the MaskedImage's variance.
table::Key< table::Array< Kernel::Pixel > > image
x_iterator row_end(int) const
std::vector< ValueT >::const_iterator fast_iterator
lsst::afw::image::MaskedImage< EntryT >::VariancePtr getVariance() const
void setCalcErrorFromInputVariance(bool calcErrorFromInputVariance)
estimate sample N-sigma clipped stdev (N set in StatisticsControl, default=3)
double getValue(Property const prop=NOTHING) const
Return the value of the desired property (if specified in the constructor)
std::pair< double, double > Value
The type used to report (value, error) for desired statistics.
std::shared_ptr< StatisticsControl > const ConstPtr
infinite_iterator< ValueT > x_iterator
void setNumIter(int numIter)
Statistics makeStatistics(lsst::afw::image::MaskedImage< Pixel > const &mimg, lsst::afw::image::Image< WeightPixel > const &weights, int const flags, StatisticsControl const &sctrl=StatisticsControl())
Handle MaskedImages, just pass the getImage() and getMask() values right on through.
Statistics makeStatistics(ImageT const &img, MaskT const &msk, VarianceT const &var, int const flags, StatisticsControl const &sctrl=StatisticsControl())
Handle a straight front-end to the constructor.
Pass parameters to a Statistics objectA class to pass parameters which control how the stats are calc...
estimate sample N-sigma clipped mean (N set in StatisticsControl, default=3)
x_iterator row_begin(int) const
Represent a 2-dimensional array of bitmask pixels.
estimate sample N-sigma clipped variance (N set in StatisticsControl, default=3)
MaskPtr getMask(bool const noThrow=false) const
Return a (Ptr to) the MaskedImage's mask.
A Mask wrapper to provide an infinite_iterator for Mask::row_begin().
A class to manipulate images, masks, and variance as a single object.
int getHeight() const
Return the number of rows in the image.
lsst::afw::image::MaskPixel _allPixelOrMask
Statistics makeStatistics(std::vector< EntryT > const &v, std::vector< WeightPixel > const &vweights, int const flags, StatisticsControl const &sctrl=StatisticsControl())
The makeStatistics() overload to handle std::vector<>
std::vector< double > _maskPropagationThresholds
static MaskPixelT getPlaneBitMask(const std::vector< std::string > &names)
Return the bitmask corresponding to a vector of plane names OR'd together.
void setWeighted(bool useWeights)
This iterator will never increment.
lsst::afw::image::MaskedImage< EntryT >::MaskPtr getMask() const
infinite_iterator(const ValueT *p)
Value getResult(Property const prop=NOTHING) const
Return the value and error in the specified statistic (e.g.
estimate sample inter-quartile range
void setNanSafe(bool isNanSafe)
double getError(Property const prop=NOTHING) const
Return the error in the desired property (if specified in the constructor)
double getMaskPropagationThreshold(int bit) const
When pixels with the given bit are rejected, we count what fraction the rejected pixels would have co...
Statistics makeStatistics(afwImage::Mask< afwImage::MaskPixel > const &msk, int const flags, StatisticsControl const &sctrl)
Specialization to handle Masks.
A vector wrapper to provide a vector with the necessary methods and typedefs to be processed by Stati...
int getNoGoodPixelsMask() const
Property stringToStatisticsProperty(std::string const property)
Conversion function to switch a string to a Property (see Statistics.h)
bool _calcErrorFromInputVariance
Implementation of the Class MaskedImage.
find sum of pixels in the image
lsst::afw::image::MaskedImage< EntryT >::ImagePtr getImage() const
float VariancePixel
! default type for Masks and MaskedImage Masks
std::vector< ValueT > const & _v
Property
control what is calculated
int getWidth() const
Return the number of columns in the image.
Statistics makeStatistics(lsst::afw::image::MaskedImage< Pixel > const &mimg, int const flags, StatisticsControl const &sctrl=StatisticsControl())
Handle MaskedImages, just pass the getImage() and getMask() values right on through.
Extent< int, 2 > Extent2I
friend class boost::iterator_core_access
ImageImposter(std::vector< ValueT > const &v)
bool getWeightedIsSet() const
void setAndMask(int andMask)
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)
std::vector< ValueT > const & _getVector() const