35 #include <type_traits> 52 double const IQ_TO_STDEV = 0.741301109252802;
58 bool operator()(
T)
const {
61 template <
typename Ta,
typename Tb>
62 bool operator()(Ta, Tb)
const {
65 template <
typename Ta,
typename Tb,
typename Tc>
66 bool operator()(Ta, Tb, Tc)
const {
75 bool operator()(
T)
const {
78 template <
typename Ta,
typename Tb>
79 bool operator()(Ta, Tb)
const {
82 template <
typename Ta,
typename Tb,
typename Tc>
83 bool operator()(Ta, Tb, Tc)
const {
92 bool operator()(
T val)
const {
98 class CheckValueLtMin {
100 template <
typename Tval,
typename Tmin>
101 bool operator()(Tval
val, Tmin
min)
const {
102 return (static_cast<Tmin>(val) < min);
107 class CheckValueGtMax {
109 template <
typename Tval,
typename Tmax>
110 bool operator()(Tval val, Tmax
max)
const {
111 return (static_cast<Tmax>(val) > max);
116 class CheckClipRange {
118 template <
typename Tval,
typename Tcen,
typename Tmax>
119 bool operator()(Tval val, Tcen center, Tmax cliplimit)
const {
120 Tmax tmp =
fabs(val - center);
121 return (tmp <= cliplimit);
126 typedef CheckFinite ChkFin;
127 typedef CheckValueLtMin ChkMin;
128 typedef CheckValueGtMax ChkMax;
129 typedef CheckClipRange ChkClip;
130 typedef AlwaysTrue AlwaysT;
131 typedef AlwaysFalse AlwaysF;
136 inline double varianceError(
double const variance,
int const n) {
137 return 2 * (n - 1) * variance * variance / static_cast<double>(n * n);
164 template <
typename IsFinite,
typename HasValueLtMin,
typename HasValueGtMax,
typename InClipRange,
165 bool useWeights,
typename ImageT,
typename MaskT,
typename VarianceT,
typename WeightT>
166 StandardReturn processPixels(ImageT
const &img, MaskT
const &msk, VarianceT
const &var,
167 WeightT
const &weights,
int const,
int const nCrude,
int const stride,
168 double const meanCrude,
double const cliplimit,
169 bool const weightsAreMultiplicative,
int const andMask,
170 bool const calcErrorFromInputVariance,
180 double min = (nCrude) ? meanCrude : MAX_DOUBLE;
181 double max = (nCrude) ? meanCrude : -MAX_DOUBLE;
187 for (
int iY = 0; iY < img.getHeight(); iY += stride) {
188 typename MaskT::x_iterator mptr = msk.row_begin(iY);
189 typename VarianceT::x_iterator vptr = var.row_begin(iY);
190 typename WeightT::x_iterator wptr = weights.row_begin(iY);
192 for (
typename ImageT::x_iterator
ptr = img.row_begin(iY),
end =
ptr + img.getWidth();
ptr !=
end;
193 ++
ptr, ++mptr, ++vptr, ++wptr) {
194 if (IsFinite()(*ptr) && !(*mptr & andMask) &&
195 InClipRange()(*
ptr, meanCrude, cliplimit)) {
197 double const delta = (*
ptr - meanCrude);
201 if (weightsAreMultiplicative) {
212 sumx += weight * delta;
213 sumx2 += weight * delta * delta;
215 if (calcErrorFromInputVariance) {
216 double const var = *vptr;
217 sumvw2 += var * weight *
weight;
221 sumx2 += delta * delta;
223 if (calcErrorFromInputVariance) {
224 double const var = *vptr;
229 allPixelOrMask |= *mptr;
231 if (HasValueLtMin()(*
ptr,
min)) {
234 if (HasValueGtMax()(*
ptr,
max)) {
239 for (
int bit = 0, nBits = maskPropagationThresholds.
size(); bit < nBits; ++bit) {
245 if (!weightsAreMultiplicative) {
252 rejectedWeightsByBit[bit] +=
weight;
269 for (
int bit = 0, nBits = maskPropagationThresholds.
size(); bit < nBits; ++bit) {
270 double hypotheticalTotalWeight = sumw + rejectedWeightsByBit[bit];
271 rejectedWeightsByBit[bit] /= hypotheticalTotalWeight;
272 if (rejectedWeightsByBit[bit] > maskPropagationThresholds[bit]) {
273 allPixelOrMask |= (1 << bit);
281 variance = sumx2 / sumw -
::pow(mean, 2);
282 variance *= sumw * sumw / (sumw * sumw - sumw2);
285 if (calcErrorFromInputVariance) {
286 meanVar = sumvw2 / (sumw * sumw);
288 meanVar = variance * sumw2 / (sumw * sumw);
291 double varVar = varianceError(variance, n);
293 sumx += sumw * meanCrude;
296 return StandardReturn(n, sumx, Statistics::Value(mean, meanVar), Statistics::Value(variance, varVar), min,
297 max, allPixelOrMask);
300 template <
typename IsFinite,
typename HasValueLtMin,
typename HasValueGtMax,
typename InClipRange,
301 bool useWeights,
typename ImageT,
typename MaskT,
typename VarianceT,
typename WeightT>
302 StandardReturn processPixels(ImageT
const &img, MaskT
const &msk, VarianceT
const &var,
303 WeightT
const &weights,
int const flags,
int const nCrude,
int const stride,
304 double const meanCrude,
double const cliplimit,
305 bool const weightsAreMultiplicative,
int const andMask,
306 bool const calcErrorFromInputVariance,
bool doGetWeighted,
309 return processPixels<IsFinite, HasValueLtMin, HasValueGtMax, InClipRange, true>(
310 img, msk, var, weights, flags, nCrude, 1, meanCrude, cliplimit, weightsAreMultiplicative,
311 andMask, calcErrorFromInputVariance, maskPropagationThresholds);
313 return processPixels<IsFinite, HasValueLtMin, HasValueGtMax, InClipRange, false>(
314 img, msk, var, weights, flags, nCrude, 1, meanCrude, cliplimit, weightsAreMultiplicative,
315 andMask, calcErrorFromInputVariance, maskPropagationThresholds);
319 template <
typename IsFinite,
typename HasValueLtMin,
typename HasValueGtMax,
typename InClipRange,
320 bool useWeights,
typename ImageT,
typename MaskT,
typename VarianceT,
typename WeightT>
321 StandardReturn processPixels(ImageT
const &img, MaskT
const &msk, VarianceT
const &var,
322 WeightT
const &weights,
int const flags,
int const nCrude,
int const stride,
323 double const meanCrude,
double const cliplimit,
324 bool const weightsAreMultiplicative,
int const andMask,
325 bool const calcErrorFromInputVariance,
bool doCheckFinite,
bool doGetWeighted,
328 return processPixels<CheckFinite, HasValueLtMin, HasValueGtMax, InClipRange, useWeights>(
329 img, msk, var, weights, flags, nCrude, 1, meanCrude, cliplimit, weightsAreMultiplicative,
330 andMask, calcErrorFromInputVariance, doGetWeighted, maskPropagationThresholds);
332 return processPixels<AlwaysTrue, HasValueLtMin, HasValueGtMax, InClipRange, useWeights>(
333 img, msk, var, weights, flags, nCrude, 1, meanCrude, cliplimit, weightsAreMultiplicative,
334 andMask, calcErrorFromInputVariance, doGetWeighted, maskPropagationThresholds);
355 template <
typename ImageT,
typename MaskT,
typename VarianceT,
typename WeightT>
356 StandardReturn getStandard(ImageT
const &img, MaskT
const &msk, VarianceT
const &var, WeightT
const &weights,
357 int const flags,
bool const weightsAreMultiplicative,
int const andMask,
358 bool const calcErrorFromInputVariance,
bool doCheckFinite,
bool doGetWeighted,
363 double meanCrude = 0.0;
366 int const nPix = img.getWidth() * img.getHeight();
374 double cliplimit = -1;
375 StandardReturn values = processPixels<ChkFin, AlwaysF, AlwaysF, AlwaysT, true>(
376 img, msk, var, weights, flags, nCrude, strideCrude, meanCrude, cliplimit,
377 weightsAreMultiplicative, andMask, calcErrorFromInputVariance, doCheckFinite, doGetWeighted,
378 maskPropagationThresholds);
379 nCrude = std::get<0>(values);
380 double sumCrude = std::get<1>(values);
384 meanCrude = sumCrude / nCrude;
391 if (flags & (
MIN |
MAX)) {
392 return processPixels<ChkFin, ChkMin, ChkMax, AlwaysT, true>(
393 img, msk, var, weights, flags, nCrude, 1, meanCrude, cliplimit, weightsAreMultiplicative,
394 andMask, calcErrorFromInputVariance,
true, doGetWeighted, maskPropagationThresholds);
396 return processPixels<ChkFin, AlwaysF, AlwaysF, AlwaysT, true>(
397 img, msk, var, weights, flags, nCrude, 1, meanCrude, cliplimit, weightsAreMultiplicative,
398 andMask, calcErrorFromInputVariance, doCheckFinite, doGetWeighted, maskPropagationThresholds);
420 template <
typename ImageT,
typename MaskT,
typename VarianceT,
typename WeightT>
421 StandardReturn getStandard(ImageT
const &img, MaskT
const &msk, VarianceT
const &var, WeightT
const &weights,
424 bool const weightsAreMultiplicative,
int const andMask,
425 bool const calcErrorFromInputVariance,
bool doCheckFinite,
bool doGetWeighted,
427 double const center = clipinfo.first;
428 double const cliplimit = clipinfo.second;
431 return StandardReturn(0, NaN, Statistics::Value(NaN, NaN), Statistics::Value(NaN, NaN), NaN, NaN,
437 int const stride = 1;
440 if (flags & (
MIN |
MAX)) {
441 return processPixels<ChkFin, ChkMin, ChkMax, ChkClip, true>(
442 img, msk, var, weights, flags, nCrude, stride, center, cliplimit, weightsAreMultiplicative,
443 andMask, calcErrorFromInputVariance,
true, doGetWeighted, maskPropagationThresholds);
445 return processPixels<ChkFin, AlwaysF, AlwaysF, ChkClip, true>(
446 img, msk, var, weights, flags, nCrude, stride, center, cliplimit, weightsAreMultiplicative,
447 andMask, calcErrorFromInputVariance, doCheckFinite, doGetWeighted, maskPropagationThresholds);
459 template <
typename Pixel>
462 assert(fraction >= 0.0 && fraction <= 1.0);
464 int const n = img.
size();
467 double const idx = fraction * (n - 1);
475 int const q1 =
static_cast<int>(idx);
476 int const q2 = q1 + 1;
478 auto mid1 = img.
begin() + q1;
479 auto mid2 = img.
begin() + q2;
480 if (fraction > 0.5) {
488 double val1 =
static_cast<double>(*mid1);
489 double val2 =
static_cast<double>(*mid2);
490 double w1 = (
static_cast<double>(q2) - idx);
491 double w2 = (idx -
static_cast<double>(q1));
492 return w1 * val1 + w2 * val2;
526 auto const val = *
ptr;
529 }
else if (val == naive) {
534 return naive - 0.5 + (target -
left)/middle;
545 template <
typename Pixel>
548 assert(fraction >= 0.0 && fraction <= 1.0);
550 auto const n = img.
size();
564 double const idx = fraction*(n - 1);
566 auto midP = img.
begin() +
static_cast<int>(idx);
568 auto const naiveP = *midP;
570 return computeQuantile(img.
begin(), img.
end(), naiveP, fraction*n);
584 template <
typename Pixel>
585 typename enable_if<!is_integral<Pixel>::value, MedianQuartileReturn>
::type 587 int const n = img.
size();
590 double const idx50 = 0.50 * (n - 1);
591 double const idx25 = 0.25 * (n - 1);
592 double const idx75 = 0.75 * (n - 1);
599 int const q50a =
static_cast<int>(idx50);
600 int const q50b = q50a + 1;
601 int const q25a =
static_cast<int>(idx25);
602 int const q25b = q25a + 1;
603 int const q75a =
static_cast<int>(idx75);
604 int const q75b = q75a + 1;
606 auto mid50a = img.
begin() + q50a;
607 auto mid50b = img.
begin() + q50b;
608 auto mid25a = img.
begin() + q25a;
609 auto mid25b = img.
begin() + q25b;
610 auto mid75a = img.
begin() + q75a;
611 auto mid75b = img.
begin() + q75b;
624 double val50a =
static_cast<double>(*mid50a);
625 double val50b =
static_cast<double>(*mid50b);
626 double w50a = (
static_cast<double>(q50b) - idx50);
627 double w50b = (idx50 -
static_cast<double>(q50a));
628 double median = w50a * val50a + w50b * val50b;
630 double val25a =
static_cast<double>(*mid25a);
631 double val25b =
static_cast<double>(*mid25b);
632 double w25a = (
static_cast<double>(q25b) - idx25);
633 double w25b = (idx25 -
static_cast<double>(q25a));
634 double q1 = w25a * val25a + w25b * val25b;
636 double val75a =
static_cast<double>(*mid75a);
637 double val75b =
static_cast<double>(*mid75b);
638 double w75a = (
static_cast<double>(q75b) - idx75);
639 double w75b = (idx75 -
static_cast<double>(q75a));
640 double q3 = w75a * val75a + w75b * val75b;
642 return MedianQuartileReturn(median, q1, q3);
644 return MedianQuartileReturn(img[0], img[0], img[0]);
646 return MedianQuartileReturn(NaN, NaN, NaN);
657 template <
typename Pixel>
660 auto const n = img.
size();
663 return MedianQuartileReturn(NaN, NaN, NaN);
665 return MedianQuartileReturn(img[0], img[0], img[0]);
677 auto mid25 = img.
begin() +
static_cast<int>(0.25*(n - 1));
678 auto mid50 = img.
begin() +
static_cast<int>(0.50*(n - 1));
679 auto mid75 = img.
begin() +
static_cast<int>(0.75*(n - 1));
686 double const q1 = computeQuantile(img.
begin(), mid50, *mid25,
688 double const median = computeQuantile(mid25, mid75, *mid50,
689 0.50*n - (mid25 - img.
begin()));
690 double const q3 = computeQuantile(mid50, img.
end(), *mid75,
691 0.75*n - (mid50 - img.
begin()));
693 return MedianQuartileReturn(median, q1, q3);
705 template <
typename IsFinite,
typename ImageT,
typename MaskT,
typename VarianceT>
707 VarianceT
const &,
int const andMask) {
712 for (
int i_y = 0; i_y < img.getHeight(); ++i_y) {
713 typename MaskT::x_iterator mptr = msk.row_begin(i_y);
714 for (
typename ImageT::x_iterator
ptr = img.row_begin(i_y), end = img.row_end(i_y);
ptr !=
end;
716 if (IsFinite()(*ptr) && !(*mptr & andMask)) {
717 imgcp->push_back(*
ptr);
727 double StatisticsControl::getMaskPropagationThreshold(
int bit)
const {
728 int oldSize = _maskPropagationThresholds.size();
732 return _maskPropagationThresholds[bit];
735 void StatisticsControl::setMaskPropagationThreshold(
int bit,
double threshold) {
736 int oldSize = _maskPropagationThresholds.size();
737 if (oldSize <= bit) {
738 int newSize = bit + 1;
739 _maskPropagationThresholds.resize(newSize);
740 for (
int i = oldSize; i < bit; ++i) {
741 _maskPropagationThresholds[i] = 1.0;
744 _maskPropagationThresholds[bit] = threshold;
749 if (statisticsProperty.
size() == 0) {
750 statisticsProperty[
"NOTHING"] =
NOTHING;
751 statisticsProperty[
"ERRORS"] =
ERRORS;
752 statisticsProperty[
"NPOINT"] =
NPOINT;
753 statisticsProperty[
"MEAN"] =
MEAN;
754 statisticsProperty[
"STDEV"] =
STDEV;
755 statisticsProperty[
"VARIANCE"] =
VARIANCE;
756 statisticsProperty[
"MEDIAN"] =
MEDIAN;
757 statisticsProperty[
"IQRANGE"] =
IQRANGE;
758 statisticsProperty[
"MEANCLIP"] =
MEANCLIP;
759 statisticsProperty[
"STDEVCLIP"] =
STDEVCLIP;
761 statisticsProperty[
"MIN"] =
MIN;
762 statisticsProperty[
"MAX"] =
MAX;
763 statisticsProperty[
"SUM"] =
SUM;
764 statisticsProperty[
"MEANSQUARE"] =
MEANSQUARE;
765 statisticsProperty[
"ORMASK"] =
ORMASK;
766 statisticsProperty[
"NCLIPPED"] =
NCLIPPED;
767 statisticsProperty[
"NMASKED"] =
NMASKED;
769 return statisticsProperty[property];
772 template <
typename ImageT,
typename MaskT,
typename VarianceT>
773 Statistics::Statistics(ImageT
const &img, MaskT
const &msk, VarianceT
const &var,
int const flags,
782 _varianceclip(NaN, NaN),
788 _weightsAreMultiplicative(false) {
789 doStatistics(img, msk, var, var, _flags, _sctrl);
793 template <
typename T>
794 bool isEmpty(
T const &t) {
798 template <
typename T>
804 template <
typename ImageT1,
typename ImageT2>
805 void checkDimensions(ImageT1
const &image1, ImageT2
const &image2) {
806 if (image1.getDimensions() != image2.getDimensions()) {
808 (
boost::format(
"Image sizes don't match: %s vs %s") % image1.getDimensions() %
809 image2.getDimensions())
815 template <
typename ImageT,
typename PixelT>
817 template <
typename ImageT,
typename PixelT>
821 template <
typename ImageT,
typename MaskT,
typename VarianceT,
typename WeightT>
831 _varianceclip(NaN, NaN),
837 _weightsAreMultiplicative(true) {
838 if (!isEmpty(weights)) {
841 "You must use the weights if you provide them");
846 doStatistics(img, msk, var, weights, _flags, _sctrl);
849 template <
typename ImageT,
typename MaskT,
typename VarianceT,
typename WeightT>
850 void Statistics::doStatistics(ImageT
const &img, MaskT
const &msk, VarianceT
const &var,
852 int const num = img.getWidth() * img.getHeight();
857 checkDimensions(img, msk);
858 checkDimensions(img, var);
860 checkDimensions(img, weights);
867 StandardReturn standard =
868 getStandard(img, msk, var, weights, flags, _weightsAreMultiplicative, _sctrl.
getAndMask(),
870 _sctrl._maskPropagationThresholds);
872 _n = std::get<0>(standard);
873 _sum = std::get<1>(standard);
874 _mean = std::get<2>(standard);
875 _variance = std::get<3>(standard);
876 _min = std::get<4>(standard);
877 _max = std::get<5>(standard);
878 _allPixelOrMask = std::get<6>(standard);
892 imgcp = makeVectorCopy<ChkFin>(img, msk, var, _sctrl.
getAndMask());
894 imgcp = makeVectorCopy<AlwaysT>(img, msk, var, _sctrl.
getAndMask());
899 _median =
Value(percentile(*imgcp, 0.5), NaN);
901 MedianQuartileReturn mq = medianAndQuartiles(*imgcp);
902 _median =
Value(std::get<0>(mq), NaN);
903 _iqrange = std::get<2>(mq) - std::get<1>(mq);
907 for (
int i_i = 0; i_i < _sctrl.
getNumIter(); ++i_i) {
908 double const center = ((i_i > 0) ? _meanclip : _median).first;
909 double const hwidth = (i_i > 0 && _n > 1)
914 StandardReturn clipped = getStandard(
915 img, msk, var, weights, flags, clipinfo, _weightsAreMultiplicative,
917 _sctrl.
getWeighted(), _sctrl._maskPropagationThresholds);
919 int const nClip = std::get<0>(clipped);
920 _nClipped = _n - nClip;
921 _meanclip = std::get<2>(clipped);
922 double const varClip = std::get<3>(clipped).
first;
924 _varianceclip =
Value(varClip, varianceError(varClip, nClip));
935 if (!(prop & _flags)) {
937 (
boost::format(
"You didn't ask me to calculate %d") % prop).str());
943 ret.first =
static_cast<double>(_n);
950 ret.first =
static_cast<double>(_nClipped);
951 if (_flags & ERRORS) {
957 ret.first =
static_cast<double>(_nMasked);
958 if (_flags & ERRORS) {
964 ret.first =
static_cast<double>(_sum);
965 if (_flags & ERRORS) {
972 ret.first = _mean.first;
973 if (_flags & ERRORS) {
974 ret.second = ::sqrt(_mean.second);
978 ret.first = _meanclip.first;
979 if (_flags & ERRORS) {
980 ret.second = ::sqrt(_meanclip.second);
986 ret.first = _variance.first;
987 if (_flags & ERRORS) {
988 ret.second = ::sqrt(_variance.second);
992 ret.first =
sqrt(_variance.first);
993 if (_flags & ERRORS) {
994 ret.second = 0.5 * ::sqrt(_variance.second) / ret.first;
998 ret.first = _varianceclip.first;
999 if (_flags & ERRORS) {
1000 ret.second = ret.second;
1004 ret.first =
sqrt(_varianceclip.first);
1005 if (_flags & ERRORS) {
1006 ret.second = 0.5 * ::sqrt(_varianceclip.second) / ret.first;
1011 ret.first = (_n - 1) / static_cast<double>(_n) * _variance.first + ::pow(_mean.first, 2);
1012 if (_flags & ERRORS) {
1013 ret.second = ::sqrt(2 * ::
pow(ret.first / _n, 2));
1020 if (_flags & ERRORS) {
1026 if (_flags & ERRORS) {
1031 ret.first = _median.first;
1032 if (_flags & ERRORS) {
1037 ret.first = _iqrange;
1038 if (_flags & ERRORS) {
1050 "getValue() may only be called without a parameter" 1051 " if you asked for only one statistic");
1075 _variance(NaN, NaN),
1078 _meanclip(NaN, NaN),
1079 _varianceclip(NaN, NaN),
1086 "Statistics<Mask> only supports NPOINT and SUM");
1115 return Statistics(msk, msk, msk, flags, sctrl);
1126 #define STAT Statistics 1130 #define INSTANTIATE_MASKEDIMAGE_STATISTICS(TYPE) \ 1131 template STAT::Statistics(image::Image<TYPE> const &img, image::Mask<image::MaskPixel> const &msk, \ 1132 image::Image<VPixel> const &var, int const flags, \ 1133 StatisticsControl const &sctrl); \ 1134 template STAT::Statistics(image::Image<TYPE> const &img, image::Mask<image::MaskPixel> const &msk, \ 1135 image::Image<VPixel> const &var, image::Image<VPixel> const &weights, \ 1136 int const flags, StatisticsControl const &sctrl); \ 1137 template STAT::Statistics(image::Image<TYPE> const &img, image::Mask<image::MaskPixel> const &msk, \ 1138 image::Image<VPixel> const &var, ImageImposter<VPixel> const &weights, \ 1139 int const flags, StatisticsControl const &sctrl) 1141 #define INSTANTIATE_MASKEDIMAGE_STATISTICS_NO_MASK(TYPE) \ 1142 template STAT::Statistics(image::Image<TYPE> const &img, MaskImposter<image::MaskPixel> const &msk, \ 1143 image::Image<VPixel> const &var, int const flags, \ 1144 StatisticsControl const &sctrl); \ 1145 template STAT::Statistics(image::Image<TYPE> const &img, MaskImposter<image::MaskPixel> const &msk, \ 1146 image::Image<VPixel> const &var, image::Image<VPixel> const &weights, \ 1147 int const flags, StatisticsControl const &sctrl) 1149 #define INSTANTIATE_MASKEDIMAGE_STATISTICS_NO_VAR(TYPE) \ 1150 template STAT::Statistics(image::Image<TYPE> const &img, image::Mask<image::MaskPixel> const &msk, \ 1151 MaskImposter<VPixel> const &var, int const flags, \ 1152 StatisticsControl const &sctrl); \ 1153 template STAT::Statistics(image::Image<TYPE> const &img, image::Mask<image::MaskPixel> const &msk, \ 1154 MaskImposter<VPixel> const &var, image::Image<VPixel> const &weights, \ 1155 int const flags, StatisticsControl const &sctrl); \ 1156 template STAT::Statistics(image::Image<TYPE> const &img, image::Mask<image::MaskPixel> const &msk, \ 1157 MaskImposter<VPixel> const &var, ImageImposter<VPixel> const &weights, \ 1158 int const flags, StatisticsControl const &sctrl) 1160 #define INSTANTIATE_REGULARIMAGE_STATISTICS(TYPE) \ 1161 template STAT::Statistics(image::Image<TYPE> const &img, MaskImposter<image::MaskPixel> const &msk, \ 1162 MaskImposter<VPixel> const &var, int const flags, \ 1163 StatisticsControl const &sctrl) 1165 #define INSTANTIATE_VECTOR_STATISTICS(TYPE) \ 1166 template STAT::Statistics(ImageImposter<TYPE> const &img, MaskImposter<image::MaskPixel> const &msk, \ 1167 MaskImposter<VPixel> const &var, int const flags, \ 1168 StatisticsControl const &sctrl); \ 1169 template STAT::Statistics(ImageImposter<TYPE> const &img, MaskImposter<image::MaskPixel> const &msk, \ 1170 MaskImposter<VPixel> const &var, ImageImposter<VPixel> const &weights, \ 1171 int const flags, StatisticsControl const &sctrl) 1173 #define INSTANTIATE_IMAGE_STATISTICS(T) \ 1174 INSTANTIATE_MASKEDIMAGE_STATISTICS(T); \ 1175 INSTANTIATE_MASKEDIMAGE_STATISTICS_NO_VAR(T); \ 1176 INSTANTIATE_MASKEDIMAGE_STATISTICS_NO_MASK(T); \ 1177 INSTANTIATE_REGULARIMAGE_STATISTICS(T); \ 1178 INSTANTIATE_VECTOR_STATISTICS(T) 1180 INSTANTIATE_IMAGE_STATISTICS(
double);
1181 INSTANTIATE_IMAGE_STATISTICS(
float);
1182 INSTANTIATE_IMAGE_STATISTICS(
int);
Value getResult(Property const prop=NOTHING) const
Return the value and error in the specified statistic (e.g.
double getNumSigmaClip() const noexcept
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
bool getNanSafe() const noexcept
Key< Flag > const & target
get the or-mask of all pixels used.
bool getCalcErrorFromInputVariance() const noexcept
double getError(Property const prop=NOTHING) const
Return the error in the desired property (if specified in the constructor)
int getHeight() const
Return the number of rows in the image.
estimate sample standard deviation
find mean value of square of pixel values
int getNumIter() const noexcept
We don't want anything.
Include errors of requested quantities.
x_iterator row_begin(int y) const
Return an x_iterator to the start of the y'th row.
A class to evaluate image statistics.
Statistics(ImageT const &img, MaskT const &msk, VarianceT const &var, int const flags, StatisticsControl const &sctrl=StatisticsControl())
Constructor for Statistics object.
estimate sample N-sigma clipped stdev (N set in StatisticsControl, default=3)
std::pair< double, double > Value
The type used to report (value, error) for desired statistics.
Property stringToStatisticsProperty(std::string const property)
Conversion function to switch a string to a Property (see Statistics.h)
Pass parameters to a Statistics object.
estimate sample N-sigma clipped mean (N set in StatisticsControl, default=3)
A base class for image defects.
Represent a 2-dimensional array of bitmask pixels.
estimate sample N-sigma clipped variance (N set in StatisticsControl, default=3)
A Mask wrapper to provide an infinite_iterator for Mask::row_begin().
bool getWeightedIsSet() const noexcept
double getValue(Property const prop=NOTHING) const
Return the value of the desired property (if specified in the constructor)
int getAndMask() const noexcept
afw::table::Key< double > weight
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
estimate sample inter-quartile range
int getWidth() const
Return the number of columns in the image.
Reports invalid arguments.
x_iterator row_end(int y) const
Return an x_iterator to the end of the y'th row.
void setWeighted(bool useWeights) noexcept
find sum of pixels in the image
bool getWeighted() const noexcept
float VariancePixel
default type for MaskedImage variance images
Property
control what is calculated
A class to represent a 2-dimensional array of pixels.
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)