LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
Public Types | Public Member Functions | Private Member Functions | Private Attributes | Related Functions | List of all members
lsst::afw::math::Statistics Class Reference

#include <Statistics.h>

Public Types

typedef std::pair< double, double > Value
 The type used to report (value, error) for desired statistics. More...
 

Public Member Functions

template<typename ImageT , typename MaskT , typename VarianceT >
 Statistics (ImageT const &img, MaskT const &msk, VarianceT const &var, int const flags, StatisticsControl const &sctrl=StatisticsControl())
 Constructor for Statistics object. More...
 
template<typename ImageT , typename MaskT , typename VarianceT , typename WeightT >
 Statistics (ImageT const &img, MaskT const &msk, VarianceT const &var, WeightT const &weights, int const flags, StatisticsControl const &sctrl=StatisticsControl())
 
Value getResult (Property const prop=NOTHING) const
 Return the value and error in the specified statistic (e.g. MEAN) More...
 
double getError (Property const prop=NOTHING) const
 Return the error in the desired property (if specified in the constructor) More...
 
double getValue (Property const prop=NOTHING) const
 Return the value of the desired property (if specified in the constructor) More...
 
lsst::afw::image::MaskPixel getOrMask () const
 
template<>
 Statistics (afwImage::Mask< afwImage::MaskPixel > const &msk, afwImage::Mask< afwImage::MaskPixel > const &, afwImage::Mask< afwImage::MaskPixel > const &, int const flags, StatisticsControl const &sctrl)
 

Private Member Functions

template<typename ImageT , typename MaskT , typename VarianceT , typename WeightT >
void doStatistics (ImageT const &img, MaskT const &msk, VarianceT const &var, WeightT const &weights, int const flags, StatisticsControl const &sctrl)
 

Private Attributes

long _flags
 
int _n
 
Value _mean
 
Value _variance
 
double _min
 
double _max
 
double _sum
 
Value _meanclip
 
Value _varianceclip
 
Value _median
 
double _iqrange
 
lsst::afw::image::MaskPixel _allPixelOrMask
 
StatisticsControl _sctrl
 
bool _weightsAreMultiplicative
 

Related Functions

(Note that these are not member functions.)

template<typename Pixel >
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) More...
 
template<typename ImageT , typename MaskT , typename VarianceT >
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. More...
 
template<typename Pixel >
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. More...
 
template<typename Pixel >
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. More...
 
Statistics makeStatistics (lsst::afw::image::Mask< lsst::afw::image::MaskPixel > const &msk, int const flags, StatisticsControl const &sctrl=StatisticsControl())
 Front end for specialization to handle Masks. More...
 
template<typename Pixel >
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. More...
 
template<typename EntryT >
Statistics makeStatistics (std::vector< EntryT > const &v, int const flags, StatisticsControl const &sctrl=StatisticsControl())
 The makeStatistics() overload to handle std::vector<> More...
 
template<typename EntryT >
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<> More...
 
template<typename EntryT >
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<> More...
 
template<typename EntryT >
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<> More...
 

Detailed Description

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
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)
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)
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.
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.
Examples:
imageStatistics.cc, and statistics.cc.

Definition at line 212 of file Statistics.h.

Member Typedef Documentation

typedef std::pair<double, double> lsst::afw::math::Statistics::Value

The type used to report (value, error) for desired statistics.

Definition at line 215 of file Statistics.h.

Constructor & Destructor Documentation

template<typename ImageT , typename MaskT , typename VarianceT >
lsst::afw::math::Statistics::Statistics ( ImageT const &  img,
MaskT const &  msk,
VarianceT const &  var,
int const  flags,
afwMath::StatisticsControl const &  sctrl = StatisticsControl() 
)
explicit

Constructor for Statistics object.

Note
Most of the actual work is done in this constructor; the results are retrieved using getValue etc.
Parameters
imgImage whose properties we want
mskMask to control which pixels are included
varVariances corresponding to values in Image
flagsDescribe what we want to calculate
sctrlControl how things are calculated

Definition at line 746 of file Statistics.cc.

