LSST Applications  21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
LSST Data Management Base Package
Public Types | Public Member Functions | Related Functions | List of all members
lsst::afw::math::Statistics Class Referencefinal

A class to evaluate image statistics. More...

#include <Statistics.h>

Public Types

using Value = std::pair< double, double >
 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())
 
 Statistics (Statistics const &)=default
 
 Statistics (Statistics &&)=default
 
Statisticsoperator= (Statistics const &)=default
 
Statisticsoperator= (Statistics &&)=default
 
 ~Statistics () noexcept=default
 
Value getResult (Property const prop=NOTHING) const
 Return the value and error in the specified statistic (e.g. 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 noexcept
 
template<>
 Statistics (image::Mask< image::MaskPixel > const &msk, image::Mask< image::MaskPixel > const &msk2, image::Mask< image::MaskPixel > const &var, int const flags, StatisticsControl const &sctrl)
 

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())
 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
 lsst::afw::math::StatisticsControl sctrl(3.0, 3);

 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)

 lsst::afw::math::Statistics statobj =
     lsst::afw::math::makeStatistics(*img, afwMath::NPOINT |
                                           afwMath::MEAN | afwMath::MEANCLIP, sctrl);
 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.

Definition at line 220 of file Statistics.h.

Member Typedef Documentation

◆ Value

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

Definition at line 223 of file Statistics.h.

Constructor & Destructor Documentation

◆ Statistics() [1/5]

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

Constructor for Statistics object.

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
Note
Most of the actual work is done in this constructor; the results are retrieved using getValue etc.

Definition at line 764 of file Statistics.cc.

766  : _flags(flags),
767  _mean(NaN, NaN),
768  _variance(NaN, NaN),
769  _min(NaN),
770  _max(NaN),
771  _sum(NaN),
772  _meanclip(NaN, NaN),
773  _varianceclip(NaN, NaN),
774  _median(NaN, NaN),
775  _nClipped(0),
776  _nMasked(0),
777  _iqrange(NaN),
778  _sctrl(sctrl),
779  _weightsAreMultiplicative(false) {
780  doStatistics(img, msk, var, var, _flags, _sctrl);
781 }

◆ Statistics() [2/5]

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

815  : _flags(flags),
816  _mean(NaN, NaN),
817  _variance(NaN, NaN),
818  _min(NaN),
819  _max(NaN),
820  _sum(NaN),
821  _meanclip(NaN, NaN),
822  _varianceclip(NaN, NaN),
823  _median(NaN, NaN),
824  _nClipped(0),
825  _nMasked(0),
826  _iqrange(NaN),
827  _sctrl(sctrl),
828  _weightsAreMultiplicative(true) {
829  if (!isEmpty(weights)) {
830  if (_sctrl.getWeightedIsSet() && !_sctrl.getWeighted()) {
831  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError,
832  "You must use the weights if you provide them");
833  }
834 
835  _sctrl.setWeighted(true);
836  }
837  doStatistics(img, msk, var, weights, _flags, _sctrl);
838 }
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
bool getWeightedIsSet() const noexcept
Definition: Statistics.h:138
void setWeighted(bool useWeights) noexcept
Definition: Statistics.h:158
bool getWeighted() const noexcept
Definition: Statistics.h:137

◆ Statistics() [3/5]

lsst::afw::math::Statistics::Statistics ( Statistics const &  )
default

◆ Statistics() [4/5]

lsst::afw::math::Statistics::Statistics ( Statistics &&  )
default

◆ ~Statistics()

lsst::afw::math::Statistics::~Statistics ( )
defaultnoexcept

◆ Statistics() [5/5]

template<>
lsst::afw::math::Statistics::Statistics ( image::Mask< image::MaskPixel > const &  msk,
image::Mask< image::MaskPixel > const &  msk2,
image::Mask< image::MaskPixel > const &  var,
int const  flags,
StatisticsControl const &  sctrl 
)

Definition at line 1061 of file Statistics.cc.

