31 namespace pexExcept = lsst::pex::exceptions;
38 template<
typename ImageT>
41 lsst::afw::math::
Property const flags
44 return binImage(in, binsize, binsize, flags);
47 template<
typename ImageT>
51 lsst::afw::math::
Property const flags
56 (
boost::format(
"Only afwMath::MEAN is supported, saw 0x%x") % flags).str());
58 if (binX <= 0 || binY <= 0) {
60 (
boost::format(
"Binning must be >= 0, saw %dx%d") % binX % binY).str());
63 int const outWidth = in.getWidth()/binX;
64 int const outHeight = in.getHeight()/binY;
66 typename ImageT::Ptr out =
typename ImageT::Ptr(
69 out->setXY0(in.getXY0());
70 *out =
typename ImageT::SinglePixel(0);
72 for (
int oy = 0, iy = 0; oy < out->getHeight(); ++oy) {
73 for (
int i = 0; i != binY; ++i, ++iy) {
74 typename ImageT::x_iterator optr = out->row_begin(oy);
75 for (
typename ImageT::x_iterator iptr = in.row_begin(iy), iend = iptr + binX*outWidth;
77 typename ImageT::SinglePixel
val = *iptr; ++iptr;
78 for (
int j = 1; j != binX; ++j, ++iptr) {
84 for (
typename ImageT::x_iterator ptr = out->row_begin(oy), end = out->row_end(oy); ptr != end; ++ptr) {
97 #define INSTANTIATE(TYPE) \
98 template afwImage::Image<TYPE>::Ptr \
99 binImage(afwImage::Image<TYPE> const&, int, lsst::afw::math::Property const); \
100 template afwImage::Image<TYPE>::Ptr \
101 binImage(afwImage::Image<TYPE> const&, int, int, lsst::afw::math::Property const); \
102 template afwImage::MaskedImage<TYPE>::Ptr \
103 binImage(afwImage::MaskedImage<TYPE> const&, int, lsst::afw::math::Property const); \
104 template afwImage::MaskedImage<TYPE>::Ptr \
105 binImage(afwImage::MaskedImage<TYPE> const&, int, int, lsst::afw::math::Property const); \
boost::shared_ptr< ImageT > binImage(ImageT const &inImage, int const binX, int const binY, lsst::afw::math::Property const flags=lsst::afw::math::MEAN)
Include files required for standard LSST Exception handling.
#define INSTANTIATE(MATCH)
table::Key< table::Array< Kernel::Pixel > > image
#define LSST_EXCEPT(type,...)
Property
control what is calculated