LSSTApplications  1.1.2+25,10.0+13,10.0+132,10.0+133,10.0+224,10.0+41,10.0+8,10.0-1-g0f53050+14,10.0-1-g4b7b172+19,10.0-1-g61a5bae+98,10.0-1-g7408a83+3,10.0-1-gc1e0f5a+19,10.0-1-gdb4482e+14,10.0-11-g3947115+2,10.0-12-g8719d8b+2,10.0-15-ga3f480f+1,10.0-2-g4f67435,10.0-2-gcb4bc6c+26,10.0-28-gf7f57a9+1,10.0-3-g1bbe32c+14,10.0-3-g5b46d21,10.0-4-g027f45f+5,10.0-4-g86f66b5+2,10.0-4-gc4fccf3+24,10.0-40-g4349866+2,10.0-5-g766159b,10.0-5-gca2295e+25,10.0-6-g462a451+1
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 196 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 199 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 689 of file Statistics.cc.

695  :
696  _flags(flags), _mean(NaN, NaN), _variance(NaN, NaN), _min(NaN), _max(NaN), _sum(NaN),
697  _meanclip(NaN, NaN), _varianceclip(NaN, NaN), _median(NaN, NaN), _iqrange(NaN),
698  _sctrl(sctrl), _weightsAreMultiplicative(false)
699 {
700  doStatistics(img, msk, var, var, _flags, _sctrl);
701 }
void doStatistics(ImageT const &img, MaskT const &msk, VarianceT const &var, WeightT const &weights, int const flags, StatisticsControl const &sctrl)
Definition: Statistics.cc:736
StatisticsControl _sctrl
Definition: Statistics.h:239
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 712 of file Statistics.cc.

719  :
720  _flags(flags), _mean(NaN, NaN), _variance(NaN, NaN), _min(NaN), _max(NaN), _sum(NaN),
721  _meanclip(NaN, NaN), _varianceclip(NaN, NaN), _median(NaN, NaN), _iqrange(NaN),
722  _sctrl(sctrl), _weightsAreMultiplicative(true)
723 {
724  if (!isEmpty(weights)) {
726  throw LSST_EXCEPT(lsst::pex::exceptions::InvalidParameterError,
727  "You must use the weights if you provide them");
728  }
729 
730  _sctrl.setWeighted(true);
731  }
732  doStatistics(img, msk, var, weights, _flags, _sctrl);
733 }
void doStatistics(ImageT const &img, MaskT const &msk, VarianceT const &var, WeightT const &weights, int const flags, StatisticsControl const &sctrl)
Definition: Statistics.cc:736
StatisticsControl _sctrl
Definition: Statistics.h:239
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
void setWeighted(bool useWeights)
Definition: Statistics.h:138
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 981 of file Statistics.cc.

987  :
988  _flags(flags),
989  _mean(NaN, NaN), _variance(NaN, NaN), _min(NaN), _max(NaN),
990  _meanclip(NaN, NaN), _varianceclip(NaN, NaN), _median(NaN, NaN), _iqrange(NaN),
991  _sctrl(sctrl) {
992 
993  if ((flags & ~(NPOINT | SUM)) != 0x0) {
994  throw LSST_EXCEPT(pexExceptions::InvalidParameterError, "Statistics<Mask> only supports NPOINT and SUM");
995  }
996 
998 
999  _n = msk.getWidth()*msk.getHeight();
1000  if (_n == 0) {
1001  throw LSST_EXCEPT(pexExceptions::InvalidParameterError, "Image contains no pixels");
1002  }
1003 
1004  // Check that an int's large enough to hold the number of pixels
1005  assert(msk.getWidth()*static_cast<double>(msk.getHeight()) < std::numeric_limits<int>::max());
1006 
1007  afwImage::MaskPixel sum = 0x0;
1008  for (int y = 0; y != msk.getHeight(); ++y) {
1009  for (Mask::x_iterator ptr = msk.row_begin(y), end = msk.row_end(y); ptr != end; ++ptr) {
1010  sum |= (*ptr)[0];
1011  }
1012  }
1013  _sum = sum;
1014 }
int y
boost::uint16_t MaskPixel
x_iterator row_begin(int y) const
Definition: Image.h:319
x_iterator row_end(int y) const
Return an x_iterator to the end of the y&#39;th row.
Definition: Image.h:324
find sum of pixels in the image
Definition: Statistics.h:78
int const x0
Definition: saturated.cc:45
boost::enable_if< typename ExpressionTraits< Scalar >::IsScalar, Scalar >::type sum(Scalar const &scalar)
Definition: operators.h:1250
int getWidth() const
Return the number of columns in the image.
Definition: Image.h:237
double max
Definition: attributes.cc:218
Represent a 2-dimensional array of bitmask pixels.
Definition: Mask.h:93
StatisticsControl _sctrl
Definition: Statistics.h:239
number of sample points
Definition: Statistics.h:66
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
int getHeight() const
Return the number of rows in the image.
Definition: Image.h:239

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 736 of file Statistics.cc.

