LSSTApplications  10.0-2-g4f67435,11.0.rc2+1,11.0.rc2+12,11.0.rc2+3,11.0.rc2+4,11.0.rc2+5,11.0.rc2+6,11.0.rc2+7,11.0.rc2+8
LSSTDataManagementBasePackage
setCoaddEdgeBits.cc
Go to the documentation of this file.
1 // -*- LSST-C++ -*-
2 
3 /*
4  * LSST Data Management System
5  * Copyright 2008, 2009, 2010 LSST Corporation.
6  *
7  * This product includes software developed by the
8  * LSST Project (http://www.lsst.org/).
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the LSST License Statement and
21  * the GNU General Public License along with this program. If not,
22  * see <http://www.lsstcorp.org/LegalNotices/>.
23  */
24 
30 #include "boost/format.hpp"
31 
32 #include "lsst/pex/exceptions.h"
34 
35 namespace pexExcept = lsst::pex::exceptions;
36 namespace afwImage = lsst::afw::image;
37 namespace coaddUtils = lsst::coadd::utils;
38 
39 template<typename WeightPixelT>
41  // spell out lsst:afw::image to make Doxygen happy
44 ) {
46  typedef typename afwImage::Image<WeightPixelT>::const_x_iterator WeightMapConstXIter;
47 
48  if (coaddMask.getDimensions() != weightMap.getDimensions()) {
49  throw LSST_EXCEPT(pexExcept::InvalidParameterError,
50  (boost::format("coaddMask and weightMap dimensions differ: %dx%d != %dx%d") %
51  coaddMask.getWidth() % coaddMask.getHeight() % weightMap.getWidth() % weightMap.getHeight()
52  ).str());
53  }
54 
56 
57  // Set the pixels row by row, to avoid repeated checks for end-of-row
58  for (int y = 0, endY = weightMap.getHeight(); y != endY; ++y) {
59  WeightMapConstXIter weightMapPtr = weightMap.row_begin(y);
60  WeightMapConstXIter const weightMapEndPtr = weightMap.row_end(y);
61  MaskXIter coaddMaskPtr = coaddMask.row_begin(y);
62  for (; weightMapPtr != weightMapEndPtr; ++weightMapPtr, ++coaddMaskPtr) {
63  if (*weightMapPtr == 0) {
64  (*coaddMaskPtr) = (*coaddMaskPtr) | edgeMask;
65  }
66  }
67  }
68 }
69 
70 //
71 // Explicit instantiations
72 //
74 #define INSTANTIATE(WEIGHTPIXEL) \
75  template void coaddUtils::setCoaddEdgeBits<WEIGHTPIXEL>( \
76  afwImage::Mask<afwImage::MaskPixel> &coaddMask, \
77  afwImage::Image<WEIGHTPIXEL> const &weightMap \
78  );
79 
80 INSTANTIATE(double);
81 INSTANTIATE(float);
82 INSTANTIATE(int);
83 INSTANTIATE(boost::uint16_t);
int y
boost::uint16_t MaskPixel
x_iterator row_begin(int y) const
Definition: Image.h:319
x_iterator row_end(int y) const
Return an x_iterator to the end of the y&#39;th row.
Definition: Image.h:324
void setCoaddEdgeBits(lsst::afw::image::Mask< lsst::afw::image::MaskPixel > &coaddMask, lsst::afw::image::Image< WeightPixelT > const &weightMap)
set edge bits of coadd mask based on weight map
table::Key< table::Array< Kernel::Pixel > > image
Definition: FixedKernel.cc:117
int getWidth() const
Return the number of columns in the image.
Definition: Image.h:237
static MaskPixelT getPlaneBitMask(const std::vector< std::string > &names)
Return the bitmask corresponding to a vector of plane names OR&#39;d together.
Definition: Mask.cc:860
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
#define INSTANTIATE(T)
int getHeight() const
Return the number of rows in the image.
Definition: Image.h:239
geom::Extent2I getDimensions() const
Return the image&#39;s size; useful for passing to constructors.
Definition: Image.h:298
A class to represent a 2-dimensional array of pixels.
Definition: PSF.h:43
Include files required for standard LSST Exception handling.