1064  : _flags(flags),
1065  _mean(NaN, NaN),
1066  _variance(NaN, NaN),
1067  _min(NaN),
1068  _max(NaN),
1069  _meanclip(NaN, NaN),
1070  _varianceclip(NaN, NaN),
1071  _median(NaN, NaN),
1072  _nClipped(0),
1073  _iqrange(NaN),
1074  _sctrl(sctrl) {
1075  if ((flags & ~(NPOINT | SUM)) != 0x0) {
1077  "Statistics<Mask> only supports NPOINT and SUM");
1078  }
1079 
1080  using Mask = image::Mask<>;
1081 
1082  _n = msk.getWidth() * msk.getHeight();
1083  if (_n == 0) {
1084  throw LSST_EXCEPT(pexExceptions::InvalidParameterError, "Image contains no pixels");
1085  }
1086 
1087  // Check that an int's large enough to hold the number of pixels
1088  assert(msk.getWidth() * static_cast<double>(msk.getHeight()) < std::numeric_limits<int>::max());
1089 
1090  image::MaskPixel sum = 0x0;
1091  for (int y = 0; y != msk.getHeight(); ++y) {
1092  for (Mask::x_iterator ptr = msk.row_begin(y), end = msk.row_end(y); ptr != end; ++ptr) {
1093  sum |= (*ptr)[0];
1094  }
1095  }
1096  _sum = sum;
1097 }
int end
uint64_t * ptr
Definition: RangeSet.cc:88
int y
Definition: SpanSet.cc:48
int getWidth() const
Return the number of columns in the image.
Definition: ImageBase.h:294
int getHeight() const
Return the number of rows in the image.
Definition: ImageBase.h:296
x_iterator row_begin(int y) const
Return an x_iterator to the start of the y'th row.
Definition: ImageBase.h:401
x_iterator row_end(int y) const
Return an x_iterator to the end of the y'th row.
Definition: ImageBase.h:404
Represent a 2-dimensional array of bitmask pixels.
Definition: Mask.h:77
Reports invalid arguments.
Definition: Runtime.h:66
@ SUM
find sum of pixels in the image
Definition: Statistics.h:77
@ NPOINT
number of sample points
Definition: Statistics.h:65

Member Function Documentation

◆ getError()