752  :
753  _flags(flags), _mean(NaN, NaN), _variance(NaN, NaN), _min(NaN), _max(NaN), _sum(NaN),
754  _meanclip(NaN, NaN), _varianceclip(NaN, NaN), _median(NaN, NaN), _iqrange(NaN),
755  _sctrl(sctrl), _weightsAreMultiplicative(false)
756 {
757  doStatistics(img, msk, var, var, _flags, _sctrl);
758 }
void doStatistics(ImageT const &img, MaskT const &msk, VarianceT const &var, WeightT const &weights, int const flags, StatisticsControl const &sctrl)
Definition: Statistics.cc:793
StatisticsControl _sctrl
Definition: Statistics.h:255
template<typename ImageT , typename MaskT , typename VarianceT , typename WeightT >
lsst::afw::math::Statistics::Statistics ( ImageT const &  img,
MaskT const &  msk,
VarianceT const &  var,
WeightT const &  weights,
int const  flags,
afwMath::StatisticsControl const &  sctrl = StatisticsControl() 
)
explicit
Parameters
imgImage whose properties we want
mskMask to control which pixels are included
varVariances corresponding to values in Image
weightsWeights to use corresponding to values in Image
flagsDescribe what we want to calculate
sctrlControl how things are calculated

Definition at line 769 of file Statistics.cc.

776  :
777  _flags(flags), _mean(NaN, NaN), _variance(NaN, NaN), _min(NaN), _max(NaN), _sum(NaN),
778  _meanclip(NaN, NaN), _varianceclip(NaN, NaN), _median(NaN, NaN), _iqrange(NaN),
779  _sctrl(sctrl), _weightsAreMultiplicative(true)
780 {
781  if (!isEmpty(weights)) {
783  throw LSST_EXCEPT(lsst::pex::exceptions::InvalidParameterError,
784  "You must use the weights if you provide them");
785  }
786 
787  _sctrl.setWeighted(true);
788  }
789  doStatistics(img, msk, var, weights, _flags, _sctrl);
790 }
void doStatistics(ImageT const &img, MaskT const &msk, VarianceT const &var, WeightT const &weights, int const flags, StatisticsControl const &sctrl)
Definition: Statistics.cc:793
void setWeighted(bool useWeights)
Definition: Statistics.h:149
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
StatisticsControl _sctrl
Definition: Statistics.h:255
template<>
lsst::afw::math::Statistics::Statistics ( afwImage::Mask< afwImage::MaskPixel > const &  msk,
afwImage::Mask< afwImage::MaskPixel > const &  ,
afwImage::Mask< afwImage::MaskPixel > const &  ,
int const  flags,
StatisticsControl const &  sctrl 
)
Parameters
mskMask whose properties we want
flagsDescribe what we want to calculate
sctrlControl how things are calculated

Definition at line 1040 of file Statistics.cc.

1046  :
1047  _flags(flags),
1048  _mean(NaN, NaN), _variance(NaN, NaN), _min(NaN), _max(NaN),
1049  _meanclip(NaN, NaN), _varianceclip(NaN, NaN), _median(NaN, NaN), _iqrange(NaN),
1050  _sctrl(sctrl) {
1051 
1052  if ((flags & ~(NPOINT | SUM)) != 0x0) {
1053  throw LSST_EXCEPT(pexExceptions::InvalidParameterError, "Statistics<Mask> only supports NPOINT and SUM");
1054  }
1055 
1057 
1058  _n = msk.getWidth()*msk.getHeight();
1059  if (_n == 0) {
1060  throw LSST_EXCEPT(pexExceptions::InvalidParameterError, "Image contains no pixels");
1061  }
1062 
1063  // Check that an int's large enough to hold the number of pixels
1064  assert(msk.getWidth()*static_cast<double>(msk.getHeight()) < std::numeric_limits<int>::max());
1065 
1066  afwImage::MaskPixel sum = 0x0;
1067  for (int y = 0; y != msk.getHeight(); ++y) {
1068  for (Mask::x_iterator ptr = msk.row_begin(y), end = msk.row_end(y); ptr != end; ++ptr) {
1069  sum |= (*ptr)[0];
1070  }
1071  }
1072  _sum = sum;
1073 }
int y
boost::uint16_t MaskPixel
int const x0
Definition: saturated.cc:45
boost::enable_if< typename ExpressionTraits< Scalar >::IsScalar, Scalar >::type sum(Scalar const &scalar)
Definition: operators.h:1250
Represent a 2-dimensional array of bitmask pixels.
Definition: Mask.h:93
x_iterator row_end(int y) const
Return an x_iterator to the end of the y&#39;th row.
Definition: Image.h:324
number of sample points
Definition: Statistics.h:66
int getHeight() const
Return the number of rows in the image.
Definition: Image.h:239
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
x_iterator row_begin(int y) const
Definition: Image.h:319
find sum of pixels in the image
Definition: Statistics.h:78
int getWidth() const
Return the number of columns in the image.
Definition: Image.h:237
StatisticsControl _sctrl
Definition: Statistics.h:255