744 {
745  _n = img.getWidth()*img.getHeight();
746  if (_n == 0) {
747  throw LSST_EXCEPT(pexExceptions::InvalidParameterError, "Image contains no pixels");
748  }
749 
750  // Check that an int's large enough to hold the number of pixels
751  assert(img.getWidth()*static_cast<double>(img.getHeight()) < std::numeric_limits<int>::max());
752 
753  // get the standard statistics
754  StandardReturn standard = getStandard(img, msk, var, weights, flags,
756  _sctrl.getAndMask(),
759 
760  _n = standard.get<0>();
761  _sum = standard.get<1>();
762  _mean = standard.get<2>();
763  _variance = standard.get<3>();
764  _min = standard.get<4>();
765  _max = standard.get<5>();
766  _allPixelOrMask = standard.get<6>();
767 
768  // ==========================================================
769  // now only calculate it if it's specifically requested - these all cost more!
770 
771  // copy the image for any routines that will use median or quantiles
772  if (flags & (MEDIAN | IQRANGE | MEANCLIP | STDEVCLIP | VARIANCECLIP)) {
773 
774  // make a vector copy of the image to get the median and quartiles (will move values)
775  boost::shared_ptr<std::vector<typename ImageT::Pixel> > imgcp;
776  if (_sctrl.getNanSafe()) {
777  imgcp = makeVectorCopy<ChkFin>(img, msk, var, _sctrl.getAndMask());
778  } else {
779  imgcp = makeVectorCopy<AlwaysT>(img, msk, var, _sctrl.getAndMask());
780  }
781 
782  // if we *only* want the median, just use percentile(), otherwise use medianAndQuartiles()
783  if ( (flags & (MEDIAN)) && !(flags & (IQRANGE | MEANCLIP | STDEVCLIP | VARIANCECLIP)) ) {
784  _median = Value(percentile(*imgcp, 0.5), NaN);
785  } else {
786  MedianQuartileReturn mq = medianAndQuartiles(*imgcp);
787  _median = Value(mq.get<0>(), NaN);
788  _iqrange = mq.get<2>() - mq.get<1>();
789  }
790 
791 
792  if (flags & (MEANCLIP | STDEVCLIP | VARIANCECLIP)) {
793  for (int i_i = 0; i_i < _sctrl.getNumIter(); ++i_i) {
794  double const center = ((i_i > 0) ? _meanclip : _median).first;
795  double const hwidth = (i_i > 0 && _n > 1) ?
796  _sctrl.getNumSigmaClip()*std::sqrt(_varianceclip.first) :
797  _sctrl.getNumSigmaClip()*IQ_TO_STDEV*_iqrange;
798  std::pair<double, double> const clipinfo(center, hwidth);
799 
800  StandardReturn clipped = getStandard(img, msk, var, weights, flags, clipinfo,
802  _sctrl.getAndMask(),
805 
806  int const nClip = clipped.get<0>();
807  _meanclip = clipped.get<2>(); // clipped mean
808  double const varClip = clipped.get<3>().first; // clipped variance
809 
810  _varianceclip = Value(varClip, varianceError(varClip, nClip));
811  // ... ignore other values
812  }
813  }
814  }
815 }
std::pair< double, double > Value
The type used to report (value, error) for desired statistics.
Definition: Statistics.h:199
estimate sample N-sigma clipped mean (N set in StatisticsControl, default=3)
Definition: Statistics.h:72
estimate sample N-sigma clipped stdev (N set in StatisticsControl, default=3)
Definition: Statistics.h:73
double max
Definition: attributes.cc:218
StatisticsControl _sctrl
Definition: Statistics.h:239
estimate sample median
Definition: Statistics.h:70
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
bool getCalcErrorFromInputVariance() const
Definition: Statistics.h:131
estimate sample inter-quartile range
Definition: Statistics.h:71
lsst::afw::image::MaskPixel _allPixelOrMask
Definition: Statistics.h:237
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 961 of file Statistics.cc.

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

Definition at line 220 of file Statistics.h.

220  {
221  return _allPixelOrMask;
222  }
lsst::afw::image::MaskPixel _allPixelOrMask
Definition: Statistics.h:237
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 828 of file Statistics.cc.

833  {
834 
835  // if iProp == NOTHING try to return their heart's delight, as specified in the constructor
836  afwMath::Property const prop =
837  static_cast<afwMath::Property>(((iProp == NOTHING) ? _flags : iProp) & ~ERRORS);
838 
839  if (!(prop & _flags)) { // we didn't calculate it
840  throw LSST_EXCEPT(pexExceptions::InvalidParameterError,
841  (boost::format("You didn't ask me to calculate %d") % prop).str());
842  }
843 
844 
845  Value ret(NaN, NaN);
846  switch (prop) {
847 
848  case NPOINT:
849  ret.first = static_cast<double>(_n);
850  if (_flags & ERRORS) {
851  ret.second = 0;
852  }
853  break;
854 
855  case SUM:
856  ret.first = static_cast<double>(_sum);
857  if (_flags & ERRORS) {
858  ret.second = 0;
859  }
860  break;
861 
862  // == means ==
863  case MEAN:
864  ret.first = _mean.first;
865  if (_flags & ERRORS) {
866  ret.second = ::sqrt(_mean.second);
867  }
868  break;
869  case MEANCLIP:
870  ret.first = _meanclip.first;
871  if ( _flags & ERRORS ) {
872  ret.second = ::sqrt(_meanclip.second);
873  }
874  break;
875 
876  // == stdevs & variances ==
877  case VARIANCE:
878  ret.first = _variance.first;
879  if (_flags & ERRORS) {
880  ret.second = ::sqrt(_variance.second);
881  }
882  break;
883  case STDEV:
884  ret.first = sqrt(_variance.first);
885  if (_flags & ERRORS) {
886  ret.second = 0.5*::sqrt(_variance.second)/ret.first;
887  }
888  break;
889  case VARIANCECLIP:
890  ret.first = _varianceclip.first;
891  if (_flags & ERRORS) {
892  ret.second = ret.second;
893  }
894  break;
895  case STDEVCLIP:
896  ret.first = sqrt(_varianceclip.first);
897  if (_flags & ERRORS) {
898  ret.second = 0.5*::sqrt(_varianceclip.second)/ret.first;
899  }
900  break;
901 
902  case MEANSQUARE:
903  ret.first = (_n - 1)/static_cast<double>(_n)*_variance.first + ::pow(_mean.first, 2);
904  if (_flags & ERRORS) {
905  ret.second = ::sqrt(2*::pow(ret.first/_n, 2)); // assumes Gaussian
906  }
907  break;
908 
909  // == other stats ==
910  case MIN:
911  ret.first = _min;
912  if ( _flags & ERRORS ) {
913  ret.second = 0;
914  }
915  break;
916  case MAX:
917  ret.first = _max;
918  if ( _flags & ERRORS ) {
919  ret.second = 0;
920  }
921  break;
922  case MEDIAN:
923  ret.first = _median.first;
924  if ( _flags & ERRORS ) {
925  ret.second = sqrt(afwGeom::HALFPI*_variance.first/_n); // assumes Gaussian
926  }
927  break;
928  case IQRANGE:
929  ret.first = _iqrange;
930  if ( _flags & ERRORS ) {
931  ret.second = NaN; // we're not estimating this properly
932  }
933  break;
934 
935  // no-op to satisfy the compiler
936  case ERRORS:
937  break;
938  // default: redundant as 'ret' is initialized to NaN, NaN
939  default: // we must have set prop to _flags
940  assert (iProp == 0);
941  throw LSST_EXCEPT(lsst::pex::exceptions::InvalidParameterError,
942  "getValue() may only be called without a parameter"
943  " if you asked for only one statistic");
944  }
945  return ret;
946 }
estimate sample mean
Definition: Statistics.h:67
std::pair< double, double > Value
The type used to report (value, error) for desired statistics.
Definition: Statistics.h:199
estimate sample N-sigma clipped mean (N set in StatisticsControl, default=3)
Definition: Statistics.h:72
estimate sample standard deviation
Definition: Statistics.h:68
estimate sample variance
Definition: Statistics.h:69
find sum of pixels in the image
Definition: Statistics.h:78
estimate sample N-sigma clipped stdev (N set in StatisticsControl, default=3)
Definition: Statistics.h:73
find mean value of square of pixel values
Definition: Statistics.h:79
Include errors of requested quantities.
Definition: Statistics.h:65
We don&#39;t want anything.
Definition: Statistics.h:64
estimate sample maximum
Definition: Statistics.h:77
number of sample points
Definition: Statistics.h:66
estimate sample minimum
Definition: Statistics.h:76
estimate sample median
Definition: Statistics.h:70
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
double const HALFPI
Definition: Angle.h:20
estimate sample inter-quartile range
Definition: Statistics.h:71
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 950 of file Statistics.cc.

954  {
955  return getResult(prop).first;
956 }
Value getResult(Property const prop=NOTHING) const
Return the value and error in the specified statistic (e.g. MEAN)
Definition: Statistics.cc:828

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 288 of file Statistics.h.

292  {
293  MaskImposter<WeightPixel> var;
294  return Statistics(img, msk, var, flags, sctrl);
295 }
Statistics(ImageT const &img, MaskT const &msk, VarianceT const &var, int const flags, StatisticsControl const &sctrl=StatisticsControl())
Constructor for Statistics object.
Definition: Statistics.cc:689
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 303 of file Statistics.h.

308  {
309  return Statistics(img, msk, var, flags, sctrl);
310 }
Statistics(ImageT const &img, MaskT const &msk, VarianceT const &var, int const flags, StatisticsControl const &sctrl=StatisticsControl())
Constructor for Statistics object.
Definition: Statistics.cc:689
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 317 of file Statistics.h.

322 {
323  if (sctrl.getWeighted() || sctrl.getCalcErrorFromInputVariance()) {
324  return Statistics(*mimg.getImage(), *mimg.getMask(), *mimg.getVariance(), flags, sctrl);
325  } else {
326  MaskImposter<WeightPixel> var;
327  return Statistics(*mimg.getImage(), *mimg.getMask(), var, flags, sctrl);
328  }
329 }
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:689
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 336 of file Statistics.h.

342 {
343  if (sctrl.getWeighted() || sctrl.getCalcErrorFromInputVariance() ||
344  (!sctrl.getWeightedIsSet() && (weights.getWidth() != 0 && weights.getHeight() != 0))) {
345  return Statistics(*mimg.getImage(), *mimg.getMask(), *mimg.getVariance(), weights, flags, sctrl);
346  } else {
347  MaskImposter<WeightPixel> var;
348  return Statistics(*mimg.getImage(), *mimg.getMask(), var, weights, flags, sctrl);
349  }
350 }
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:689
VariancePtr getVariance(bool const noThrow=false) const
Return a (Ptr to) the MaskedImage&#39;s variance.
Definition: MaskedImage.h:890
int getWidth() const
Return the number of columns in the image.
Definition: Image.h:237
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
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 1023 of file Statistics.cc.

1027  {
1028  return Statistics(msk, msk, msk, flags, sctrl);
1029 }
Statistics(ImageT const &img, MaskT const &msk, VarianceT const &var, int const flags, StatisticsControl const &sctrl=StatisticsControl())
Constructor for Statistics object.
Definition: Statistics.cc:689
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 368 of file Statistics.h.

372  {
373  // make a phony mask that will be compiled out
374  MaskImposter<lsst::afw::image::MaskPixel> const msk;
375  MaskImposter<WeightPixel> const var;
376  return Statistics(img, msk, var, flags, sctrl);
377 }
Statistics(ImageT const &img, MaskT const &msk, VarianceT const &var, int const flags, StatisticsControl const &sctrl=StatisticsControl())
Constructor for Statistics object.
Definition: Statistics.cc:689
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 415 of file Statistics.h.

418  {
419  ImageImposter<EntryT> img(v); // wrap the vector in a fake image
420  MaskImposter<lsst::afw::image::MaskPixel> msk; // instantiate a fake mask that will be compiled out.
421  MaskImposter<WeightPixel> var;
422  return Statistics(img, msk, var, flags, sctrl);
423 }
Statistics(ImageT const &img, MaskT const &msk, VarianceT const &var, int const flags, StatisticsControl const &sctrl=StatisticsControl())
Constructor for Statistics object.
Definition: Statistics.cc:689
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 430 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 
439  ImageImposter<WeightPixel> weights(vweights);
440 
441  return Statistics(img, msk, var, weights, flags, sctrl);
442 }
Statistics(ImageT const &img, MaskT const &msk, VarianceT const &var, int const flags, StatisticsControl const &sctrl=StatisticsControl())
Constructor for Statistics object.
Definition: Statistics.cc:689
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 449 of file Statistics.h.

452  {
453  if (sctrl.getWeighted() || sctrl.getCalcErrorFromInputVariance()) {
454  return Statistics(*mv.getImage(), *mv.getMask(), *mv.getVariance(), flags, sctrl);
455  } else {
456  MaskImposter<WeightPixel> var;
457  return Statistics(*mv.getImage(), *mv.getMask(), var, flags, sctrl);
458  }
459 }
lsst::afw::image::MaskedImage< EntryT >::VariancePtr getVariance() const
Definition: MaskedVector.h:89
lsst::afw::image::MaskedImage< EntryT >::MaskPtr getMask() const
Definition: MaskedVector.h:86
Statistics(ImageT const &img, MaskT const &msk, VarianceT const &var, int const flags, StatisticsControl const &sctrl=StatisticsControl())
Constructor for Statistics object.
Definition: Statistics.cc:689
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 466 of file Statistics.h.

470  {
471  ImageImposter<WeightPixel> weights(vweights);
472 
473  if (sctrl.getWeighted() || sctrl.getCalcErrorFromInputVariance()) {
474  return Statistics(*mv.getImage(), *mv.getMask(), *mv.getVariance(), weights, flags, sctrl);
475  } else {
476  MaskImposter<WeightPixel> var;
477  return Statistics(*mv.getImage(), *mv.getMask(), var, weights, flags, sctrl);
478  }
479 }
lsst::afw::image::MaskedImage< EntryT >::VariancePtr getVariance() const
Definition: MaskedVector.h:89
lsst::afw::image::MaskedImage< EntryT >::MaskPtr getMask() const
Definition: MaskedVector.h:86
Statistics(ImageT const &img, MaskT const &msk, VarianceT const &var, int const flags, StatisticsControl const &sctrl=StatisticsControl())
Constructor for Statistics object.
Definition: Statistics.cc:689
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 237 of file Statistics.h.

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

Definition at line 225 of file Statistics.h.

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

Definition at line 236 of file Statistics.h.

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

Definition at line 231 of file Statistics.h.

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

Definition at line 228 of file Statistics.h.

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

Definition at line 233 of file Statistics.h.

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

Definition at line 235 of file Statistics.h.

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

Definition at line 230 of file Statistics.h.

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

Definition at line 227 of file Statistics.h.

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

Definition at line 239 of file Statistics.h.

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

Definition at line 232 of file Statistics.h.

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

Definition at line 229 of file Statistics.h.

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

Definition at line 234 of file Statistics.h.

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

Definition at line 240 of file Statistics.h.


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