double lsst::afw::math::Statistics::getError ( 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

Definition at line 1049 of file Statistics.cc.

1049 { return getResult(prop).second; }
Value getResult(Property const prop=NOTHING) const
Return the value and error in the specified statistic (e.g.
Definition: Statistics.cc:922

◆ getOrMask()

lsst::afw::image::MaskPixel lsst::afw::math::Statistics::getOrMask ( ) const
inlinenoexcept

Definition at line 288 of file Statistics.h.

288 { return _allPixelOrMask; }

◆ getResult()

std::pair< double, double > lsst::afw::math::Statistics::getResult ( Property const  prop = NOTHING) const

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

MEAN)

Parameters
propthe 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
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

Definition at line 922 of file Statistics.cc.

922  {
923  // if iProp == NOTHING try to return their heart's delight, as specified in the constructor
924  Property const prop = static_cast<Property>(((iProp == NOTHING) ? _flags : iProp) & ~ERRORS);
925 
926  if (!(prop & _flags)) { // we didn't calculate it
928  (boost::format("You didn't ask me to calculate %d") % prop).str());
929  }
930 
931  Value ret(NaN, NaN);
932  switch (prop) {
933  case NPOINT:
934  ret.first = static_cast<double>(_n);
935  if (_flags & ERRORS) {
936  ret.second = 0;
937  }
938  break;
939 
940  case NCLIPPED:
941  ret.first = static_cast<double>(_nClipped);
942  if (_flags & ERRORS) {
943  ret.second = 0;
944  }
945  break;
946 
947  case NMASKED:
948  ret.first = static_cast<double>(_nMasked);
949  if (_flags & ERRORS) {
950  ret.second = 0;
951  }
952  break;
953 
954  case SUM:
955  ret.first = static_cast<double>(_sum);
956  if (_flags & ERRORS) {
957  ret.second = 0;
958  }
959  break;
960 
961  // == means ==
962  case MEAN:
963  ret.first = _mean.first;
964  if (_flags & ERRORS) {
965  ret.second = ::sqrt(_mean.second);
966  }
967  break;
968  case MEANCLIP:
969  ret.first = _meanclip.first;
970  if (_flags & ERRORS) {
971  ret.second = ::sqrt(_meanclip.second);
972  }
973  break;
974 
975  // == stdevs & variances ==
976  case VARIANCE:
977  ret.first = _variance.first;
978  if (_flags & ERRORS) {
979  ret.second = ::sqrt(_variance.second);
980  }
981  break;
982  case STDEV:
983  ret.first = sqrt(_variance.first);
984  if (_flags & ERRORS) {
985  ret.second = 0.5 * ::sqrt(_variance.second) / ret.first;
986  }
987  break;
988  case VARIANCECLIP:
989  ret.first = _varianceclip.first;
990  if (_flags & ERRORS) {
991  ret.second = ret.second;
992  }
993  break;
994  case STDEVCLIP:
995  ret.first = sqrt(_varianceclip.first);
996  if (_flags & ERRORS) {
997  ret.second = 0.5 * ::sqrt(_varianceclip.second) / ret.first;
998  }
999  break;
1000 
1001  case MEANSQUARE:
1002  ret.first = (_n - 1) / static_cast<double>(_n) * _variance.first + ::pow(_mean.first, 2);
1003  if (_flags & ERRORS) {
1004  ret.second = ::sqrt(2 * ::pow(ret.first / _n, 2)); // assumes Gaussian
1005  }
1006  break;
1007 
1008  // == other stats ==
1009  case MIN:
1010  ret.first = _min;
1011  if (_flags & ERRORS) {
1012  ret.second = 0;
1013  }
1014  break;
1015  case MAX:
1016  ret.first = _max;
1017  if (_flags & ERRORS) {
1018  ret.second = 0;
1019  }
1020  break;
1021  case MEDIAN:
1022  ret.first = _median.first;
1023  if (_flags & ERRORS) {
1024  ret.second = sqrt(geom::HALFPI * _variance.first / _n); // assumes Gaussian
1025  }
1026  break;
1027  case IQRANGE:
1028  ret.first = _iqrange;
1029  if (_flags & ERRORS) {
1030  ret.second = NaN; // we're not estimating this properly
1031  }
1032  break;
1033 
1034  // no-op to satisfy the compiler
1035  case ERRORS:
1036  break;
1037  // default: redundant as 'ret' is initialized to NaN, NaN
1038  default: // we must have set prop to _flags
1039  assert(iProp == 0);
1040  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError,
1041  "getValue() may only be called without a parameter"
1042  " if you asked for only one statistic");
1043  }
1044  return ret;
1045 }
std::pair< double, double > Value
The type used to report (value, error) for desired statistics.
Definition: Statistics.h:223
Property
control what is calculated
Definition: Statistics.h:62
@ ERRORS
Include errors of requested quantities.
Definition: Statistics.h:64
@ VARIANCECLIP
estimate sample N-sigma clipped variance (N set in StatisticsControl, default=3)
Definition: Statistics.h:73
@ MEANSQUARE
find mean value of square of pixel values
Definition: Statistics.h:78
@ MIN
estimate sample minimum
Definition: Statistics.h:75
@ NCLIPPED
number of clipped points
Definition: Statistics.h:80
@ NOTHING
We don't want anything.
Definition: Statistics.h:63
@ STDEV
estimate sample standard deviation
Definition: Statistics.h:67
@ NMASKED
number of masked points
Definition: Statistics.h:81
@ STDEVCLIP
estimate sample N-sigma clipped stdev (N set in StatisticsControl, default=3)
Definition: Statistics.h:72
@ VARIANCE
estimate sample variance
Definition: Statistics.h:68
@ MEDIAN
estimate sample median
Definition: Statistics.h:69
@ MAX
estimate sample maximum
Definition: Statistics.h:76
@ IQRANGE
estimate sample inter-quartile range
Definition: Statistics.h:70
@ MEAN
estimate sample mean
Definition: Statistics.h:66
@ MEANCLIP
estimate sample N-sigma clipped mean (N set in StatisticsControl, default=3)
Definition: Statistics.h:71
constexpr double HALFPI
Definition: Angle.h:41
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:174
T pow(T... args)
T sqrt(T... args)

◆ getValue()

