51double const IQ_TO_STDEV = 0.741301109252802;
57 bool operator()(
T)
const {
60 template <
typename Ta,
typename Tb>
61 bool operator()(Ta, Tb)
const {
64 template <
typename Ta,
typename Tb,
typename Tc>
65 bool operator()(Ta, Tb, Tc)
const {
74 bool operator()(
T)
const {
77 template <
typename Ta,
typename Tb>
78 bool operator()(Ta, Tb)
const {
81 template <
typename Ta,
typename Tb,
typename Tc>
82 bool operator()(Ta, Tb, Tc)
const {
91 bool operator()(
T val)
const {
97class CheckValueLtMin {
99 template <
typename Tval,
typename Tmin>
100 bool operator()(Tval
val, Tmin
min)
const {
101 return (
static_cast<Tmin
>(
val) <
min);
106class CheckValueGtMax {
108 template <
typename Tval,
typename Tmax>
109 bool operator()(Tval
val, Tmax
max)
const {
110 return (
static_cast<Tmax
>(
val) >
max);
115class CheckClipRange {
117 template <
typename Tval,
typename Tcen,
typename Tmax>
118 bool operator()(Tval
val, Tcen center, Tmax cliplimit)
const {
120 return (tmp <= cliplimit);
125using ChkFin = CheckFinite;
126using ChkMin = CheckValueLtMin;
127using ChkMax = CheckValueGtMax;
128using ChkClip = CheckClipRange;
129using AlwaysT = AlwaysTrue;
130using AlwaysF = AlwaysFalse;
135inline double varianceError(
double const variance,
int const n) {
155template <
typename IsFinite,
typename HasValueLtMin,
typename HasValueGtMax,
typename InClipRange,
156 bool useWeights,
typename ImageT,
typename MaskT,
typename VarianceT,
typename WeightT>
157StandardReturn processPixels(ImageT
const &img, MaskT
const &msk, VarianceT
const &var,
158 WeightT
const &weights,
int const,
int const nCrude,
int const stride,
159 double const meanCrude,
double const cliplimit,
160 bool const weightsAreMultiplicative,
int const andMask,
161 bool const calcErrorFromInputVariance,
171 double min = (nCrude) ? meanCrude : MAX_DOUBLE;
172 double max = (nCrude) ? meanCrude : -MAX_DOUBLE;
178 for (
int iY = 0; iY < img.getHeight(); iY += stride) {
179 typename MaskT::x_iterator mptr = msk.row_begin(iY);
180 typename VarianceT::x_iterator vptr = var.row_begin(iY);
181 typename WeightT::x_iterator wptr = weights.row_begin(iY);
183 for (
typename ImageT::x_iterator
ptr = img.row_begin(iY),
end =
ptr + img.getWidth();
ptr !=
end;
184 ++
ptr, ++mptr, ++vptr, ++wptr) {
185 if (IsFinite()(*
ptr) && !(*mptr & andMask) &&
186 InClipRange()(*
ptr, meanCrude, cliplimit)) {
188 double const delta = (*
ptr - meanCrude);
192 if (weightsAreMultiplicative) {
204 sumx2 +=
weight * delta * delta;
206 if (calcErrorFromInputVariance) {
207 double const var = *vptr;
212 sumx2 += delta * delta;
214 if (calcErrorFromInputVariance) {
215 double const var = *vptr;
220 allPixelOrMask |= *mptr;
222 if (HasValueLtMin()(*
ptr,
min)) {
225 if (HasValueGtMax()(*
ptr,
max)) {
230 for (
int bit = 0, nBits = maskPropagationThresholds.
size(); bit < nBits; ++bit) {
236 if (!weightsAreMultiplicative) {
243 rejectedWeightsByBit[bit] +=
weight;
260 for (
int bit = 0, nBits = maskPropagationThresholds.
size(); bit < nBits; ++bit) {
261 double hypotheticalTotalWeight = sumw + rejectedWeightsByBit[bit];
262 rejectedWeightsByBit[bit] /= hypotheticalTotalWeight;
263 if (rejectedWeightsByBit[bit] > maskPropagationThresholds[bit]) {
264 allPixelOrMask |= (1 << bit);
272 variance = sumx2 / sumw - ::pow(mean, 2);
273 variance *= sumw * sumw / (sumw * sumw - sumw2);
276 if (calcErrorFromInputVariance) {
277 meanVar = sumvw2 / (sumw * sumw);
279 meanVar =
variance * sumw2 / (sumw * sumw);
282 double varVar = varianceError(
variance, n);
284 sumx += sumw * meanCrude;
288 max, allPixelOrMask);
291template <
typename IsFinite,
typename HasValueLtMin,
typename HasValueGtMax,
typename InClipRange,
292 bool useWeights,
typename ImageT,
typename MaskT,
typename VarianceT,
typename WeightT>
293StandardReturn processPixels(ImageT
const &img, MaskT
const &msk, VarianceT
const &var,
294 WeightT
const &weights,
int const flags,
int const nCrude,
int const stride,
295 double const meanCrude,
double const cliplimit,
296 bool const weightsAreMultiplicative,
int const andMask,
297 bool const calcErrorFromInputVariance,
bool doGetWeighted,
300 return processPixels<IsFinite, HasValueLtMin, HasValueGtMax, InClipRange, true>(
301 img, msk, var, weights, flags, nCrude, 1, meanCrude, cliplimit, weightsAreMultiplicative,
302 andMask, calcErrorFromInputVariance, maskPropagationThresholds);
304 return processPixels<IsFinite, HasValueLtMin, HasValueGtMax, InClipRange, false>(
305 img, msk, var, weights, flags, nCrude, 1, meanCrude, cliplimit, weightsAreMultiplicative,
306 andMask, calcErrorFromInputVariance, maskPropagationThresholds);
310template <
typename IsFinite,
typename HasValueLtMin,
typename HasValueGtMax,
typename InClipRange,
311 bool useWeights,
typename ImageT,
typename MaskT,
typename VarianceT,
typename WeightT>
312StandardReturn processPixels(ImageT
const &img, MaskT
const &msk, VarianceT
const &var,
313 WeightT
const &weights,
int const flags,
int const nCrude,
int const stride,
314 double const meanCrude,
double const cliplimit,
315 bool const weightsAreMultiplicative,
int const andMask,
316 bool const calcErrorFromInputVariance,
bool doCheckFinite,
bool doGetWeighted,
319 return processPixels<CheckFinite, HasValueLtMin, HasValueGtMax, InClipRange, useWeights>(
320 img, msk, var, weights, flags, nCrude, 1, meanCrude, cliplimit, weightsAreMultiplicative,
321 andMask, calcErrorFromInputVariance, doGetWeighted, maskPropagationThresholds);
323 return processPixels<AlwaysTrue, HasValueLtMin, HasValueGtMax, InClipRange, useWeights>(
324 img, msk, var, weights, flags, nCrude, 1, meanCrude, cliplimit, weightsAreMultiplicative,
325 andMask, calcErrorFromInputVariance, doGetWeighted, maskPropagationThresholds);
346template <
typename ImageT,
typename MaskT,
typename VarianceT,
typename WeightT>
347StandardReturn getStandard(ImageT
const &img, MaskT
const &msk, VarianceT
const &var, WeightT
const &weights,
348 int const flags,
bool const weightsAreMultiplicative,
int const andMask,
349 bool const calcErrorFromInputVariance,
bool doCheckFinite,
bool doGetWeighted,
354 double meanCrude = 0.0;
357 int const nPix = img.getWidth() * img.getHeight();
365 double cliplimit = -1;
366 StandardReturn values = processPixels<ChkFin, AlwaysF, AlwaysF, AlwaysT, true>(
367 img, msk, var, weights, flags, nCrude, strideCrude, meanCrude, cliplimit,
368 weightsAreMultiplicative, andMask, calcErrorFromInputVariance, doCheckFinite, doGetWeighted,
369 maskPropagationThresholds);
370 nCrude = std::get<0>(values);
371 double sumCrude = std::get<1>(values);
375 meanCrude = sumCrude / nCrude;
382 if (flags & (
MIN |
MAX)) {
383 return processPixels<ChkFin, ChkMin, ChkMax, AlwaysT, true>(
384 img, msk, var, weights, flags, nCrude, 1, meanCrude, cliplimit, weightsAreMultiplicative,
385 andMask, calcErrorFromInputVariance,
true, doGetWeighted, maskPropagationThresholds);
387 return processPixels<ChkFin, AlwaysF, AlwaysF, AlwaysT, true>(
388 img, msk, var, weights, flags, nCrude, 1, meanCrude, cliplimit, weightsAreMultiplicative,
389 andMask, calcErrorFromInputVariance, doCheckFinite, doGetWeighted, maskPropagationThresholds);
411template <
typename ImageT,
typename MaskT,
typename VarianceT,
typename WeightT>
412StandardReturn getStandard(ImageT
const &img, MaskT
const &msk, VarianceT
const &var, WeightT
const &weights,
415 bool const weightsAreMultiplicative,
int const andMask,
416 bool const calcErrorFromInputVariance,
bool doCheckFinite,
bool doGetWeighted,
418 double const center = clipinfo.first;
419 double const cliplimit = clipinfo.second;
428 int const stride = 1;
431 if (flags & (
MIN |
MAX)) {
432 return processPixels<ChkFin, ChkMin, ChkMax, ChkClip, true>(
433 img, msk, var, weights, flags, nCrude, stride, center, cliplimit, weightsAreMultiplicative,
434 andMask, calcErrorFromInputVariance,
true, doGetWeighted, maskPropagationThresholds);
436 return processPixels<ChkFin, AlwaysF, AlwaysF, ChkClip, true>(
437 img, msk, var, weights, flags, nCrude, stride, center, cliplimit, weightsAreMultiplicative,
438 andMask, calcErrorFromInputVariance, doCheckFinite, doGetWeighted, maskPropagationThresholds);
450template <
typename Pixel>
453 assert(fraction >= 0.0 && fraction <= 1.0);
455 int const n = img.
size();
458 double const idx = fraction * (n - 1);
466 int const q1 =
static_cast<int>(idx);
467 int const q2 = q1 + 1;
469 auto mid1 = img.
begin() + q1;
470 auto mid2 = img.
begin() + q2;
471 if (fraction > 0.5) {
479 double val1 =
static_cast<double>(*mid1);
480 double val2 =
static_cast<double>(*mid2);
481 double w1 = (
static_cast<double>(q2) - idx);
482 double w2 = (idx -
static_cast<double>(q1));
483 return w1 * val1 + w2 * val2;
520 }
else if (
val == naive) {
536 template <
typename Pixel>
539 assert(fraction >= 0.0 && fraction <= 1.0);
541 auto const n = img.
size();
555 double const idx = fraction*(n - 1);
557 auto midP = img.
begin() +
static_cast<int>(idx);
559 auto const naiveP = *midP;
561 return computeQuantile(img.
begin(), img.
end(), naiveP, fraction*n);
575 template <
typename Pixel>
578 int const n = img.
size();
581 double const idx50 = 0.50 * (n - 1);
582 double const idx25 = 0.25 * (n - 1);
583 double const idx75 = 0.75 * (n - 1);
590 int const q50a =
static_cast<int>(idx50);
591 int const q50b = q50a + 1;
592 int const q25a =
static_cast<int>(idx25);
593 int const q25b = q25a + 1;
594 int const q75a =
static_cast<int>(idx75);
595 int const q75b = q75a + 1;
597 auto mid50a = img.
begin() + q50a;
598 auto mid50b = img.
begin() + q50b;
599 auto mid25a = img.
begin() + q25a;
600 auto mid25b = img.
begin() + q25b;
601 auto mid75a = img.
begin() + q75a;
602 auto mid75b = img.
begin() + q75b;
615 double val50a =
static_cast<double>(*mid50a);
616 double val50b =
static_cast<double>(*mid50b);
617 double w50a = (
static_cast<double>(q50b) - idx50);
618 double w50b = (idx50 -
static_cast<double>(q50a));
619 double median = w50a * val50a + w50b * val50b;
621 double val25a =
static_cast<double>(*mid25a);
622 double val25b =
static_cast<double>(*mid25b);
623 double w25a = (
static_cast<double>(q25b) - idx25);
624 double w25b = (idx25 -
static_cast<double>(q25a));
625 double q1 = w25a * val25a + w25b * val25b;
627 double val75a =
static_cast<double>(*mid75a);
628 double val75b =
static_cast<double>(*mid75b);
629 double w75a = (
static_cast<double>(q75b) - idx75);
630 double w75b = (idx75 -
static_cast<double>(q75a));
631 double q3 = w75a * val75a + w75b * val75b;
633 return MedianQuartileReturn(median, q1, q3);
635 return MedianQuartileReturn(img[0], img[0], img[0]);
637 return MedianQuartileReturn(NaN, NaN, NaN);
648 template <
typename Pixel>
651 auto const n = img.
size();
654 return MedianQuartileReturn(NaN, NaN, NaN);
656 return MedianQuartileReturn(img[0], img[0], img[0]);
668 auto mid25 = img.
begin() +
static_cast<int>(0.25*(n - 1));
669 auto mid50 = img.
begin() +
static_cast<int>(0.50*(n - 1));
670 auto mid75 = img.
begin() +
static_cast<int>(0.75*(n - 1));
677 double const q1 = computeQuantile(img.
begin(), mid50, *mid25,
679 double const median = computeQuantile(mid25, mid75, *mid50,
680 0.50*n - (mid25 - img.
begin()));
681 double const q3 = computeQuantile(mid50, img.
end(), *mid75,
682 0.75*n - (mid50 - img.
begin()));
684 return MedianQuartileReturn(median, q1, q3);
696template <
typename IsFinite,
typename ImageT,
typename MaskT,
typename VarianceT>
698 VarianceT
const &,
int const andMask) {
703 for (
int i_y = 0; i_y < img.getHeight(); ++i_y) {
704 typename MaskT::x_iterator mptr = msk.row_begin(i_y);
705 for (
typename ImageT::x_iterator
ptr = img.row_begin(i_y),
end = img.row_end(i_y);
ptr !=
end;
707 if (IsFinite()(*
ptr) && !(*mptr & andMask)) {
708 imgcp->push_back(*
ptr);
719 int oldSize = _maskPropagationThresholds.
size();
720 if (oldSize <= bit) {
723 return _maskPropagationThresholds[bit];
727 int oldSize = _maskPropagationThresholds.
size();
728 if (oldSize <= bit) {
729 int newSize = bit + 1;
730 _maskPropagationThresholds.
resize(newSize);
731 for (
int i = oldSize; i < bit; ++i) {
732 _maskPropagationThresholds[i] = 1.0;
735 _maskPropagationThresholds[bit] = threshold;
740 if (statisticsProperty.
size() == 0) {
741 statisticsProperty[
"NOTHING"] =
NOTHING;
742 statisticsProperty[
"ERRORS"] =
ERRORS;
743 statisticsProperty[
"NPOINT"] =
NPOINT;
744 statisticsProperty[
"MEAN"] =
MEAN;
745 statisticsProperty[
"STDEV"] =
STDEV;
746 statisticsProperty[
"VARIANCE"] =
VARIANCE;
747 statisticsProperty[
"MEDIAN"] =
MEDIAN;
748 statisticsProperty[
"IQRANGE"] =
IQRANGE;
749 statisticsProperty[
"MEANCLIP"] =
MEANCLIP;
750 statisticsProperty[
"STDEVCLIP"] =
STDEVCLIP;
752 statisticsProperty[
"MIN"] =
MIN;
753 statisticsProperty[
"MAX"] =
MAX;
754 statisticsProperty[
"SUM"] =
SUM;
755 statisticsProperty[
"MEANSQUARE"] =
MEANSQUARE;
756 statisticsProperty[
"ORMASK"] =
ORMASK;
757 statisticsProperty[
"NCLIPPED"] =
NCLIPPED;
758 statisticsProperty[
"NMASKED"] =
NMASKED;
760 return statisticsProperty[property];
763template <
typename ImageT,
typename MaskT,
typename VarianceT>
773 _varianceclip(NaN, NaN),
779 _weightsAreMultiplicative(false) {
780 doStatistics(img, msk, var, var, _flags, _sctrl);
785bool isEmpty(
T const &t) {
795template <
typename ImageT1,
typename ImageT2>
796void checkDimensions(ImageT1
const &image1, ImageT2
const &image2) {
797 if (image1.getDimensions() != image2.getDimensions()) {
799 (
boost::format(
"Image sizes don't match: %s vs %s") % image1.getDimensions() %
800 image2.getDimensions())
806template <
typename ImageT,
typename PixelT>
807void checkDimensions(ImageT
const &image1, MaskImposter<PixelT>
const &image2) {}
808template <
typename ImageT,
typename PixelT>
809void checkDimensions(MaskImposter<PixelT>
const &image1, ImageT
const &image2) {}
812template <
typename ImageT,
typename MaskT,
typename VarianceT,
typename WeightT>
822 _varianceclip(NaN, NaN),
828 _weightsAreMultiplicative(true) {
829 if (!isEmpty(weights)) {
832 "You must use the weights if you provide them");
837 doStatistics(img, msk, var, weights, _flags, _sctrl);
840template <
typename ImageT,
typename MaskT,
typename VarianceT,
typename WeightT>
841void Statistics::doStatistics(ImageT
const &img, MaskT
const &msk, VarianceT
const &var,
843 int const num = img.getWidth() * img.getHeight();
848 checkDimensions(img, msk);
849 checkDimensions(img, var);
851 checkDimensions(img, weights);
858 StandardReturn standard =
859 getStandard(img, msk, var, weights, flags, _weightsAreMultiplicative, _sctrl.
getAndMask(),
861 _sctrl._maskPropagationThresholds);
863 _n = std::get<0>(standard);
864 _sum = std::get<1>(standard);
865 _mean = std::get<2>(standard);
866 _variance = std::get<3>(standard);
867 _min = std::get<4>(standard);
868 _max = std::get<5>(standard);
869 _allPixelOrMask = std::get<6>(standard);
883 imgcp = makeVectorCopy<ChkFin>(img, msk, var, _sctrl.
getAndMask());
885 imgcp = makeVectorCopy<AlwaysT>(img, msk, var, _sctrl.
getAndMask());
890 _median =
Value(percentile(*imgcp, 0.5), NaN);
892 MedianQuartileReturn mq = medianAndQuartiles(*imgcp);
893 _median =
Value(std::get<0>(mq), NaN);
894 _iqrange = std::get<2>(mq) - std::get<1>(mq);
898 for (
int i_i = 0; i_i < _sctrl.
getNumIter(); ++i_i) {
899 double const center = ((i_i > 0) ? _meanclip : _median).first;
900 double const hwidth = (i_i > 0 && _n > 1)
902 : _sctrl.getNumSigmaClip() * IQ_TO_STDEV * _iqrange;
905 StandardReturn clipped = getStandard(
906 img, msk, var, weights, flags, clipinfo, _weightsAreMultiplicative,
908 _sctrl.
getWeighted(), _sctrl._maskPropagationThresholds);
910 int const nClip = std::get<0>(clipped);
911 _nClipped = _n - nClip;
912 _meanclip = std::get<2>(clipped);
913 double const varClip = std::get<3>(clipped).first;
915 _varianceclip =
Value(varClip, varianceError(varClip, nClip));
926 if (!(prop & _flags)) {
934 ret.first =
static_cast<double>(_n);
941 ret.first =
static_cast<double>(_nClipped);
948 ret.first =
static_cast<double>(_nMasked);
955 ret.first =
static_cast<double>(_sum);
963 ret.first = _mean.first;
965 ret.second = ::sqrt(_mean.second);
969 ret.first = _meanclip.first;
971 ret.second = ::sqrt(_meanclip.second);
977 ret.first = _variance.first;
979 ret.second = ::sqrt(_variance.second);
983 ret.first =
sqrt(_variance.first);
985 ret.second = 0.5 * ::sqrt(_variance.second) / ret.first;
989 ret.first = _varianceclip.first;
991 ret.second = ret.second;
995 ret.first =
sqrt(_varianceclip.first);
997 ret.second = 0.5 * ::sqrt(_varianceclip.second) / ret.first;
1002 ret.first = (_n - 1) /
static_cast<double>(_n) * _variance.first + ::pow(_mean.first, 2);
1004 ret.second = ::sqrt(2 * ::
pow(ret.first / _n, 2));
1022 ret.first = _median.first;
1028 ret.first = _iqrange;
1041 "getValue() may only be called without a parameter"
1042 " if you asked for only one statistic");
1066 _variance(NaN, NaN),
1069 _meanclip(NaN, NaN),
1070 _varianceclip(NaN, NaN),
1077 "Statistics<Mask> only supports NPOINT and SUM");
1106 return Statistics(msk, msk, msk, flags, sctrl);
1117#define STAT Statistics
1121#define INSTANTIATE_MASKEDIMAGE_STATISTICS(TYPE) \
1122 template STAT::Statistics(image::Image<TYPE> const &img, image::Mask<image::MaskPixel> const &msk, \
1123 image::Image<VPixel> const &var, int const flags, \
1124 StatisticsControl const &sctrl); \
1125 template STAT::Statistics(image::Image<TYPE> const &img, image::Mask<image::MaskPixel> const &msk, \
1126 image::Image<VPixel> const &var, image::Image<VPixel> const &weights, \
1127 int const flags, StatisticsControl const &sctrl); \
1128 template STAT::Statistics(image::Image<TYPE> const &img, image::Mask<image::MaskPixel> const &msk, \
1129 image::Image<VPixel> const &var, ImageImposter<VPixel> const &weights, \
1130 int const flags, StatisticsControl const &sctrl)
1132#define INSTANTIATE_MASKEDIMAGE_STATISTICS_NO_MASK(TYPE) \
1133 template STAT::Statistics(image::Image<TYPE> const &img, MaskImposter<image::MaskPixel> const &msk, \
1134 image::Image<VPixel> const &var, int const flags, \
1135 StatisticsControl const &sctrl); \
1136 template STAT::Statistics(image::Image<TYPE> const &img, MaskImposter<image::MaskPixel> const &msk, \
1137 image::Image<VPixel> const &var, image::Image<VPixel> const &weights, \
1138 int const flags, StatisticsControl const &sctrl)
1140#define INSTANTIATE_MASKEDIMAGE_STATISTICS_NO_VAR(TYPE) \
1141 template STAT::Statistics(image::Image<TYPE> const &img, image::Mask<image::MaskPixel> const &msk, \
1142 MaskImposter<VPixel> const &var, int const flags, \
1143 StatisticsControl const &sctrl); \
1144 template STAT::Statistics(image::Image<TYPE> const &img, image::Mask<image::MaskPixel> const &msk, \
1145 MaskImposter<VPixel> const &var, image::Image<VPixel> const &weights, \
1146 int const flags, StatisticsControl const &sctrl); \
1147 template STAT::Statistics(image::Image<TYPE> const &img, image::Mask<image::MaskPixel> const &msk, \
1148 MaskImposter<VPixel> const &var, ImageImposter<VPixel> const &weights, \
1149 int const flags, StatisticsControl const &sctrl)
1151#define INSTANTIATE_REGULARIMAGE_STATISTICS(TYPE) \
1152 template STAT::Statistics(image::Image<TYPE> const &img, MaskImposter<image::MaskPixel> const &msk, \
1153 MaskImposter<VPixel> const &var, int const flags, \
1154 StatisticsControl const &sctrl)
1156#define INSTANTIATE_VECTOR_STATISTICS(TYPE) \
1157 template STAT::Statistics(ImageImposter<TYPE> const &img, MaskImposter<image::MaskPixel> const &msk, \
1158 MaskImposter<VPixel> const &var, int const flags, \
1159 StatisticsControl const &sctrl); \
1160 template STAT::Statistics(ImageImposter<TYPE> const &img, MaskImposter<image::MaskPixel> const &msk, \
1161 MaskImposter<VPixel> const &var, ImageImposter<VPixel> const &weights, \
1162 int const flags, StatisticsControl const &sctrl)
1164#define INSTANTIATE_IMAGE_STATISTICS(T) \
1165 INSTANTIATE_MASKEDIMAGE_STATISTICS(T); \
1166 INSTANTIATE_MASKEDIMAGE_STATISTICS_NO_VAR(T); \
1167 INSTANTIATE_MASKEDIMAGE_STATISTICS_NO_MASK(T); \
1168 INSTANTIATE_REGULARIMAGE_STATISTICS(T); \
1169 INSTANTIATE_VECTOR_STATISTICS(T)
1171INSTANTIATE_IMAGE_STATISTICS(
double);
1172INSTANTIATE_IMAGE_STATISTICS(
float);
1173INSTANTIATE_IMAGE_STATISTICS(
int);
Key< Flag > const & target
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
int getWidth() const
Return the number of columns in the image.
int getHeight() const
Return the number of rows in the image.
x_iterator row_begin(int y) const
Return an x_iterator to the start of the y'th row.
x_iterator row_end(int y) const
Return an x_iterator to the end of the y'th row.
A class to represent a 2-dimensional array of pixels.
Represent a 2-dimensional array of bitmask pixels.
Pass parameters to a Statistics object.
double getMaskPropagationThreshold(int bit) const
When pixels with the given bit are rejected, we count what fraction the rejected pixels would have co...
bool getCalcErrorFromInputVariance() const noexcept
int getAndMask() const noexcept
bool getWeightedIsSet() const noexcept
void setMaskPropagationThreshold(int bit, double threshold)
void setWeighted(bool useWeights) noexcept
double getNumSigmaClip() const noexcept
bool getWeighted() const noexcept
int getNumIter() const noexcept
bool getNanSafe() const noexcept
A class to evaluate image statistics.
Value getResult(Property const prop=NOTHING) const
Return the value and error in the specified statistic (e.g.
double getError(Property const prop=NOTHING) const
Return the error in the desired property (if specified in the constructor)
Statistics(ImageT const &img, MaskT const &msk, VarianceT const &var, int const flags, StatisticsControl const &sctrl=StatisticsControl())
Constructor for Statistics object.
double getValue(Property const prop=NOTHING) const
Return the value of the desired property (if specified in the constructor)
std::pair< double, double > Value
The type used to report (value, error) for desired statistics.
Reports invalid arguments.
float VariancePixel
default type for MaskedImage variance images
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)
Property
control what is calculated
@ ORMASK
get the or-mask of all pixels used.
@ ERRORS
Include errors of requested quantities.
@ VARIANCECLIP
estimate sample N-sigma clipped variance (N set in StatisticsControl, default=3)
@ MEANSQUARE
find mean value of square of pixel values
@ MIN
estimate sample minimum
@ NCLIPPED
number of clipped points
@ NOTHING
We don't want anything.
@ STDEV
estimate sample standard deviation
@ NMASKED
number of masked points
@ STDEVCLIP
estimate sample N-sigma clipped stdev (N set in StatisticsControl, default=3)
@ VARIANCE
estimate sample variance
@ MEDIAN
estimate sample median
@ MAX
estimate sample maximum
@ SUM
find sum of pixels in the image
@ IQRANGE
estimate sample inter-quartile range
@ MEAN
estimate sample mean
@ MEANCLIP
estimate sample N-sigma clipped mean (N set in StatisticsControl, default=3)
@ NPOINT
number of sample points
Property stringToStatisticsProperty(std::string const property)
Conversion function to switch a string to a Property (see Statistics.h)
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
A base class for image defects.
afw::table::Key< double > weight