32 #include "boost/format.hpp"
38 namespace pexExcept = lsst::pex::exceptions;
39 namespace afwGeom = lsst::afw::geom;
41 namespace coaddUtils = lsst::coadd::utils;
51 bool operator()(T
val)
const {
52 return ((val.mask() & _badPixel) == 0) ?
true :
false;
61 struct CheckKnownValue {
65 bool operator()(T val)
const {
80 template <
typename CoaddT,
typename WeightPixelT,
typename isVal
idPixel>
90 if (coadd.getBBox() != weightMap.
getBBox()) {
92 (
boost::format(
"coadd and weightMap parent bboxes differ: %s != %s") %
93 coadd.getBBox() % weightMap.
getBBox()).str());
97 overlapBBox.
clip(image.getBBox());
106 isValidPixel
const isValid(badPixelMask);
107 for (
int y = 0, endY = imageView.getHeight();
y != endY; ++
y) {
108 typename CoaddT::const_x_iterator imageIter = imageView.row_begin(
y);
109 typename CoaddT::const_x_iterator
const imageEndIter = imageView.row_end(
y);
110 typename CoaddT::x_iterator coaddIter = coaddView.row_begin(
y);
111 typename WeightMapT::x_iterator weightMapIter = weightMapView.row_begin(
y);
112 for (; imageIter != imageEndIter; ++imageIter, ++coaddIter, ++weightMapIter) {
113 if (isValid(imageIter)) {
114 typename CoaddT::SinglePixel pix = *imageIter;
115 pix *=
typename CoaddT::Pixel(weight);
125 template <
typename CoaddPixelT,
typename WeightPixelT>
134 return addToCoaddImpl<Image, WeightPixelT, CheckKnownValue>(coadd, weightMap,
image, 0x0,
weight);
137 template <
typename CoaddPixelT,
typename WeightPixelT>
149 return addToCoaddImpl<Image,WeightPixelT,CheckMask>(coadd, weightMap, maskedImage, badPixelMask,
weight);
155 #define MASKEDIMAGE(IMAGEPIXEL) afwImage::MaskedImage<IMAGEPIXEL, \
156 afwImage::MaskPixel, afwImage::VariancePixel>
157 #define INSTANTIATE(COADDPIXEL, WEIGHTPIXEL) \
158 template lsst::afw::geom::Box2I coaddUtils::addToCoadd<COADDPIXEL, WEIGHTPIXEL>( \
159 afwImage::Image<COADDPIXEL> &coadd, \
160 afwImage::Image<WEIGHTPIXEL> &weightMap, \
161 afwImage::Image<COADDPIXEL> const &image, \
165 template lsst::afw::geom::Box2I coaddUtils::addToCoadd<COADDPIXEL, WEIGHTPIXEL>( \
166 MASKEDIMAGE(COADDPIXEL) &coadd, \
167 afwImage::Image<WEIGHTPIXEL> &weightMap, \
168 MASKEDIMAGE(COADDPIXEL) const &image, \
169 afwImage::MaskPixel const badPixelMask, \
An include file to include the header files for lsst::afw::geom.
tbl::Key< double > weight
Include files required for standard LSST Exception handling.
boost::uint16_t MaskPixel
#define INSTANTIATE(MATCH)
geom::Box2I getBBox(ImageOrigin origin=PARENT) const
An integer coordinate rectangle.
table::Key< table::Array< Kernel::Pixel > > image
A class to manipulate images, masks, and variance as a single object.
bool isEmpty() const
Return true if the box contains no points.
#define LSST_EXCEPT(type,...)
lsst::afw::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
void clip(Box2I const &other)
Shrink this to ensure that other.contains(*this).
float VariancePixel
! default type for Masks and MaskedImage Masks
A class to represent a 2-dimensional array of pixels.