Member Function Documentation

template<typename ImageT , typename MaskT , typename VarianceT , typename WeightT >
void lsst::afw::math::Statistics::doStatistics ( ImageT const &  img,
MaskT const &  msk,
VarianceT const &  var,
WeightT const &  weights,
int const  flags,
afwMath::StatisticsControl const &  sctrl 
)
private
Parameters
imgImage whose properties we want
mskMask to control which pixels are included
varVariances corresponding to values in Image
weightsWeights to use corresponding to values in Image
flagsDescribe what we want to calculate
sctrlControl how things are calculated

Definition at line 793 of file Statistics.cc.

801 {
802  _n = img.getWidth()*img.getHeight();
803  if (_n == 0) {
804  throw LSST_EXCEPT(pexExceptions::InvalidParameterError, "Image contains no pixels");
805  }
806 
807  // Check that an int's large enough to hold the number of pixels
808  assert(img.getWidth()*static_cast<double>(img.getHeight()) < std::numeric_limits<int>::max());
809 
810  // get the standard statistics
811  StandardReturn standard = getStandard(img, msk, var, weights, flags,
813  _sctrl.getAndMask(),
817 
818  _n = standard.get<0>();
819  _sum = standard.get<1>();
820  _mean = standard.get<2>();
821  _variance = standard.get<3>();
822  _min = standard.get<4>();
823  _max = standard.get<5>();
824  _allPixelOrMask = standard.get<6>();
825 
826  // ==========================================================
827  // now only calculate it if it's specifically requested - these all cost more!
828 
829  // copy the image for any routines that will use median or quantiles
830  if (flags & (MEDIAN | IQRANGE | MEANCLIP | STDEVCLIP | VARIANCECLIP)) {
831 
832  // make a vector copy of the image to get the median and quartiles (will move values)
833  boost::shared_ptr<std::vector<typename ImageT::Pixel> > imgcp;
834  if (_sctrl.getNanSafe()) {
835  imgcp = makeVectorCopy<ChkFin>(img, msk, var, _sctrl.getAndMask());
836  } else {
837  imgcp = makeVectorCopy<AlwaysT>(img, msk, var, _sctrl.getAndMask());
838  }
839 
840  // if we *only* want the median, just use percentile(), otherwise use medianAndQuartiles()
841  if ( (flags & (MEDIAN)) && !(flags & (IQRANGE | MEANCLIP | STDEVCLIP | VARIANCECLIP)) ) {
842  _median = Value(percentile(*imgcp, 0.5), NaN);
843  } else {
844  MedianQuartileReturn mq = medianAndQuartiles(*imgcp);
845  _median = Value(mq.get<0>(), NaN);
846  _iqrange = mq.get<2>() - mq.get<1>();
847  }
848 
849 
850  if (flags & (MEANCLIP | STDEVCLIP | VARIANCECLIP)) {
851  for (int i_i = 0; i_i < _sctrl.getNumIter(); ++i_i) {
852  double const center = ((i_i > 0) ? _meanclip : _median).first;
853  double const hwidth = (i_i > 0 && _n > 1) ?
854  _sctrl.getNumSigmaClip()*std::sqrt(_varianceclip.first) :
855  _sctrl.getNumSigmaClip()*IQ_TO_STDEV*_iqrange;
856  std::pair<double, double> const clipinfo(center, hwidth);
857 
858  StandardReturn clipped = getStandard(img, msk, var, weights, flags, clipinfo,
860  _sctrl.getAndMask(),
864 
865  int const nClip = clipped.get<0>();
866  _meanclip = clipped.get<2>(); // clipped mean
867  double const varClip = clipped.get<3>().first; // clipped variance
868 
869  _varianceclip = Value(varClip, varianceError(varClip, nClip));
870  // ... ignore other values
871  }
872  }
873  }
874 }
bool getCalcErrorFromInputVariance() const
Definition: Statistics.h:142
estimate sample N-sigma clipped stdev (N set in StatisticsControl, default=3)
Definition: Statistics.h:73
std::pair< double, double > Value
The type used to report (value, error) for desired statistics.
Definition: Statistics.h:215
estimate sample median
Definition: Statistics.h:70
estimate sample N-sigma clipped mean (N set in StatisticsControl, default=3)
Definition: Statistics.h:72
lsst::afw::image::MaskPixel _allPixelOrMask
Definition: Statistics.h:253
std::vector< double > _maskPropagationThresholds
Definition: Statistics.h:165
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
estimate sample inter-quartile range
Definition: Statistics.h:71
StatisticsControl _sctrl
Definition: Statistics.h:255
double lsst::afw::math::Statistics::getError ( afwMath::Property const  prop = NOTHING) const

Return the error in the desired property (if specified in the constructor)

Parameters
propthe afw::math::Property to retrieve. If NOTHING (default) and you only asked for one property in the constructor, that property's error is returned
Note
You may have needed to specify ERROR to the ctor
Examples:
statistics.cc.

Definition at line 1020 of file Statistics.cc.

1025  {
1026  return getResult(prop).second;
1027 }
Value getResult(Property const prop=NOTHING) const
Return the value and error in the specified statistic (e.g. MEAN)
Definition: Statistics.cc:887
lsst::afw::image::MaskPixel lsst::afw::math::Statistics::getOrMask ( ) const
inline

Definition at line 236 of file Statistics.h.

236  {
237  return _allPixelOrMask;
238  }
lsst::afw::image::MaskPixel _allPixelOrMask
Definition: Statistics.h:253
std::pair< double, double > lsst::afw::math::Statistics::getResult ( afwMath::Property const  iProp = NOTHING) const

Return the value and error in the specified statistic (e.g. MEAN)

Note
Only quantities requested in the constructor may be retrieved; in particular errors may not be available if you didn't specify ERROR in the constructor
See Also
getValue and getError
Todo:
uncertainties on MEANCLIP,STDEVCLIP are sketchy. _n != _nClip
Parameters
iPropthe afw::math::Property to retrieve. If NOTHING (default) and you only asked for one property (and maybe its error) in the constructor, that property is returned
Examples:
statistics.cc.

Definition at line 887 of file Statistics.cc.

892  {
893 
894  // if iProp == NOTHING try to return their heart's delight, as specified in the constructor
895  afwMath::Property const prop =
896  static_cast<afwMath::Property>(((iProp == NOTHING) ? _flags : iProp) & ~ERRORS);
897 
898  if (!(prop & _flags)) { // we didn't calculate it
899  throw LSST_EXCEPT(pexExceptions::InvalidParameterError,
900  (boost::format("You didn't ask me to calculate %d") % prop).str());
901  }
902 
903 
904  Value ret(NaN, NaN);
905  switch (prop) {
906 
907  case NPOINT:
908  ret.first = static_cast<double>(_n);
909  if (_flags & ERRORS) {
910  ret.second = 0;
911  }
912  break;
913 
914  case SUM:
915  ret.first = static_cast<double>(_sum);
916  if (_flags & ERRORS) {
917  ret.second = 0;
918  }
919  break;
920 
921  // == means ==
922  case MEAN:
923  ret.first = _mean.first;
924  if (_flags & ERRORS) {
925  ret.second = ::sqrt(_mean.second);
926  }
927  break;
928  case MEANCLIP:
929  ret.first = _meanclip.first;
930  if ( _flags & ERRORS ) {
931  ret.second = ::sqrt(_meanclip.second);
932  }
933  break;
934 
935  // == stdevs & variances ==
936  case VARIANCE:
937  ret.first = _variance.first;
938  if (_flags & ERRORS) {
939  ret.second = ::sqrt(_variance.second);
940  }
941  break;
942  case STDEV:
943  ret.first = sqrt(_variance.first);
944  if (_flags & ERRORS) {
945  ret.second = 0.5*::sqrt(_variance.second)/ret.first;
946  }
947  break;
948  case VARIANCECLIP:
949  ret.first = _varianceclip.first;
950  if (_flags & ERRORS) {
951  ret.second = ret.second;
952  }
953  break;
954  case STDEVCLIP:
955  ret.first = sqrt(_varianceclip.first);
956  if (_flags & ERRORS) {
957  ret.second = 0.5*::sqrt(_varianceclip.second)/ret.first;
958  }
959  break;
960 
961  case MEANSQUARE:
962  ret.first = (_n - 1)/static_cast<double>(_n)*_variance.first + ::pow(_mean.first, 2);
963  if (_flags & ERRORS) {
964  ret.second = ::sqrt(2*::pow(ret.first/_n, 2)); // assumes Gaussian
965  }
966  break;
967 
968  // == other stats ==
969  case MIN:
970  ret.first = _min;
971  if ( _flags & ERRORS ) {
972  ret.second = 0;
973  }
974  break;
975  case MAX:
976  ret.first = _max;
977  if ( _flags & ERRORS ) {
978  ret.second = 0;
979  }
980  break;
981  case MEDIAN:
982  ret.first = _median.first;
983  if ( _flags & ERRORS ) {
984  ret.second = sqrt(afwGeom::HALFPI*_variance.first/_n); // assumes Gaussian
985  }
986  break;
987  case IQRANGE:
988  ret.first = _iqrange;
989  if ( _flags & ERRORS ) {
990  ret.second = NaN; // we're not estimating this properly
991  }
992  break;
993 
994  // no-op to satisfy the compiler
995  case ERRORS:
996  break;
997  // default: redundant as 'ret' is initialized to NaN, NaN
998  default: // we must have set prop to _flags
999  assert (iProp == 0);
1000  throw LSST_EXCEPT(lsst::pex::exceptions::InvalidParameterError,
1001  "getValue() may only be called without a parameter"
1002  " if you asked for only one statistic");
1003  }
1004  return ret;
1005 }
estimate sample minimum
Definition: Statistics.h:76
estimate sample standard deviation
Definition: Statistics.h:68
find mean value of square of pixel values
Definition: Statistics.h:79
estimate sample maximum
Definition: Statistics.h:77
We don&#39;t want anything.
Definition: Statistics.h:64
Include errors of requested quantities.
Definition: Statistics.h:65
estimate sample N-sigma clipped stdev (N set in StatisticsControl, default=3)
Definition: Statistics.h:73
std::pair< double, double > Value
The type used to report (value, error) for desired statistics.
Definition: Statistics.h:215
estimate sample median
Definition: Statistics.h:70
estimate sample N-sigma clipped mean (N set in StatisticsControl, default=3)
Definition: Statistics.h:72
number of sample points
Definition: Statistics.h:66
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
estimate sample inter-quartile range
Definition: Statistics.h:71
estimate sample mean
Definition: Statistics.h:67
double const HALFPI
Definition: Angle.h:20
estimate sample variance
Definition: Statistics.h:69
find sum of pixels in the image
Definition: Statistics.h:78
Property
control what is calculated
Definition: Statistics.h:63
double lsst::afw::math::Statistics::getValue ( afwMath::Property const  prop = NOTHING) const

Return the value of the desired property (if specified in the constructor)

Parameters
propthe afw::math::Property to retrieve. If NOTHING (default) and you only asked for one property in the constructor, that property is returned
Examples:
imageStatistics.cc, and statistics.cc.

Definition at line 1009 of file Statistics.cc.

1013  {
1014  return getResult(prop).first;
1015 }
Value getResult(Property const prop=NOTHING) const
Return the value and error in the specified statistic (e.g. MEAN)
Definition: Statistics.cc:887

Friends And Related Function Documentation

template<typename Pixel >
Statistics makeStatistics ( lsst::afw::image::Image< Pixel > const &  img,
lsst::afw::image::Mask< image::MaskPixel > const &  msk,
int const  flags,
StatisticsControl const &  sctrl = StatisticsControl() 
)
related

Handle a watered-down front-end to the constructor (no variance)

Examples:
imageStatistics.cc.

Definition at line 304 of file Statistics.h.

308  {
309  MaskImposter<WeightPixel> var;
310  return Statistics(img, msk, var, flags, sctrl);
311 }
Statistics(ImageT const &img, MaskT const &msk, VarianceT const &var, int const flags, StatisticsControl const &sctrl=StatisticsControl())
Constructor for Statistics object.
Definition: Statistics.cc:746
template<typename ImageT , typename MaskT , typename VarianceT >
Statistics makeStatistics ( ImageT const &  img,
MaskT const &  msk,
VarianceT const &  var,
int const  flags,
StatisticsControl const &  sctrl = StatisticsControl() 
)
related

Handle a straight front-end to the constructor.

Definition at line 319 of file Statistics.h.

324  {
325  return Statistics(img, msk, var, flags, sctrl);
326 }
Statistics(ImageT const &img, MaskT const &msk, VarianceT const &var, int const flags, StatisticsControl const &sctrl=StatisticsControl())
Constructor for Statistics object.
Definition: Statistics.cc:746
template<typename Pixel >
Statistics makeStatistics ( lsst::afw::image::MaskedImage< Pixel > const &  mimg,
int const  flags,
StatisticsControl const &  sctrl = StatisticsControl() 
)
related

Handle MaskedImages, just pass the getImage() and getMask() values right on through.

Definition at line 333 of file Statistics.h.

338 {
339  if (sctrl.getWeighted() || sctrl.getCalcErrorFromInputVariance()) {
340  return Statistics(*mimg.getImage(), *mimg.getMask(), *mimg.getVariance(), flags, sctrl);
341  } else {
342  MaskImposter<WeightPixel> var;
343  return Statistics(*mimg.getImage(), *mimg.getMask(), var, flags, sctrl);
344  }
345 }
ImagePtr getImage(bool const noThrow=false) const
Return a (Ptr to) the MaskedImage&#39;s image.
Definition: MaskedImage.h:869
Statistics(ImageT const &img, MaskT const &msk, VarianceT const &var, int const flags, StatisticsControl const &sctrl=StatisticsControl())
Constructor for Statistics object.
Definition: Statistics.cc:746
VariancePtr getVariance(bool const noThrow=false) const
Return a (Ptr to) the MaskedImage&#39;s variance.
Definition: MaskedImage.h:890
MaskPtr getMask(bool const noThrow=false) const
Return a (Ptr to) the MaskedImage&#39;s mask.
Definition: MaskedImage.h:879
template<typename Pixel >
Statistics makeStatistics ( lsst::afw::image::MaskedImage< Pixel > const &  mimg,
lsst::afw::image::Image< WeightPixel > const &  weights,
int const  flags,
StatisticsControl const &  sctrl = StatisticsControl() 
)
related

Handle MaskedImages, just pass the getImage() and getMask() values right on through.

Definition at line 352 of file Statistics.h.

358 {
359  if (sctrl.getWeighted() || sctrl.getCalcErrorFromInputVariance() ||
360  (!sctrl.getWeightedIsSet() && (weights.getWidth() != 0 && weights.getHeight() != 0))) {
361  return Statistics(*mimg.getImage(), *mimg.getMask(), *mimg.getVariance(), weights, flags, sctrl);
362  } else {
363  MaskImposter<WeightPixel> var;
364  return Statistics(*mimg.getImage(), *mimg.getMask(), var, weights, flags, sctrl);
365  }
366 }
ImagePtr getImage(bool const noThrow=false) const
Return a (Ptr to) the MaskedImage&#39;s image.
Definition: MaskedImage.h:869
Statistics(ImageT const &img, MaskT const &msk, VarianceT const &var, int const flags, StatisticsControl const &sctrl=StatisticsControl())
Constructor for Statistics object.
Definition: Statistics.cc:746
VariancePtr getVariance(bool const noThrow=false) const
Return a (Ptr to) the MaskedImage&#39;s variance.
Definition: MaskedImage.h:890
MaskPtr getMask(bool const noThrow=false) const
Return a (Ptr to) the MaskedImage&#39;s mask.
Definition: MaskedImage.h:879
int getHeight() const
Return the number of rows in the image.
Definition: Image.h:239
int getWidth() const
Return the number of columns in the image.
Definition: Image.h:237
Statistics makeStatistics ( lsst::afw::image::Mask< lsst::afw::image::MaskPixel > const &  msk,
int const  flags,
StatisticsControl const &  sctrl = StatisticsControl() 
)
related

Front end for specialization to handle Masks.

Note
The definition (in Statistics.cc) simply calls the specialized constructor

Definition at line 1082 of file Statistics.cc.

1086  {
1087  return Statistics(msk, msk, msk, flags, sctrl);
1088 }
Statistics(ImageT const &img, MaskT const &msk, VarianceT const &var, int const flags, StatisticsControl const &sctrl=StatisticsControl())
Constructor for Statistics object.
Definition: Statistics.cc:746
template<typename Pixel >
Statistics makeStatistics ( lsst::afw::image::Image< Pixel > const &  img,
int const  flags,
StatisticsControl const &  sctrl = StatisticsControl() 
)
related

The makeStatistics() overload to handle regular (non-masked) Images.

Parameters
imgImage (or Image) whose properties we want
flagsDescribe what we want to calculate
sctrlControl calculation

Definition at line 384 of file Statistics.h.

388  {
389  // make a phony mask that will be compiled out
390  MaskImposter<lsst::afw::image::MaskPixel> const msk;
391  MaskImposter<WeightPixel> const var;
392  return Statistics(img, msk, var, flags, sctrl);
393 }
Statistics(ImageT const &img, MaskT const &msk, VarianceT const &var, int const flags, StatisticsControl const &sctrl=StatisticsControl())
Constructor for Statistics object.
Definition: Statistics.cc:746
template<typename EntryT >
Statistics makeStatistics ( std::vector< EntryT > const &  v,
int const  flags,
StatisticsControl const &  sctrl = StatisticsControl() 
)
related

The makeStatistics() overload to handle std::vector<>

Parameters
vImage (or MaskedImage) whose properties we want
flagsDescribe what we want to calculate
sctrlControl calculation

Definition at line 431 of file Statistics.h.

434  {
435  ImageImposter<EntryT> img(v); // wrap the vector in a fake image
436  MaskImposter<lsst::afw::image::MaskPixel> msk; // instantiate a fake mask that will be compiled out.
437  MaskImposter<WeightPixel> var;
438  return Statistics(img, msk, var, flags, sctrl);
439 }
Statistics(ImageT const &img, MaskT const &msk, VarianceT const &var, int const flags, StatisticsControl const &sctrl=StatisticsControl())
Constructor for Statistics object.
Definition: Statistics.cc:746
template<typename EntryT >
Statistics makeStatistics ( std::vector< EntryT > const &  v,
std::vector< WeightPixel > const &  vweights,
int const  flags,
StatisticsControl const &  sctrl = StatisticsControl() 
)
related

The makeStatistics() overload to handle std::vector<>

Parameters
vImage (or MaskedImage) whose properties we want
vweightsWeights
flagsDescribe what we want to calculate
sctrlControl calculation

Definition at line 446 of file Statistics.h.

450  {
451  ImageImposter<EntryT> img(v); // wrap the vector in a fake image
452  MaskImposter<lsst::afw::image::MaskPixel> msk; // instantiate a fake mask that will be compiled out.
453  MaskImposter<WeightPixel> var;
454 
455  ImageImposter<WeightPixel> weights(vweights);
456 
457  return Statistics(img, msk, var, weights, flags, sctrl);
458 }
Statistics(ImageT const &img, MaskT const &msk, VarianceT const &var, int const flags, StatisticsControl const &sctrl=StatisticsControl())
Constructor for Statistics object.
Definition: Statistics.cc:746
template<typename EntryT >
Statistics makeStatistics ( lsst::afw::math::MaskedVector< EntryT > const &  mv,
int const  flags,
StatisticsControl const &  sctrl = StatisticsControl() 
)
related

The makeStatistics() overload to handle lsst::afw::math::MaskedVector<>

Parameters
mvMaskedVector
flagsDescribe what we want to calculate
sctrlControl calculation

Definition at line 465 of file Statistics.h.

468  {
469  if (sctrl.getWeighted() || sctrl.getCalcErrorFromInputVariance()) {
470  return Statistics(*mv.getImage(), *mv.getMask(), *mv.getVariance(), flags, sctrl);
471  } else {
472  MaskImposter<WeightPixel> var;
473  return Statistics(*mv.getImage(), *mv.getMask(), var, flags, sctrl);
474  }
475 }
Statistics(ImageT const &img, MaskT const &msk, VarianceT const &var, int const flags, StatisticsControl const &sctrl=StatisticsControl())
Constructor for Statistics object.
Definition: Statistics.cc:746
lsst::afw::image::MaskedImage< EntryT >::VariancePtr getVariance() const
Definition: MaskedVector.h:89
lsst::afw::image::MaskedImage< EntryT >::MaskPtr getMask() const
Definition: MaskedVector.h:86
lsst::afw::image::MaskedImage< EntryT >::ImagePtr getImage() const
Definition: MaskedVector.h:83
template<typename EntryT >
Statistics makeStatistics ( lsst::afw::math::MaskedVector< EntryT > const &  mv,
std::vector< WeightPixel > const &  vweights,
int const  flags,
StatisticsControl const &  sctrl = StatisticsControl() 
)
related

The makeStatistics() overload to handle lsst::afw::math::MaskedVector<>

Parameters
mvMaskedVector
vweightsweights
flagsDescribe what we want to calculate
sctrlControl calculation

Definition at line 482 of file Statistics.h.

486  {
487  ImageImposter<WeightPixel> weights(vweights);
488 
489  if (sctrl.getWeighted() || sctrl.getCalcErrorFromInputVariance()) {
490  return Statistics(*mv.getImage(), *mv.getMask(), *mv.getVariance(), weights, flags, sctrl);
491  } else {
492  MaskImposter<WeightPixel> var;
493  return Statistics(*mv.getImage(), *mv.getMask(), var, weights, flags, sctrl);
494  }
495 }
Statistics(ImageT const &img, MaskT const &msk, VarianceT const &var, int const flags, StatisticsControl const &sctrl=StatisticsControl())
Constructor for Statistics object.
Definition: Statistics.cc:746
lsst::afw::image::MaskedImage< EntryT >::VariancePtr getVariance() const
Definition: MaskedVector.h:89
lsst::afw::image::MaskedImage< EntryT >::MaskPtr getMask() const
Definition: MaskedVector.h:86
lsst::afw::image::MaskedImage< EntryT >::ImagePtr getImage() const
Definition: MaskedVector.h:83

Member Data Documentation

lsst::afw::image::MaskPixel lsst::afw::math::Statistics::_allPixelOrMask
private

Definition at line 253 of file Statistics.h.

long lsst::afw::math::Statistics::_flags
private

Definition at line 241 of file Statistics.h.

double lsst::afw::math::Statistics::_iqrange
private

Definition at line 252 of file Statistics.h.

double lsst::afw::math::Statistics::_max
private

Definition at line 247 of file Statistics.h.

Value lsst::afw::math::Statistics::_mean
private

Definition at line 244 of file Statistics.h.

Value lsst::afw::math::Statistics::_meanclip
private

Definition at line 249 of file Statistics.h.

Value lsst::afw::math::Statistics::_median
private

Definition at line 251 of file Statistics.h.

double lsst::afw::math::Statistics::_min
private

Definition at line 246 of file Statistics.h.

int lsst::afw::math::Statistics::_n
private

Definition at line 243 of file Statistics.h.

StatisticsControl lsst::afw::math::Statistics::_sctrl
private

Definition at line 255 of file Statistics.h.

double lsst::afw::math::Statistics::_sum
private

Definition at line 248 of file Statistics.h.

Value lsst::afw::math::Statistics::_variance
private

Definition at line 245 of file Statistics.h.

Value lsst::afw::math::Statistics::_varianceclip
private

Definition at line 250 of file Statistics.h.

bool lsst::afw::math::Statistics::_weightsAreMultiplicative
private

Definition at line 256 of file Statistics.h.


The documentation for this class was generated from the following files: