38template <
typename ImageT>
40 return binImage(in, binsize, binsize, flags);
43template <
typename ImageT>
48 (boost::format(
"Only afwMath::MEAN is supported, saw 0x%x") % flags).
str());
50 if (binX <= 0 || binY <= 0) {
52 (boost::format(
"Binning must be >= 0, saw %dx%d") % binX % binY).
str());
55 int const outWidth = in.getWidth() / binX;
56 int const outHeight = in.getHeight() / binY;
60 out->setXY0(in.getXY0());
61 *out =
typename ImageT::SinglePixel(0);
63 for (
int oy = 0, iy = 0; oy < out->getHeight(); ++oy) {
64 for (
int i = 0; i != binY; ++i, ++iy) {
65 typename ImageT::x_iterator optr = out->row_begin(oy);
66 for (
typename ImageT::x_iterator iptr = in.row_begin(iy), iend = iptr + binX * outWidth;
68 typename ImageT::SinglePixel val = *iptr;
70 for (
int j = 1; j != binX; ++j, ++iptr) {
77 for (
typename ImageT::x_iterator ptr = out->row_begin(oy),
end = out->row_end(oy); ptr !=
end;
90#define INSTANTIATE(TYPE) \
91 template std::shared_ptr<image::Image<TYPE>> binImage(image::Image<TYPE> const&, int, \
92 lsst::afw::math::Property const); \
93 template std::shared_ptr<image::Image<TYPE>> binImage(image::Image<TYPE> const&, int, int, \
94 lsst::afw::math::Property const); \
95 template std::shared_ptr<image::MaskedImage<TYPE>> binImage(image::MaskedImage<TYPE> const&, int, \
96 lsst::afw::math::Property const); \
97 template std::shared_ptr<image::MaskedImage<TYPE>> binImage(image::MaskedImage<TYPE> const&, int, int, \
98 lsst::afw::math::Property const);
#define INSTANTIATE(FROMSYS, TOSYS)
#define LSST_EXCEPT(type,...)
Property
control what is calculated
@ MEAN
estimate sample mean
std::shared_ptr< ImageT > binImage(ImageT const &inImage, int const binX, int const binY, lsst::afw::math::Property const flags=lsst::afw::math::MEAN)
A base class for image defects.