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"
45 #include "boost/shared_ptr.hpp"
52 template<
typename>
class Image;
53 template<
typename,
typename,
typename>
class MaskedImage;
96 typedef boost::shared_ptr<StatisticsControl>
Ptr;
97 typedef boost::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;
422 std::vector<ValueT>
const &
_v;
430 template<
typename EntryT>
438 return Statistics(img, msk, var, flags, sctrl);
445 template<
typename EntryT>
447 std::vector<WeightPixel>
const &vweights,
457 return Statistics(img, msk, var, weights, flags, sctrl);
464 template<
typename EntryT>
469 if (sctrl.getWeighted() || sctrl.getCalcErrorFromInputVariance()) {
481 template<
typename EntryT>
483 std::vector<WeightPixel>
const &vweights,
489 if (sctrl.getWeighted() || sctrl.getCalcErrorFromInputVariance()) {
ImageImposter(ImageImposter< ValueT > const &img)
double getValue(Property const prop=NOTHING) const
Return the value of the desired property (if specified in the constructor)
boost::uint16_t MaskPixel
double getMaskPropagationThreshold(int bit) const
ImagePtr getImage(bool const noThrow=false) const
Return a (Ptr to) the MaskedImage's image.
Statistics makeStatistics(std::vector< EntryT > const &v, int const flags, StatisticsControl const &sctrl=StatisticsControl())
The makeStatistics() overload to handle std::vector<>
boost::shared_ptr< StatisticsControl > Ptr
lsst::afw::image::MaskedImage< EntryT >::VariancePtr getVariance() const
lsst::afw::image::MaskedImage< EntryT >::MaskPtr getMask() const
std::pair< double, double > Value
The type used to report (value, error) for desired statistics.
std::vector< ValueT > const & _getVector() const
estimate sample N-sigma clipped mean (N set in StatisticsControl, default=3)
void setNumIter(int numIter)
int getNoGoodPixelsMask() const
StatisticsControl(double numSigmaClip=3.0, int numIter=3, lsst::afw::image::MaskPixel andMask=0x0, bool isNanSafe=true, int useWeights=WEIGHTS_NONE)
infinite_iterator< ValueT > x_iterator
void setAndMask(int andMask)
x_iterator row_begin(int) const
MaskImposter(ValueT val=0)
Statistics(ImageT const &img, MaskT const &msk, VarianceT const &var, int const flags, StatisticsControl const &sctrl=StatisticsControl())
Constructor for Statistics object.
estimate sample standard deviation
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.
find sum of pixels in the image
Value getResult(Property const prop=NOTHING) const
Return the value and error in the specified statistic (e.g. MEAN)
ImageImposter(std::vector< ValueT > const &v)
lsst::afw::image::VariancePixel WeightPixel
boost::shared_ptr< StatisticsControl > const ConstPtr
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<>
estimate sample N-sigma clipped stdev (N set in StatisticsControl, default=3)
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<>
find mean value of square of pixel values
lsst::afw::image::MaskedImage< EntryT >::ImagePtr getImage() const
infinite_iterator(const ValueT *p)
table::Key< table::Array< Kernel::Pixel > > image
Include errors of requested quantities.
We don't want anything.
VariancePtr getVariance(bool const noThrow=false) const
Return a (Ptr to) the MaskedImage's variance.
lsst::afw::image::MaskPixel getOrMask() const
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.
int getWidth() const
Return the number of columns in the image.
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...
void doStatistics(ImageT const &img, MaskT const &msk, VarianceT const &var, WeightT const &weights, int const flags, StatisticsControl const &sctrl)
static MaskPixelT getPlaneBitMask(const std::vector< std::string > &names)
Return the bitmask corresponding to a vector of plane names OR'd together.
void setNumSigmaClip(double numSigmaClip)
Represent a 2-dimensional array of bitmask pixels.
void setNanSafe(bool isNanSafe)
std::vector< ValueT >::const_iterator fast_iterator
A Mask wrapper to provide an infinite_iterator for Mask::row_begin(). This allows a fake Mask to be p...
bool getWeightedIsSet() const
A class to manipulate images, masks, and variance as a single object.
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<>
void setCalcErrorFromInputVariance(bool calcErrorFromInputVariance)
WeightsBoolean _useWeights
double getNumSigmaClip() const
float VariancePixel
! default type for Masks and MaskedImage Masks
double getError(Property const prop=NOTHING) const
Return the error in the desired property (if specified in the constructor)
std::vector< ValueT > const & _v
This iterator will never increment. It is returned by row_begin() in the MaskImposter class (below) t...
std::vector< ValueT >::const_iterator x_iterator
bool getCalcErrorFromInputVariance() const
MaskPtr getMask(bool const noThrow=false) const
Return a (Ptr to) the MaskedImage's mask.
void setMaskPropagationThreshold(int bit, double threshold)
void setWeighted(bool useWeights)
void setNoGoodPixelsMask(int noGoodPixelsMask)
estimate sample inter-quartile range
lsst::afw::image::MaskPixel _allPixelOrMask
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...
get the or-mask of all pixels used.
Property stringToStatisticsProperty(std::string const property)
Conversion function to switch a string to a Property (see Statistics.h)
Implementation of the Class MaskedImage.
int getHeight() const
Return the number of rows in the image.
bool _weightsAreMultiplicative
x_iterator row_end(int) const
Property
control what is calculated
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.
friend class boost::iterator_core_access
std::vector< double > _maskPropagationThresholds
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)
x_iterator row_begin(int) const
bool _calcErrorFromInputVariance