double lsst::afw::math::Statistics::getValue ( 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

Definition at line 1047 of file Statistics.cc.

1047 { return getResult(prop).first; }

◆ operator=() [1/2]

Statistics& lsst::afw::math::Statistics::operator= ( Statistics &&  )
default

◆ operator=() [2/2]

Statistics& lsst::afw::math::Statistics::operator= ( Statistics const &  )
default

Friends And Related Function Documentation

◆ makeStatistics() [1/10]

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

372  {
373  return Statistics(img, msk, var, flags, sctrl);
374 }
Statistics(ImageT const &img, MaskT const &msk, VarianceT const &var, int const flags, StatisticsControl const &sctrl=StatisticsControl())
Constructor for Statistics object.
Definition: Statistics.cc:764

◆ makeStatistics() [2/10]

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

429  {
430  // make a phony mask that will be compiled out
431  MaskImposter<lsst::afw::image::MaskPixel> const msk;
432  MaskImposter<WeightPixel> const var;
433  return Statistics(img, msk, var, flags, sctrl);
434 }

◆ makeStatistics() [3/10]

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

361  {
362  MaskImposter<WeightPixel> var;
363  return Statistics(img, msk, var, flags, sctrl);
364 }

◆ makeStatistics() [4/10]

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

Specialization to handle Masks.

Parameters
mskImage (or MaskedImage) whose properties we want
flagsDescribe what we want to calculate
sctrlControl how things are calculated

Definition at line 1104 of file Statistics.cc.

1105  {
1106  return Statistics(msk, msk, msk, flags, sctrl);
1107 }

◆ makeStatistics() [5/10]

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

382  {
383  if (sctrl.getWeighted() || sctrl.getCalcErrorFromInputVariance()) {
384  return Statistics(*mimg.getImage(), *mimg.getMask(), *mimg.getVariance(), flags, sctrl);
385  } else {
386  MaskImposter<WeightPixel> var;
387  return Statistics(*mimg.getImage(), *mimg.getMask(), var, flags, sctrl);
388  }
389 }
VariancePtr getVariance() const
Return a (shared_ptr to) the MaskedImage's variance.
Definition: MaskedImage.h:1051
MaskPtr getMask() const
Return a (shared_ptr to) the MaskedImage's mask.
Definition: MaskedImage.h:1030
ImagePtr getImage() const
Return a (shared_ptr to) the MaskedImage's image.
Definition: MaskedImage.h:1018

◆ makeStatistics() [6/10]

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

398  {
399  if (sctrl.getWeighted() || sctrl.getCalcErrorFromInputVariance() ||
400  (!sctrl.getWeightedIsSet() && (weights.getWidth() != 0 && weights.getHeight() != 0))) {
401  return Statistics(*mimg.getImage(), *mimg.getMask(), *mimg.getVariance(), weights, flags, sctrl);
402  } else {
403  MaskImposter<WeightPixel> var;
404  return Statistics(*mimg.getImage(), *mimg.getMask(), var, weights, flags, sctrl);
405  }
406 }

◆ makeStatistics() [7/10]

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

511  {
512  if (sctrl.getWeighted() || sctrl.getCalcErrorFromInputVariance()) {
513  return Statistics(*mv.getImage(), *mv.getMask(), *mv.getVariance(), flags, sctrl);
514  } else {
515  MaskImposter<WeightPixel> var;
516  return Statistics(*mv.getImage(), *mv.getMask(), var, flags, sctrl);
517  }
518 }
lsst::afw::image::MaskedImage< EntryT >::VariancePtr getVariance() const
Definition: MaskedVector.h:94
lsst::afw::image::MaskedImage< EntryT >::ImagePtr getImage() const
Definition: MaskedVector.h:88
lsst::afw::image::MaskedImage< EntryT >::MaskPtr getMask() const
Definition: MaskedVector.h:91

◆ makeStatistics() [8/10]

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

529  {
530  ImageImposter<WeightPixel> weights(vweights);
531 
532  if (sctrl.getWeighted() || sctrl.getCalcErrorFromInputVariance()) {
533  return Statistics(*mv.getImage(), *mv.getMask(), *mv.getVariance(), weights, flags, sctrl);
534  } else {
535  MaskImposter<WeightPixel> var;
536  return Statistics(*mv.getImage(), *mv.getMask(), var, weights, flags, sctrl);
537  }
538 }

◆ makeStatistics() [9/10]

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

477  {
478  ImageImposter<EntryT> img(v); // wrap the vector in a fake image
479  MaskImposter<lsst::afw::image::MaskPixel> msk; // instantiate a fake mask that will be compiled out.
480  MaskImposter<WeightPixel> var;
481  return Statistics(img, msk, var, flags, sctrl);
482 }

◆ makeStatistics() [10/10]

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

493  {
494  ImageImposter<EntryT> img(v); // wrap the vector in a fake image
495  MaskImposter<lsst::afw::image::MaskPixel> msk; // instantiate a fake mask that will be compiled out.
496  MaskImposter<WeightPixel> var;
497 
498  ImageImposter<WeightPixel> weights(vweights);
499 
500  return Statistics(img, msk, var, weights, flags, sctrl);
501 }

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