37 #include "boost/shared_ptr.hpp"
46 namespace afwMath = lsst::afw::math;
47 namespace afwGeom = lsst::afw::geom;
48 namespace pexExceptions = lsst::pex::exceptions;
51 double const NaN = std::numeric_limits<double>::quiet_NaN();
53 double const IQ_TO_STDEV = 0.741301109252802;
61 bool operator()(T)
const {
64 template<
typename Ta,
typename Tb>
65 bool operator()(Ta, Tb)
const {
68 template<
typename Ta,
typename Tb,
typename Tc>
69 bool operator()(Ta, Tb, Tc)
const {
80 bool operator()(T)
const {
83 template<
typename Ta,
typename Tb>
84 bool operator()(Ta, Tb)
const {
87 template<
typename Ta,
typename Tb,
typename Tc>
88 bool operator()(Ta, Tb, Tc)
const {
99 bool operator()(T
val)
const {
107 class CheckValueLtMin {
109 template<
typename Tval,
typename Tmin>
110 bool operator()(Tval
val, Tmin
min)
const {
111 return (static_cast<Tmin>(val) < min);
118 class CheckValueGtMax {
120 template<
typename Tval,
typename Tmax>
121 bool operator()(Tval val, Tmax
max)
const {
122 return (static_cast<Tmax>(val) > max);
129 class CheckClipRange {
131 template<
typename Tval,
typename Tcen,
typename Tmax>
132 bool operator()(Tval val, Tcen center, Tmax cliplimit)
const {
133 Tmax tmp = fabs(val - center);
134 return (tmp <= cliplimit);
139 typedef CheckFinite ChkFin;
140 typedef CheckValueLtMin ChkMin;
141 typedef CheckValueGtMax ChkMax;
142 typedef CheckClipRange ChkClip;
143 typedef AlwaysTrue AlwaysT;
144 typedef AlwaysFalse AlwaysF;
148 inline double varianceError(
double const variance,
int const n)
150 return 2*(n - 1)*variance*variance/static_cast<double>(n*n);
155 typedef boost::tuple<int,
177 template<
typename IsFinite,
178 typename HasValueLtMin,
179 typename HasValueGtMax,
180 typename InClipRange,
182 typename ImageT,
typename MaskT,
typename VarianceT,
typename WeightT>
183 StandardReturn processPixels(ImageT
const &img,
185 VarianceT
const &var,
186 WeightT
const &weights,
190 double const meanCrude,
191 double const cliplimit,
192 bool const weightsAreMultiplicative,
194 bool const calcErrorFromInputVariance
205 double min = (nCrude) ? meanCrude : MAX_DOUBLE;
206 double max = (nCrude) ? meanCrude : -MAX_DOUBLE;
210 for (
int iY = 0; iY < img.getHeight(); iY += stride) {
212 typename MaskT::x_iterator mptr = msk.row_begin(iY);
213 typename VarianceT::x_iterator vptr = var.row_begin(iY);
214 typename WeightT::x_iterator wptr = weights.row_begin(iY);
216 for (
typename ImageT::x_iterator ptr = img.row_begin(iY), end = ptr + img.getWidth();
217 ptr != end; ++ptr, ++mptr, ++vptr, ++wptr) {
219 if (IsFinite()(*ptr) && !(*mptr & andMask) &&
220 InClipRange()(*ptr, meanCrude, cliplimit) ) {
222 double const delta = (*ptr - meanCrude);
225 double weight = *wptr;
226 if (weightsAreMultiplicative) {
236 sumw2 += weight*weight;
237 sumx += weight*delta;
238 sumx2 += weight*delta*delta;
240 if (calcErrorFromInputVariance) {
241 double const var = *vptr;
242 sumvw2 += var*weight*weight;
246 sumx2 += delta*delta;
248 if (calcErrorFromInputVariance) {
249 double const var = *vptr;
254 allPixelOrMask |= *mptr;
256 if (HasValueLtMin()(*ptr,
min)) { min = *ptr; }
257 if (HasValueGtMax()(*ptr,
max)) { max = *ptr; }
268 double mean, variance;
277 variance = sumx2/sumw - ::pow(mean, 2);
278 variance *= sumw*sumw/(sumw*sumw - sumw2);
281 if (calcErrorFromInputVariance) {
282 meanVar = sumvw2/(sumw*sumw);
284 meanVar = variance*sumw2/(sumw*sumw);
287 double varVar = varianceError(variance, n);
289 sumx += sumw*meanCrude;
292 return StandardReturn(n, sumx,
297 template<
typename IsFinite,
298 typename HasValueLtMin,
299 typename HasValueGtMax,
300 typename InClipRange,
302 typename ImageT,
typename MaskT,
typename VarianceT,
typename WeightT>
303 StandardReturn processPixels(ImageT
const &img,
305 VarianceT
const &var,
306 WeightT
const &weights,
310 double const meanCrude,
311 double const cliplimit,
312 bool const weightsAreMultiplicative,
314 bool const calcErrorFromInputVariance,
319 return processPixels<IsFinite, HasValueLtMin, HasValueGtMax, InClipRange, true>(
320 img, msk, var, weights,
321 flags, nCrude, 1, meanCrude, cliplimit, weightsAreMultiplicative, andMask,
322 calcErrorFromInputVariance);
324 return processPixels<IsFinite, HasValueLtMin, HasValueGtMax, InClipRange, false>(
325 img, msk, var, weights,
326 flags, nCrude, 1, meanCrude, cliplimit, weightsAreMultiplicative, andMask,
327 calcErrorFromInputVariance);
331 template<
typename IsFinite,
332 typename HasValueLtMin,
333 typename HasValueGtMax,
334 typename InClipRange,
336 typename ImageT,
typename MaskT,
typename VarianceT,
typename WeightT>
337 StandardReturn processPixels(ImageT
const &img,
339 VarianceT
const &var,
340 WeightT
const &weights,
344 double const meanCrude,
345 double const cliplimit,
346 bool const weightsAreMultiplicative,
348 bool const calcErrorFromInputVariance,
354 return processPixels<CheckFinite, HasValueLtMin, HasValueGtMax, InClipRange, useWeights>(
355 img, msk, var, weights,
356 flags, nCrude, 1, meanCrude, cliplimit,
357 weightsAreMultiplicative, andMask, calcErrorFromInputVariance,
360 return processPixels<AlwaysTrue, HasValueLtMin, HasValueGtMax, InClipRange, useWeights>(
361 img, msk, var, weights,
362 flags, nCrude, 1, meanCrude, cliplimit,
363 weightsAreMultiplicative, andMask, calcErrorFromInputVariance,
376 template<
typename ImageT,
typename MaskT,
typename VarianceT,
typename WeightT>
377 StandardReturn getStandard(ImageT
const &img,
379 VarianceT
const &var,
380 WeightT
const &weights,
382 bool const weightsAreMultiplicative,
384 bool const calcErrorFromInputVariance,
392 double meanCrude = 0.0;
395 int const nPix = img.getWidth()*img.getHeight();
403 double cliplimit = -1;
404 StandardReturn values = processPixels<ChkFin, AlwaysF, AlwaysF, AlwaysT, true>(
405 img, msk, var, weights,
406 flags, nCrude, strideCrude, meanCrude,
408 weightsAreMultiplicative, andMask, calcErrorFromInputVariance,
409 doCheckFinite, doGetWeighted);
410 nCrude = values.get<0>();
411 double sumCrude = values.get<1>();
415 meanCrude = sumCrude/nCrude;
423 return processPixels<ChkFin, ChkMin, ChkMax, AlwaysT, true>(
424 img, msk, var, weights,
425 flags, nCrude, 1, meanCrude,
427 weightsAreMultiplicative, andMask, calcErrorFromInputVariance,
428 true, doGetWeighted);
430 return processPixels<ChkFin, AlwaysF, AlwaysF, AlwaysT,true>(
431 img, msk, var, weights,
432 flags, nCrude, 1, meanCrude,
434 weightsAreMultiplicative, andMask, calcErrorFromInputVariance,
435 doCheckFinite, doGetWeighted);
444 template<
typename ImageT,
typename MaskT,
typename VarianceT,
typename WeightT>
445 StandardReturn getStandard(ImageT
const &img,
447 VarianceT
const &var,
448 WeightT
const &weights,
450 std::pair<double, double>
const clipinfo,
452 bool const weightsAreMultiplicative,
454 bool const calcErrorFromInputVariance,
459 double const center = clipinfo.first;
460 double const cliplimit = clipinfo.second;
463 return StandardReturn(0, NaN,
470 int const stride = 1;
474 return processPixels<ChkFin, ChkMin, ChkMax, ChkClip, true>(
475 img, msk, var, weights,
476 flags, nCrude, stride,
478 weightsAreMultiplicative, andMask, calcErrorFromInputVariance,
479 true, doGetWeighted);
481 return processPixels<ChkFin, AlwaysF, AlwaysF, ChkClip, true>(
482 img, msk, var, weights,
483 flags, nCrude, stride,
485 weightsAreMultiplicative, andMask, calcErrorFromInputVariance,
486 doCheckFinite, doGetWeighted);
498 template<
typename Pixel>
499 double percentile(std::vector<Pixel> &img,
500 double const fraction)
502 assert (fraction >= 0.0 && fraction <= 1.0);
504 int const n = img.size();
508 double const idx = fraction*(n - 1);
516 int const q1 =
static_cast<int>(idx);
517 int const q2 = q1 + 1;
519 typename std::vector<Pixel>::iterator mid1 = img.begin() + q1;
520 typename std::vector<Pixel>::iterator mid2 = img.begin() + q2;
521 if (fraction > 0.5) {
522 std::nth_element(img.begin(), mid1, img.end());
523 std::nth_element(mid1, mid2, img.end());
525 std::nth_element(img.begin(), mid2, img.end());
526 std::nth_element(img.begin(), mid1, mid2);
529 double val1 =
static_cast<double>(*mid1);
530 double val2 =
static_cast<double>(*mid2);
531 double w1 = (
static_cast<double>(q2) - idx);
532 double w2 = (idx -
static_cast<double>(q1));
533 return w1*val1 + w2*val2;
551 typedef boost::tuple<double, double, double> MedianQuartileReturn;
553 template<
typename Pixel>
554 MedianQuartileReturn medianAndQuartiles(std::vector<Pixel> &img)
556 int const n = img.size();
560 double const idx50 = 0.50*(n - 1);
561 double const idx25 = 0.25*(n - 1);
562 double const idx75 = 0.75*(n - 1);
569 int const q50a =
static_cast<int>(idx50);
570 int const q50b = q50a + 1;
571 int const q25a =
static_cast<int>(idx25);
572 int const q25b = q25a + 1;
573 int const q75a =
static_cast<int>(idx75);
574 int const q75b = q75a + 1;
576 typename std::vector<Pixel>::iterator mid50a = img.begin() + q50a;
577 typename std::vector<Pixel>::iterator mid50b = img.begin() + q50b;
578 typename std::vector<Pixel>::iterator mid25a = img.begin() + q25a;
579 typename std::vector<Pixel>::iterator mid25b = img.begin() + q25b;
580 typename std::vector<Pixel>::iterator mid75a = img.begin() + q75a;
581 typename std::vector<Pixel>::iterator mid75b = img.begin() + q75b;
584 std::nth_element(img.begin(), mid50a, img.end());
585 std::nth_element(mid50a, mid75a, img.end());
586 std::nth_element(img.begin(), mid25a, mid50a);
589 std::nth_element(mid50a, mid50b, mid75a);
590 std::nth_element(mid25a, mid25b, mid50a);
591 std::nth_element(mid75a, mid75b, img.end());
594 double val50a =
static_cast<double>(*mid50a);
595 double val50b =
static_cast<double>(*mid50b);
596 double w50a = (
static_cast<double>(q50b) - idx50);
597 double w50b = (idx50 -
static_cast<double>(q50a));
598 double median = w50a*val50a + w50b*val50b;
600 double val25a =
static_cast<double>(*mid25a);
601 double val25b =
static_cast<double>(*mid25b);
602 double w25a = (
static_cast<double>(q25b) - idx25);
603 double w25b = (idx25 -
static_cast<double>(q25a));
604 double q1 = w25a*val25a + w25b*val25b;
606 double val75a =
static_cast<double>(*mid75a);
607 double val75b =
static_cast<double>(*mid75b);
608 double w75a = (
static_cast<double>(q75b) - idx75);
609 double w75b = (idx75 -
static_cast<double>(q75a));
610 double q3 = w75a*val75a + w75b*val75b;
612 return MedianQuartileReturn(median, q1, q3);
614 return MedianQuartileReturn(img[0], img[0], img[0]);
616 return MedianQuartileReturn(NaN, NaN, NaN);
628 template<
typename IsFinite,
typename ImageT,
typename MaskT,
typename VarianceT>
629 boost::shared_ptr<std::vector<typename ImageT::Pixel> > makeVectorCopy(ImageT
const &img,
637 boost::shared_ptr<std::vector<typename ImageT::Pixel> >
638 imgcp(
new std::vector<typename ImageT::Pixel>(0));
640 for (
int i_y = 0; i_y < img.getHeight(); ++i_y) {
641 typename MaskT::x_iterator mptr = msk.row_begin(i_y);
642 for (
typename ImageT::x_iterator ptr = img.row_begin(i_y), end = img.row_end(i_y);
644 if (IsFinite()(*ptr) && !(*mptr & andMask)) {
645 imgcp->push_back(*ptr);
659 static std::map<std::string, Property> statisticsProperty;
660 if (statisticsProperty.size() == 0) {
661 statisticsProperty[
"NOTHING"] =
NOTHING;
662 statisticsProperty[
"ERRORS"] =
ERRORS;
663 statisticsProperty[
"NPOINT"] =
NPOINT;
664 statisticsProperty[
"MEAN"] =
MEAN;
665 statisticsProperty[
"STDEV"] =
STDEV;
666 statisticsProperty[
"VARIANCE"] =
VARIANCE;
667 statisticsProperty[
"MEDIAN"] =
MEDIAN;
668 statisticsProperty[
"IQRANGE"] =
IQRANGE;
669 statisticsProperty[
"MEANCLIP"] =
MEANCLIP;
670 statisticsProperty[
"STDEVCLIP"] =
STDEVCLIP;
672 statisticsProperty[
"MIN"] =
MIN;
673 statisticsProperty[
"MAX"] =
MAX;
674 statisticsProperty[
"SUM"] =
SUM;
675 statisticsProperty[
"MEANSQUARE"] =
MEANSQUARE;
676 statisticsProperty[
"ORMASK"] =
ORMASK;
678 return statisticsProperty[property];
688 template<
typename ImageT,
typename MaskT,
typename VarianceT>
692 VarianceT
const &var,
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)
705 bool isEmpty(T
const& t) {
return t.empty(); }
711 template<
typename ImageT,
typename MaskT,
typename VarianceT,
typename WeightT>
715 VarianceT
const &var,
716 WeightT
const &weights,
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)
724 if (!isEmpty(weights)) {
726 throw LSST_EXCEPT(lsst::pex::exceptions::InvalidParameterError,
727 "You must use the weights if you provide them");
735 template<
typename ImageT,
typename MaskT,
typename VarianceT,
typename WeightT>
739 VarianceT
const &var,
740 WeightT
const &weights,
745 _n = img.getWidth()*img.getHeight();
747 throw LSST_EXCEPT(pexExceptions::InvalidParameterError,
"Image contains no pixels");
754 StandardReturn standard = getStandard(img, msk, var, weights, flags,
755 _weightsAreMultiplicative,
757 _sctrl.getCalcErrorFromInputVariance(),
758 _sctrl.getNanSafe(), _sctrl.getWeighted());
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>();
775 boost::shared_ptr<std::vector<typename ImageT::Pixel> > imgcp;
776 if (_sctrl.getNanSafe()) {
777 imgcp = makeVectorCopy<ChkFin>(img, msk, var, _sctrl.getAndMask());
779 imgcp = makeVectorCopy<AlwaysT>(img, msk, var, _sctrl.getAndMask());
784 _median =
Value(percentile(*imgcp, 0.5), NaN);
786 MedianQuartileReturn mq = medianAndQuartiles(*imgcp);
787 _median =
Value(mq.get<0>(), NaN);
788 _iqrange = mq.get<2>() - mq.get<1>();
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);
800 StandardReturn clipped = getStandard(img, msk, var, weights, flags, clipinfo,
801 _weightsAreMultiplicative,
803 _sctrl.getCalcErrorFromInputVariance(),
804 _sctrl.getNanSafe(), _sctrl.getWeighted());
806 int const nClip = clipped.get<0>();
807 _meanclip = clipped.get<2>();
808 double const varClip = clipped.get<3>().first;
810 _varianceclip =
Value(varClip, varianceError(varClip, nClip));
839 if (!(prop & _flags)) {
840 throw LSST_EXCEPT(pexExceptions::InvalidParameterError,
841 (
boost::format(
"You didn't ask me to calculate %d") % prop).str());
849 ret.first =
static_cast<double>(
_n);
856 ret.first =
static_cast<double>(
_sum);
857 if (_flags & ERRORS) {
864 ret.first = _mean.first;
865 if (_flags & ERRORS) {
866 ret.second = ::sqrt(_mean.second);
870 ret.first = _meanclip.first;
871 if ( _flags & ERRORS ) {
872 ret.second = ::sqrt(_meanclip.second);
878 ret.first = _variance.first;
879 if (_flags & ERRORS) {
880 ret.second = ::sqrt(_variance.second);
884 ret.first = sqrt(_variance.first);
885 if (_flags & ERRORS) {
886 ret.second = 0.5*::sqrt(_variance.second)/ret.first;
890 ret.first = _varianceclip.first;
891 if (_flags & ERRORS) {
892 ret.second = ret.second;
896 ret.first = sqrt(_varianceclip.first);
897 if (_flags & ERRORS) {
898 ret.second = 0.5*::sqrt(_varianceclip.second)/ret.first;
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));
912 if ( _flags & ERRORS ) {
918 if ( _flags & ERRORS ) {
923 ret.first = _median.first;
924 if ( _flags & ERRORS ) {
929 ret.first = _iqrange;
930 if ( _flags & ERRORS ) {
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");
955 return getResult(prop).first;
967 return getResult(prop).second;
989 _mean(NaN, NaN), _variance(NaN, NaN), _min(NaN), _max(NaN),
990 _meanclip(NaN, NaN), _varianceclip(NaN, NaN), _median(NaN, NaN), _iqrange(NaN),
994 throw LSST_EXCEPT(pexExceptions::InvalidParameterError,
"Statistics<Mask> only supports NPOINT and SUM");
1001 throw LSST_EXCEPT(pexExceptions::InvalidParameterError,
"Image contains no pixels");
1009 for (Mask::x_iterator ptr = msk.
row_begin(
y), end = msk.
row_end(
y); ptr != end; ++ptr) {
1028 return Statistics(msk, msk, msk, flags, sctrl);
1042 #define STAT afwMath::Statistics
1046 #define INSTANTIATE_MASKEDIMAGE_STATISTICS(TYPE) \
1047 template STAT::Statistics(afwImage::Image<TYPE> const &img, \
1048 afwImage::Mask<afwImage::MaskPixel> const &msk, \
1049 afwImage::Image<VPixel> const &var, \
1050 int const flags, StatisticsControl const& sctrl); \
1051 template STAT::Statistics(afwImage::Image<TYPE> const &img, \
1052 afwImage::Mask<afwImage::MaskPixel> const &msk, \
1053 afwImage::Image<VPixel> const &var, \
1054 afwImage::Image<VPixel> const &weights, \
1055 int const flags, StatisticsControl const& sctrl); \
1056 template STAT::Statistics(afwImage::Image<TYPE> const &img, \
1057 afwImage::Mask<afwImage::MaskPixel> const &msk, \
1058 afwImage::Image<VPixel> const &var, \
1059 afwMath::ImageImposter<VPixel> const &weights, \
1060 int const flags, StatisticsControl const& sctrl)
1062 #define INSTANTIATE_MASKEDIMAGE_STATISTICS_NO_MASK(TYPE) \
1063 template STAT::Statistics(afwImage::Image<TYPE> const &img, \
1064 afwMath::MaskImposter<afwImage::MaskPixel> const &msk, \
1065 afwImage::Image<VPixel> const &var, \
1066 int const flags, StatisticsControl const& sctrl); \
1067 template STAT::Statistics(afwImage::Image<TYPE> const &img, \
1068 afwMath::MaskImposter<afwImage::MaskPixel> const &msk, \
1069 afwImage::Image<VPixel> const &var, \
1070 afwImage::Image<VPixel> const &weights, \
1071 int const flags, StatisticsControl const& sctrl)
1073 #define INSTANTIATE_MASKEDIMAGE_STATISTICS_NO_VAR(TYPE) \
1074 template STAT::Statistics(afwImage::Image<TYPE> const &img, \
1075 afwImage::Mask<afwImage::MaskPixel> const &msk, \
1076 afwMath::MaskImposter<VPixel> const &var, \
1077 int const flags, StatisticsControl const& sctrl); \
1078 template STAT::Statistics(afwImage::Image<TYPE> const &img, \
1079 afwImage::Mask<afwImage::MaskPixel> const &msk, \
1080 afwMath::MaskImposter<VPixel> const &var, \
1081 afwImage::Image<VPixel> const &weights, \
1082 int const flags, StatisticsControl const& sctrl); \
1083 template STAT::Statistics(afwImage::Image<TYPE> const &img, \
1084 afwImage::Mask<afwImage::MaskPixel> const &msk, \
1085 afwMath::MaskImposter<VPixel> const &var, \
1086 afwMath::ImageImposter<VPixel> const &weights, \
1087 int const flags, StatisticsControl const& sctrl)
1089 #define INSTANTIATE_REGULARIMAGE_STATISTICS(TYPE) \
1090 template STAT::Statistics(afwImage::Image<TYPE> const &img, \
1091 afwMath::MaskImposter<afwImage::MaskPixel> const &msk, \
1092 afwMath::MaskImposter<VPixel> const &var, \
1093 int const flags, StatisticsControl const& sctrl)
1095 #define INSTANTIATE_VECTOR_STATISTICS(TYPE) \
1096 template STAT::Statistics(afwMath::ImageImposter<TYPE> const &img, \
1097 afwMath::MaskImposter<afwImage::MaskPixel> const &msk, \
1098 afwMath::MaskImposter<VPixel> const &var, \
1099 int const flags, StatisticsControl const& sctrl); \
1100 template STAT::Statistics(afwMath::ImageImposter<TYPE> const &img, \
1101 afwMath::MaskImposter<afwImage::MaskPixel> const &msk, \
1102 afwMath::MaskImposter<VPixel> const &var, \
1103 afwMath::ImageImposter<VPixel> const &weights, \
1104 int const flags, StatisticsControl const& sctrl)
1106 #define INSTANTIATE_IMAGE_STATISTICS(T) \
1107 INSTANTIATE_MASKEDIMAGE_STATISTICS(T); \
1108 INSTANTIATE_MASKEDIMAGE_STATISTICS_NO_VAR(T); \
1109 INSTANTIATE_MASKEDIMAGE_STATISTICS_NO_MASK(T); \
1110 INSTANTIATE_REGULARIMAGE_STATISTICS(T); \
1111 INSTANTIATE_VECTOR_STATISTICS(T)
1113 INSTANTIATE_IMAGE_STATISTICS(
double);
1114 INSTANTIATE_IMAGE_STATISTICS(
float);
1115 INSTANTIATE_IMAGE_STATISTICS(
int);
1116 INSTANTIATE_IMAGE_STATISTICS(boost::uint16_t);
1117 INSTANTIATE_IMAGE_STATISTICS(boost::uint64_t);
double getValue(Property const prop=NOTHING) const
Return the value of the desired property (if specified in the constructor)
boost::uint16_t MaskPixel
std::pair< double, double > Value
The type used to report (value, error) for desired statistics.
x_iterator row_begin(int y) const
estimate sample N-sigma clipped mean (N set in StatisticsControl, default=3)
x_iterator row_end(int y) const
Return an x_iterator to the end of the y'th row.
Statistics(ImageT const &img, MaskT const &msk, VarianceT const &var, int const flags, StatisticsControl const &sctrl=StatisticsControl())
Constructor for Statistics object.
estimate sample standard deviation
find sum of pixels in the image
Value getResult(Property const prop=NOTHING) const
Return the value and error in the specified statistic (e.g. MEAN)
estimate sample N-sigma clipped stdev (N set in StatisticsControl, default=3)
boost::enable_if< typename ExpressionTraits< Scalar >::IsScalar, Scalar >::type sum(Scalar const &scalar)
find mean value of square of pixel values
table::Key< table::Array< Kernel::Pixel > > image
Include errors of requested quantities.
We don't want anything.
int getWidth() const
Return the number of columns in the image.
Pass parameters to a Statistics objectA class to pass parameters which control how the stats are calc...
void doStatistics(ImageT const &img, MaskT const &msk, VarianceT const &var, WeightT const &weights, int const flags, StatisticsControl const &sctrl)
Represent a 2-dimensional array of bitmask pixels.
bool getWeightedIsSet() const
float VariancePixel
! default type for Masks and MaskedImage Masks
double getError(Property const prop=NOTHING) const
Return the error in the desired property (if specified in the constructor)
#define LSST_EXCEPT(type,...)
void setWeighted(bool useWeights)
estimate sample inter-quartile range
Statistics makeStatistics(afwImage::Mask< afwImage::MaskPixel > const &msk, int const flags, StatisticsControl const &sctrl)
Specialization to handle Masks.
Compute Image Statistics.
get the or-mask of all pixels used.
Property stringToStatisticsProperty(std::string const property)
Conversion function to switch a string to a Property (see Statistics.h)
int getHeight() const
Return the number of rows in the image.
Property
control what is calculated
A class to represent a 2-dimensional array of pixels.
Include files required for standard LSST Exception handling.