6 #include "boost/format.hpp"
12 namespace lsst {
namespace afw {
namespace display {
15 template <
typename ImageT>
18 explicit SetPixels(ImageT
const& img
19 ) : detection::FootprintFunctor<ImageT>(img),
_value(0) {}
21 void setValue(
float value) {
_value = value; }
24 void operator()(
typename ImageT::xy_locator loc,
35 template<
typename ImageT>
45 int const x0 = rim.getX0(),
y0 = rim.getY0();
47 if (width != gim.getWidth() ||
height != gim.getHeight() || x0 != gim.getX0() ||
y0 != gim.getY0()) {
48 throw LSST_EXCEPT(pex::exceptions::InvalidParameterError,
49 str(
boost::format(
"R image has different size/origin from G image "
50 "(%dx%d+%d+%d v. %dx%d+%d+%d") %
52 gim.getWidth() % gim.getHeight() % gim.getX0() % gim.getY0()));
55 if (width != bim.getWidth() ||
height != bim.getHeight() || x0 != bim.getX0() ||
y0 != bim.getY0()) {
56 throw LSST_EXCEPT(pex::exceptions::InvalidParameterError,
57 str(
boost::format(
"R image has different size/origin from B image "
58 "(%dx%d+%d+%d v. %dx%d+%d+%d") %
60 bim.getWidth() % bim.getHeight() % bim.getX0() % bim.getY0()));
66 SetPixels<typename ImageT::Image>
67 setR(*rim.getImage()),
68 setG(*gim.getImage()),
69 setB(*bim.getImage());
81 PTR(FootprintList)
feet = sat.getFootprints();
82 for (FootprintList::const_iterator ptr =
feet->begin(), end =
feet->end(); ptr != end; ++ptr) {
86 double sumR = 0, sumG = 0, sumB = 0;
87 double maxR = 0, maxG = 0, maxB = 0;
89 for (detection::Footprint::SpanList::const_iterator sptr = bigFoot->getSpans().begin(),
90 send = bigFoot->getSpans().end(); sptr != send; ++sptr) {
91 PTR(detection::Span)
const span = *sptr;
93 int const y = span->getY() -
y0;
94 if (y < 0 || y >=
height) {
97 int sx0 = span->getX0() -
x0;
101 int sx1 = span->getX1() -
x0;
106 for (
typename ImageT::iterator
107 rptr = rim.at(sx0, y),
108 rend = rim.at(sx1 + 1, y),
109 gptr = gim.at(sx0, y),
110 bptr = bim.at(sx0, y); rptr != rend; ++rptr, ++gptr, ++bptr) {
111 if (!((rptr.mask() | gptr.mask() | bptr.mask()) & SAT)) {
112 float val = rptr.image();
134 float R = 0, G = 0, B = 0;
135 if (sumR + sumB + sumG > 0) {
160 setR.setValue(R); setR.apply(*foot);
161 setG.setValue(G); setG.apply(*foot);
162 setB.setValue(B); setB.apply(*foot);
172 float saturatedPixelValue
for(FootprintList::const_iterator ptr=feet->begin(), end=feet->end();ptr!=end;++ptr)
boost::shared_ptr< FootprintList > feet
boost::uint16_t MaskPixel
Use (pixels & (given mask))
A Threshold is used to pass a threshold value to detection algorithms.
boost::shared_ptr< Footprint > growFootprint(Footprint const &foot, int nGrow, bool isotropic=true)
void ImageT ImageT int float saturatedPixelValue int const width
An include file to include the header files for lsst::afw::detection.
afw::image::MaskPixel const SAT
A class to manipulate images, masks, and variance as a single object.
detection::FootprintSet::FootprintList FootprintList
void ImageT ImageT int float saturatedPixelValue int const height
#define LSST_EXCEPT(type,...)
void ImageT ImageT int float saturatedPixelValue
detection::Threshold const satThresh(SAT, detection::Threshold::BITMASK)
Implementation of the Class MaskedImage.
template void replaceSaturatedPixels(image::MaskedImage< float > &rim, image::MaskedImage< float > &gim, image::MaskedImage< float > &bim, int borderWidth, float saturatedPixelValue)
SetPixels< typename ImageT::Image > setR * rim()), setG(*gim.getImage()), setB(*bim.getImage()
void ImageT ImageT int borderWidth