33 #include "boost/format.hpp"
52 bool operator()(T val)
const {
53 return ((val.mask() & _badPixel) == 0) ? true :
false;
62 struct CheckKnownValue {
66 bool operator()(T val)
const {
81 template <
typename CoaddT,
typename WeightPixelT,
typename isVal
idPixel>
91 if (coadd.getBBox() != weightMap.
getBBox()) {
93 (boost::format(
"coadd and weightMap parent bboxes differ: %s != %s") %
94 coadd.getBBox() % weightMap.
getBBox()).str());
103 CoaddT coaddView(coadd, overlapBBox, afwImage::PARENT,
false);
104 WeightMapT weightMapView(weightMap, overlapBBox, afwImage::PARENT,
false);
105 CoaddT imageView(image, overlapBBox, afwImage::PARENT,
false);
107 isValidPixel
const isValid(badPixelMask);
108 for (
int y = 0, endY = imageView.getHeight(); y != endY; ++y) {
109 typename CoaddT::const_x_iterator imageIter = imageView.row_begin(y);
110 typename CoaddT::const_x_iterator
const imageEndIter = imageView.row_end(y);
111 typename CoaddT::x_iterator coaddIter = coaddView.row_begin(y);
112 typename WeightMapT::x_iterator weightMapIter = weightMapView.row_begin(y);
113 for (; imageIter != imageEndIter; ++imageIter, ++coaddIter, ++weightMapIter) {
115 typename CoaddT::SinglePixel pix = *imageIter;
116 pix *=
typename CoaddT::Pixel(weight);
118 *weightMapIter += weight;
126 template <
typename CoaddPixelT,
typename WeightPixelT>
135 return addToCoaddImpl<Image, WeightPixelT, CheckKnownValue>(coadd, weightMap,
image, 0x0, weight);
138 template <
typename CoaddPixelT,
typename WeightPixelT>
150 return addToCoaddImpl<Image,WeightPixelT,CheckMask>(coadd, weightMap, maskedImage, badPixelMask, weight);
156 #define MASKEDIMAGE(IMAGEPIXEL) afwImage::MaskedImage<IMAGEPIXEL, \
157 afwImage::MaskPixel, afwImage::VariancePixel>
158 #define INSTANTIATE(COADDPIXEL, WEIGHTPIXEL) \
159 template lsst::geom::Box2I coaddUtils::addToCoadd<COADDPIXEL, WEIGHTPIXEL>( \
160 afwImage::Image<COADDPIXEL> &coadd, \
161 afwImage::Image<WEIGHTPIXEL> &weightMap, \
162 afwImage::Image<COADDPIXEL> const &image, \
166 template lsst::geom::Box2I coaddUtils::addToCoadd<COADDPIXEL, WEIGHTPIXEL>( \
167 MASKEDIMAGE(COADDPIXEL) &coadd, \
168 afwImage::Image<WEIGHTPIXEL> &weightMap, \
169 MASKEDIMAGE(COADDPIXEL) const &image, \
170 afwImage::MaskPixel const badPixelMask, \
#define INSTANTIATE(FROMSYS, TOSYS)
#define LSST_EXCEPT(type,...)
lsst::geom::Box2I getBBox(ImageOrigin origin=PARENT) const
void clip(Box2I const &other) noexcept
bool isEmpty() const noexcept
ImageT::SinglePixel badPixel(typename ImageT::Pixel bad=0)
lsst::geom::Box2I addToCoadd(lsst::afw::image::Image< CoaddPixelT > &coadd, lsst::afw::image::Image< WeightPixelT > &weightMap, lsst::afw::image::Image< CoaddPixelT > const &image, WeightPixelT weight)
add good pixels from an image to a coadd and associated weight map