13 namespace det = lsst::afw::detection;
14 namespace deblend = lsst::meas::deblender;
15 namespace geom = lsst::afw::geom;
16 namespace pexLog = lsst::pex::logging;
19 static bool span_ptr_compare(
PTR(det::Span) sp1,
PTR(det::Span) sp2) {
36 template<
typename ImagePixelT,
typename MaskPixelT,
typename VariancePixelT>
42 int S = halfsize*2 + 1;
45 xy_loc pix = img.
xy_at(halfsize,halfsize);
46 std::vector<typename xy_loc::cached_location_t> locs;
47 for (
int i=0; i<S; ++i) {
48 for (
int j=0; j<S; ++j) {
49 locs.push_back(pix.cache_location(j-halfsize, i-halfsize));
54 ImagePixelT vals[S*S];
55 for (
int y=halfsize;
y<H-halfsize; ++
y) {
56 xy_loc inpix = img.
xy_at(halfsize,
y), end = img.
xy_at(W-halfsize,
y);
58 inpix != end; ++inpix.x(), ++optr) {
59 for (
int i=0; i<SS; ++i)
60 vals[i] = inpix[locs[i]];
61 std::nth_element(vals, vals+SS/2, vals+SS);
67 for (
int y=0;
y<2*halfsize; ++
y) {
70 iy = H - 1 - (
y-halfsize);
73 for (; iptr != end; ++iptr,++optr)
76 for (
int y=halfsize;
y<H-halfsize; ++
y) {
79 for (; iptr != end; ++iptr,++optr)
84 for (; iptr != end; ++iptr,++optr)
114 template<
typename ImagePixelT,
typename MaskPixelT,
typename VariancePixelT>
121 int cx = peak.
getIx();
122 int cy = peak.
getIy();
123 int ix0 = img.
getX0();
124 int iy0 = img.
getY0();
137 for (s = 0; s < std::max(DW,DH); s += S) {
139 for (p=0; p<S; p++) {
179 for (
int i=0; i<(8*L); i++, x += dx, y += dy) {
183 if (i % (2*L) == 0) {
186 dx = ( leg % 2) * (-1 + 2*(leg/2));
188 dy = ((leg+1) % 2) * ( 1 - 2*(leg/2));
191 int px = cx + x - ix0;
192 int py = cy + y - iy0;
194 if (px < 0 || px >= iW || py < 0 || py >= iH)
197 ImagePixelT pix = (*shadowingImg)(px,py);
204 const double A = 0.3;
210 ds0 = (double(y) / double(x)) - A;
213 for (shx=1; shx<=S; shx++) {
214 int xsign = (x>0?1:-1);
216 psx = cx + x + (xsign*shx) - ix0;
217 if (psx < 0 || psx >= iW)
220 for (shy = lround(shx * ds0);
221 shy <= lround(shx * ds1); shy++) {
222 psy = cy + y + xsign*shy - iy0;
223 if (psy < 0 || psy >= iH)
225 img(psx, psy) = std::min(img(psx, psy), pix);
231 ds0 = (double(x) / double(y)) - A;
234 for (shy=1; shy<=S; shy++) {
235 int ysign = (y>0?1:-1);
236 psy = cy + y + (ysign*shy) - iy0;
237 if (psy < 0 || psy >= iH)
240 for (shx = lround(shy * ds0);
241 shx <= lround(shy * ds1); shx++) {
242 psx = cx + x + ysign*shx - ix0;
243 if (psx < 0 || psx >= iW)
245 img(psx, psy) = std::min(img(psx, psy), pix);
251 shadowingImg->assign(img);
255 static double _get_contrib_r_to_footprint(
int x,
int y,
259 SpanList
const& tspans = tfoot->
getSpans();
260 for (SpanList::const_iterator ts = tspans.begin(); ts < tspans.end(); ++ts) {
269 dx = x - sp->
getX1();
277 int dy = sp->
getY() -
y;
278 minr2 = std::min(minr2, (
double)(mindx*mindx + dy*dy));
281 return 1. / (1. + minr2);
285 template<
typename ImagePixelT,
typename MaskPixelT,
typename VariancePixelT>
291 int strayFluxOptions,
293 std::vector<bool>
const& ispsf,
294 std::vector<int>
const& pkx,
295 std::vector<int>
const& pky,
296 double clipStrayFluxFraction,
306 std::vector<PTR(det::Footprint) > strayfoot;
307 std::vector<std::vector<ImagePixelT> > straypix;
308 std::vector<std::vector<MaskPixelT> > straymask;
309 std::vector<std::vector<VariancePixelT> > strayvar;
311 int ix0 = img.
getX0();
312 int iy0 = img.
getY0();
317 for (
size_t i=0; i<tfoots.size(); ++i) {
319 straypix.push_back(std::vector<ImagePixelT>());
320 straymask.push_back(std::vector<MaskPixelT>());
321 strayvar.push_back(std::vector<VariancePixelT>());
324 bool always = (strayFluxOptions & STRAYFLUX_TO_POINT_SOURCES_ALWAYS);
326 typedef std::uint16_t itype;
329 if (strayFluxOptions & STRAYFLUX_NEAREST_FOOTPRINT) {
332 typedef std::uint16_t dtype;
336 std::vector<PTR(det::Footprint)> templist;
337 std::vector<PTR(det::Footprint)>* footlist = &tfoots;
339 if (!always && ispsf.size()) {
343 for (
size_t i=0; i<tfoots.size(); ++i) {
345 templist.push_back(empty);
347 templist.push_back(tfoots[i]);
350 footlist = &templist;
357 const SpanList& spans = foot.
getSpans();
358 for (SpanList::const_iterator s = spans.begin(); s < spans.end(); s++) {
359 int y = (*s)->getY();
360 int x0 = (*s)->getX0();
361 int x1 = (*s)->getX1();
363 tsum->row_begin(y - sumy0) + (x0 - sumx0);
366 double contrib[tfoots.size()];
368 for (
int x = x0; x <= x1; ++
x, ++tsum_it, ++in_it) {
372 if ((*tsum_it > 0) || (*in_it).image() <= 0) {
376 if (strayFluxOptions & STRAYFLUX_R_TO_FOOTPRINT) {
378 for (
size_t i=0; i<tfoots.size(); ++i) {
381 }
else if (strayFluxOptions & STRAYFLUX_NEAREST_FOOTPRINT) {
382 for (
size_t i=0; i<tfoots.size(); ++i) {
385 int i = nearest->get0(x, y);
389 for (
size_t i=0; i<tfoots.size(); ++i) {
394 contrib[i] = 1. / (1. + dx*dx + dy*dy);
400 bool ptsrcs = always;
402 for (
size_t i=0; i<tfoots.size(); ++i) {
404 if ((!ptsrcs) && ispsf.size() && ispsf[i]) {
407 if (contrib[i] == -1.0) {
408 contrib[i] = _get_contrib_r_to_footprint(x, y, tfoots[i]);
414 STRAYFLUX_TO_POINT_SOURCES_WHEN_NECESSARY)) {
418 for (
size_t i=0; i<tfoots.size(); ++i) {
419 if (contrib[i] == -1.0) {
420 contrib[i] = _get_contrib_r_to_footprint(x, y, tfoots[i]);
427 double strayclip = (clipStrayFluxFraction * csum);
429 for (
size_t i=0; i<tfoots.size(); ++i) {
431 if ((!ptsrcs) && ispsf.size() && ispsf[i]) {
436 if (contrib[i] < strayclip) {
443 for (
size_t i=0; i<tfoots.size(); ++i) {
444 if (contrib[i] == 0.) {
448 double p = (contrib[i] / csum) * (*in_it).image();
452 strayfoot[i]->addSpanInSeries(y, x, x);
453 straypix[i].push_back(p);
454 straymask[i].push_back((*in_it).mask());
455 strayvar[i].push_back((*in_it).variance());
461 for (
size_t i=0; i<tfoots.size(); ++i) {
463 strays.push_back(HeavyFootprintPtrT());
468 HeavyFootprintPtrT heavy(
new HeavyFootprint(*strayfoot[i]));
469 ndarray::Array<ImagePixelT,1,1> himg = heavy->getImageArray();
470 typename std::vector<ImagePixelT>::const_iterator spix;
471 typename std::vector<MaskPixelT>::const_iterator smask;
472 typename std::vector<VariancePixelT>::const_iterator svar;
473 typename ndarray::Array<ImagePixelT,1,1>::Iterator hpix;
474 typename ndarray::Array<MaskPixelT,1,1>::Iterator mpix;
475 typename ndarray::Array<VariancePixelT,1,1>::Iterator vpix;
477 assert((
size_t)strayfoot[i]->getNpix() == straypix[i].size());
479 for (spix = straypix[i].begin(),
480 smask = straymask[i].begin(),
481 svar = strayvar [i].begin(),
483 mpix = heavy->getMaskArray().begin(),
484 vpix = heavy->getVarianceArray().begin();
485 spix != straypix[i].end();
486 ++spix, ++smask, ++svar, ++hpix, ++mpix, ++vpix) {
491 strays.push_back(heavy);
496 template<
typename ImagePixelT,
typename MaskPixelT,
typename VariancePixelT>
506 for (
size_t i=0; i<timgs.size(); ++i) {
522 tsum->row_begin(y - sumy0) + (copyx0 - sumx0);
523 for (; in_it != inend; ++in_it, ++tsum_it) {
524 *tsum_it += std::max((ImagePixelT)0., static_cast<ImagePixelT>(*in_it));
579 template<
typename ImagePixelT,
typename MaskPixelT,
typename VariancePixelT>
580 std::vector<typename PTR(image::MaskedImage<ImagePixelT, MaskPixelT, VariancePixelT>)>
584 std::vector<ImagePtrT> timgs,
587 std::vector<bool>
const& ispsf,
588 std::vector<int>
const& pkx,
589 std::vector<int>
const& pky,
590 std::vector<std::shared_ptr<typename det::HeavyFootprint<ImagePixelT,MaskPixelT,VariancePixelT> > > & strays,
591 int strayFluxOptions,
592 double clipStrayFluxFraction
596 if (timgs.size() != tfoots.size()) {
597 throw LSST_EXCEPT(lsst::pex::exceptions::LengthError,
598 (
boost::format(
"Template images must be the same length as template footprints (%d vs %d)")
599 % timgs.size() % tfoots.size()).str());
602 for (
size_t i=0; i<timgs.size(); ++i) {
603 if (!timgs[i]->getBBox().contains(tfoots[i]->getBBox())) {
604 throw LSST_EXCEPT(lsst::pex::exceptions::RuntimeError,
605 "Template image MUST contain template footprint");
608 throw LSST_EXCEPT(lsst::pex::exceptions::RuntimeError,
609 "Image bbox MUST contain parent footprint");
617 std::vector<MaskedImagePtrT> portions;
620 "lsst.meas.deblender.apportionFlux");
621 bool findStrayFlux = (strayFluxOptions & ASSIGN_STRAYFLUX);
623 int ix0 = img.
getX0();
624 int iy0 = img.
getY0();
632 if (!tsum->getBBox().contains(foot.
getBBox())) {
633 throw LSST_EXCEPT(lsst::pex::exceptions::RuntimeError,
634 "Template sum image MUST contain parent footprint");
641 _sum_templates(timgs, tsum);
644 for (
size_t i=0; i<timgs.size(); ++i) {
648 port->setXY0(timg->getXY0());
649 portions.push_back(port);
662 timg->row_begin(y - ty0) + (copyx0 - tx0);
665 tsum->row_begin(y - sumy0) + (copyx0 - sumx0);
667 port->row_begin(y - ty0) + (copyx0 - tx0);
668 for (; tptr != tend; ++tptr, ++in_it, ++out_it, ++tsum_it) {
672 double frac = std::max((ImagePixelT)0., static_cast<ImagePixelT>(*tptr)) / (*tsum_it);
677 out_it.variance() = (*in_it).variance();
678 out_it.image() = (*in_it).image() * frac;
684 if ((ispsf.size() > 0) && (ispsf.size() != timgs.size())) {
685 throw LSST_EXCEPT(lsst::pex::exceptions::LengthError,
686 (
boost::format(
"'ispsf' must be the same length as templates (%d vs %d)")
687 % ispsf.size() % timgs.size()).str());
689 if ((pkx.size() != timgs.size()) || (pky.size() != timgs.size())) {
690 throw LSST_EXCEPT(lsst::pex::exceptions::LengthError,
691 (
boost::format(
"'pkx' and 'pky' must be the same length as templates (%d,%d vs %d)")
692 % pkx.size() % pky.size() % timgs.size()).str());
694 _find_stray_flux(foot, tsum, img, strayFluxOptions, tfoots,
695 ispsf, pkx, pky, clipStrayFluxFraction, strays);
717 int cx,
int cy,
bool forward=
true)
728 return _real == other;
731 return _real != other;
734 return _real <= other;
736 bool operator<(
const SpanList::const_iterator & other) {
737 return _real < other;
740 return _real >= other;
742 bool operator>(
const SpanList::const_iterator & other) {
743 return _real > other;
752 return !(*
this == other);
779 return (*_real)->getX0() -
_cx;
781 return _cx - (*_real)->getX1();
786 return (*_real)->getX1() -
_cx;
788 return _cx - (*_real)->getX0();
792 return std::abs((*_real)->getY() -
_cy);
795 return (*_real)->getX0();
798 return (*_real)->getX1();
801 return (*_real)->getY();
863 template<
typename ImagePixelT,
typename MaskPixelT,
typename VariancePixelT>
865 deblend::BaselineUtils<ImagePixelT,MaskPixelT,VariancePixelT>::
873 const SpanList spans = foot.getSpans();
874 assert(foot.isNormalized());
877 "lsst.meas.deblender.symmetrizeFootprint");
880 PTR(det::Span) target(
new det::Span(cy, cx, cx));
881 SpanList::const_iterator peakspan =
882 std::upper_bound(spans.begin(), spans.end(), target, span_ptr_compare);
888 if (peakspan == spans.begin()) {
890 if (!sp->contains(cx, cy)) {
892 "Failed to find span containing (%i,%i): before the beginning of this footprint", cx, cy);
899 if (!sp->contains(cx, cy)) {
902 if (!sp->contains(cx, cy)) {
904 log.warnf(
"Failed to find span containing (%i,%i): nearest is %i, [%i,%i]. "
905 "Footprint bbox is [%i,%i],[%i,%i]",
906 cx, cy, sp->getY(), sp->getX0(), sp->getX1(),
912 log.debugf(
"Span containing (%i,%i): (x=[%i,%i], y=%i)",
913 cx, cy, sp->getX0(), sp->getX1(), sp->getY());
952 int fdxlo = fwd.
dxlo();
953 int bdxlo = back.
dxlo();
960 for (fend = fwd; fend.
notDone(); ++fend) {
964 for (bend = back; bend.
notDone(); ++bend) {
969 log.debugf(
"dy=%i, fy=%i, fx=[%i, %i], by=%i, fx=[%i, %i], fdx=%i, bdx=%i",
970 dy, fy, fwd.
x0(), fwd.
x1(), by, back.
x0(), back.
x1(),
975 log.debugf(
"Advancing forward.");
979 while ((fwd != fend) && (fwd.
dxhi() < bdxlo)) {
982 log.debugf(
"Reached fend");
984 log.debugf(
"Advanced to forward span %i, [%i, %i]",
985 fy, fwd.
x0(), fwd.
x1());
988 }
else if (fdxlo > bdxlo) {
989 log.debugf(
"Advancing backward.");
993 while ((back != bend) && (back.
dxhi() < fdxlo)) {
996 log.debugf(
"Reached bend");
998 log.debugf(
"Advanced to backward span %i, [%i, %i]",
999 by, back.
x0(), back.
x1());
1004 if ((back == bend) || (fwd == fend)) {
1008 log.debugf(
"Reached bend");
1011 log.debugf(
"Reached fend");
1020 int dxlo = std::max(fwd.
dxlo(), back.
dxlo());
1021 int dxhi = std::min(fwd.
dxhi(), back.
dxhi());
1023 log.debugf(
"Adding span fwd %i, [%i, %i], back %i, [%i, %i]",
1024 fy, cx+dxlo, cx+dxhi, by, cx-dxhi, cx-dxlo);
1025 sfoot->addSpan(fy, cx + dxlo, cx + dxhi);
1026 sfoot->addSpan(by, cx - dxhi, cx - dxlo);
1033 log.debugf(
"Stepped to fend");
1035 log.debugf(
"Stepped forward to span %i, [%i, %i]",
1036 fwd.
y(), fwd.
x0(), fwd.
x1());
1041 log.debugf(
"Stepped to bend");
1043 log.debugf(
"Stepped backward to span %i, [%i, %i]",
1044 back.
y(), back.
x0(), back.
x1());
1048 if ((back == bend) || (fwd == fend)) {
1051 log.debugf(
"Reached bend");
1054 log.debugf(
"Reached fend");
1079 template<
typename ImagePixelT,
typename MaskPixelT,
typename VariancePixelT>
1080 std::pair<typename PTR(lsst::afw::image::Image<ImagePixelT>),
1090 bool* patchedEdges) {
1095 *patchedEdges =
false;
1097 int cx = peak.
getIx();
1098 int cy = peak.
getIy();
1101 "lsst.meas.deblender.symmetricFootprint");
1104 throw LSST_EXCEPT(lsst::pex::exceptions::LengthError,
"Image too small for footprint");
1109 return std::pair<ImagePtrT, FootprintPtrT>(
ImagePtrT(), sfoot);
1113 throw LSST_EXCEPT(lsst::pex::exceptions::LengthError,
1114 "Image too small for symmetrized footprint");
1116 const SpanList spans = sfoot->getSpans();
1119 bool touchesEdge =
false;
1121 log.
debugf(
"Checking footprint for EDGE bits");
1124 MaskPixelT edgebit = mask->getPlaneBitMask(
"EDGE");
1125 for (SpanList::const_iterator fwd=spans.begin();
1126 fwd != spans.end(); ++fwd) {
1127 int x0 = (*fwd)->getX0();
1128 int x1 = (*fwd)->getX1();
1130 mask->x_at(x0 - mask->getX0(), (*fwd)->getY() - mask->getY0());
1131 for (
int x=x0; x<=x1; ++
x, ++xiter) {
1132 if ((*xiter) & edgebit) {
1141 log.
debugf(
"Footprint includes an EDGE pixel.");
1149 SpanList::const_iterator fwd = spans.begin();
1150 SpanList::const_iterator back = spans.end()-1;
1154 for (; fwd <= back; fwd++, back--) {
1155 int fy = (*fwd)->getY();
1156 int by = (*back)->getY();
1158 for (
int fx=(*fwd)->getX0(), bx=(*back)->getX1();
1159 fx <= (*fwd)->getX1();
1173 ImagePixelT pixf = theimg->get0(fx, fy);
1174 ImagePixelT pixb = theimg->get0(bx, by);
1175 ImagePixelT pix = std::min(pixf, pixb);
1177 pix = std::max(pix, static_cast<ImagePixelT>(0));
1179 targetimg->set0(fx, fy, pix);
1180 targetimg->set0(bx, by, pix);
1197 log.
debugf(
"Footprint touches EDGE: start bbox [%i,%i],[%i,%i]",
1200 const SpanList ospans = foot.
getSpans();
1201 for (fwd = ospans.begin(); fwd != ospans.end(); ++fwd) {
1202 int y = (*fwd)->getY();
1203 int x = (*fwd)->getX0();
1205 int ym = cy + (cy -
y);
1206 int xm = cx + (cx -
x);
1210 x = (*fwd)->getX1();
1216 log.
debugf(
"Footprint touches EDGE: grown bbox [%i,%i],[%i,%i]",
1223 log.
debugf(
"Symmetric footprint spans:");
1224 const SpanList sspans = sfoot->getSpans();
1225 for (fwd = sspans.begin(); fwd != sspans.end(); ++fwd) {
1226 log.
debugf(
" %s", (*fwd)->toString().c_str());
1231 for (fwd = ospans.begin(); fwd != ospans.end(); ++fwd) {
1232 int y = (*fwd)->getY();
1233 int x0 = (*fwd)->getX0();
1234 int x1 = (*fwd)->getX1();
1236 int ym = cy + (cy -
y);
1237 int xm0 = cx + (cx -
x0);
1238 int xm1 = cx + (cx - x1);
1249 x0 = cx + (cx - (imbb.
getMinX() - 1));
1252 x1 = cx + (cx - (imbb.
getMaxX() + 1));
1254 log.
debugf(
"Span y=%i, x=[%i,%i] has mirror (%i,[%i,%i]) out-of-bounds; clipped to %i,[%i,%i]",
1255 y, (*fwd)->getX0(), (*fwd)->getX1(), ym, xm1, xm0,
y,
x0, x1);
1259 targetimg2->x_at(x0 - targetimg2->getX0(), y - targetimg2->getY0());
1260 for (
int x=x0; x<=x1; ++
x, ++outiter, ++initer) {
1261 *outiter = initer.
image();
1263 sfoot->addSpan(y, x0, x1);
1266 targetimg = targetimg2;
1269 *patchedEdges = touchesEdge;
1270 return std::pair<ImagePtrT, FootprintPtrT>(targetimg, sfoot);
1277 template<
typename ImagePixelT,
typename MaskPixelT,
typename VariancePixelT>
1282 ImagePixelT thresh) {
1286 "lsst.meas.deblender.hasSignificantFluxAtEdge");
1293 const SpanList spans = edge->getSpans();
1294 for (SpanList::const_iterator sp = spans.
begin(); sp != spans.
end(); ++sp) {
1295 int const y = (*sp)->getY();
1296 int const x0 = (*sp)->getX0();
1297 int const x1 = (*sp)->getX1();
1300 for (xiter = img->x_at(x0 - img->getX0(), y - img->getY0()), x=x0; x<=x1; ++
x, ++xiter) {
1301 if (*xiter >= thresh) {
1313 template<
typename ImagePixelT,
typename MaskPixelT,
typename VariancePixelT>
1314 std::shared_ptr<det::Footprint>
1318 ImagePixelT thresh) {
1320 "lsst.meas.deblender.getSignificantEdgePixels");
1326 int const x0 = img->getX0(),
y0 = img->getY0();
1328 for (det::Footprint::SpanList::const_iterator ss = edges->getSpans().begin();
1329 ss != edges->getSpans().end(); ++ss) {
1331 int const y = span.
getY();
1332 int x = span.
getX0();
1334 bool onSpan =
false;
1337 if (*iter >= thresh) {
1340 }
else if (onSpan) {
1342 significant->addSpanInSeries(y, xSpan, x - 1);
1346 significant->addSpanInSeries(y, xSpan, span.
getX1());
static std::shared_ptr< lsst::afw::detection::Footprint > getSignificantEdgePixels(ImagePtrT, std::shared_ptr< lsst::afw::detection::Footprint >, ImagePixelT threshold)
x_iterator row_begin(int y) const
Return an x_iterator to the start of the image.
Ref< MaskPixelT >::type mask()
Return (a reference to) the mask part of the Pixel pointed at by the iterator.
void debugf(const char *fmt,...)
Extent2I const getDimensions() const
bool operator>=(const SpanList::const_iterator &other)
static void medianFilter(ImageT const &img, ImageT &outimg, int halfsize)
bool contains(Point2I const &point) const
Return true if the box contains the point.
int getX0() const
Return the starting x-value.
RelativeSpanIterator(SpanList::const_iterator const &real, SpanList const &arr, int cx, int cy, bool forward=true)
A range of pixels within one row of an Image.
void include(Point2I const &point)
Expand this to ensure that this->contains(point).
bool operator<(const SpanList::const_iterator &other)
static Log & getDefaultLog()
_const_view_t::x_iterator const_x_iterator
A const iterator for traversing the pixels in a row.
bool operator==(RelativeSpanIterator &other)
_view_t::x_iterator x_iterator
An iterator for traversing the pixels in a row.
bool operator==(const SpanList::const_iterator &other)
geom::Box2I getBBox(ImageOrigin const origin=PARENT) const
ImagePtr getImage(bool const noThrow=false) const
Return a (Ptr to) the MaskedImage's image.
MaskPixelT mask() const
Return the mask part of a Pixel.
boost::shared_ptr< lsst::afw::detection::Footprint > FootprintPtrT
a place to record messages and descriptions of the state of processing.
boost::shared_ptr< lsst::afw::image::Mask< MaskPixelT > > MaskPtrT
static std::pair< ImagePtrT, FootprintPtrT > buildSymmetricTemplate(MaskedImageT const &img, lsst::afw::detection::Footprint const &foot, lsst::afw::detection::PeakRecord const &pk, double sigma1, bool minZero, bool patchEdges, bool *patchedEdges)
An integer coordinate rectangle.
table::Key< table::Array< Kernel::Pixel > > image
An iterator to the MaskedImage.
boost::shared_ptr< lsst::afw::image::Image< ImagePixelT > > ImagePtrT
Iterator begin() const
Return an iterator to the first pixel in the Span.
x_iterator x_at(int x, int y) const
Return an x_iterator at the point (x, y)
int getIy() const
Convenience accessors for the keys in the minimal schema.
int getY() const
Return the y-value.
x_iterator row_end(int y) const
Return an x_iterator to the end of the y'th row.
static void _sum_templates(std::vector< ImagePtrT > timgs, ImagePtrT tsum)
MaskPtr getMask(bool const noThrow=false) const
Return a (Ptr to) the MaskedImage's mask.
A class to manipulate images, masks, and variance as a single object.
SpanList::const_iterator _real
det::Footprint::SpanList SpanList
boost::shared_ptr< lsst::afw::detection::HeavyFootprint< ImagePixelT > MaskPixelT, VariancePixelT > HeavyFootprintPtrT
int getIx() const
Convenience accessors for the keys in the minimal schema.
int getHeight() const
Return the number of rows in the image.
def deblend
Deblend a single footprint in a maskedImage.
bool operator<=(const SpanList::const_iterator &other)
Ref< ImagePixelT >::type image()
Return (a reference to) the image part of the Pixel pointed at by the iterator.
static void makeMonotonic(ImageT &img, lsst::afw::detection::PeakRecord const &pk)
#define LSST_EXCEPT(type,...)
SpanList::const_iterator _end
afw::table::Key< double > sigma1
boost::shared_ptr< lsst::afw::image::MaskedImage< ImagePixelT > MaskPixelT, VariancePixelT > MaskedImagePtrT
lsst::afw::detection::Footprint Footprint
bool operator>(const SpanList::const_iterator &other)
bool operator!=(RelativeSpanIterator &other)
xy_locator xy_at(int x, int y) const
void clip(Box2I const &other)
Shrink this to ensure that other.contains(*this).
x_iterator row_begin(int y) const
int getX1() const
Return the ending x-value.
Include files required for standard LSST Exception handling.
bool operator!=(const SpanList::const_iterator &other)
RelativeSpanIterator operator++()
RelativeSpanIterator operator++(int dummy)
Record class that represents a peak in a Footprint.
void nearestFootprint(std::vector< boost::shared_ptr< Footprint >> const &foots, lsst::afw::image::Image< std::uint16_t >::Ptr argmin, lsst::afw::image::Image< std::uint16_t >::Ptr dist)
_view_t::xy_locator xy_locator
An xy_locator.
static bool hasSignificantFluxAtEdge(ImagePtrT, std::shared_ptr< lsst::afw::detection::Footprint >, ImagePixelT threshold)
int getWidth() const
Return the number of columns in the image.
static void _find_stray_flux(lsst::afw::detection::Footprint const &foot, ImagePtrT tsum, MaskedImageT const &img, int strayFluxOptions, std::vector< std::shared_ptr< lsst::afw::detection::Footprint > > tfoots, std::vector< bool > const &ispsf, std::vector< int > const &pkx, std::vector< int > const &pky, double clipStrayFluxFraction, std::vector< std::shared_ptr< typename lsst::afw::detection::HeavyFootprint< ImagePixelT, MaskPixelT, VariancePixelT > > > &strays)
Schema getSchema() const
Return the schema associated with the catalog's table.
Iterator end() const
Return an iterator to one past the last pixel in the Span.
void copyWithinFootprint(Footprint const &foot, boost::shared_ptr< ImageOrMaskedImageT > const input, boost::shared_ptr< ImageOrMaskedImageT > output)
A const locator for the MaskedImage.