37 template <
typename ImageT>
39 return binImage(in, binsize, binsize, flags);
42 template <
typename ImageT>
47 (boost::format(
"Only afwMath::MEAN is supported, saw 0x%x") % flags).str());
49 if (binX <= 0 || binY <= 0) {
51 (boost::format(
"Binning must be >= 0, saw %dx%d") % binX % binY).str());
54 int const outWidth = in.getWidth() / binX;
55 int const outHeight = in.getHeight() / binY;
59 out->setXY0(in.getXY0());
60 *out =
typename ImageT::SinglePixel(0);
62 for (
int oy = 0, iy = 0; oy < out->getHeight(); ++oy) {
63 for (
int i = 0; i != binY; ++i, ++iy) {
64 typename ImageT::x_iterator optr = out->row_begin(oy);
65 for (
typename ImageT::x_iterator iptr = in.row_begin(iy), iend = iptr + binX * outWidth;
67 typename ImageT::SinglePixel val = *iptr;
69 for (
int j = 1; j != binX; ++j, ++iptr) {
76 for (
typename ImageT::x_iterator ptr = out->row_begin(oy),
end = out->row_end(oy); ptr !=
end;
89 #define INSTANTIATE(TYPE) \
90 template std::shared_ptr<image::Image<TYPE>> binImage(image::Image<TYPE> const&, int, \
91 lsst::afw::math::Property const); \
92 template std::shared_ptr<image::Image<TYPE>> binImage(image::Image<TYPE> const&, int, int, \
93 lsst::afw::math::Property const); \
94 template std::shared_ptr<image::MaskedImage<TYPE>> binImage(image::MaskedImage<TYPE> const&, int, \
95 lsst::afw::math::Property const); \
96 template std::shared_ptr<image::MaskedImage<TYPE>> binImage(image::MaskedImage<TYPE> const&, int, int, \
97 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.