7 #include <boost/math/special_functions/round.hpp>
9 using boost::math::iround;
12 namespace det = lsst::afw::detection;
13 namespace deblend = lsst::meas::deblender;
14 namespace geom = lsst::afw::geom;
15 namespace pexLog = lsst::pex::logging;
18 static bool span_ptr_compare(
PTR(det::Span) sp1,
PTR(det::Span) sp2) {
35 template<
typename ImagePixelT,
typename MaskPixelT,
typename VariancePixelT>
41 int S = halfsize*2 + 1;
44 xy_loc pix = img.
xy_at(halfsize,halfsize);
45 std::vector<typename xy_loc::cached_location_t> locs;
46 for (
int i=0; i<S; ++i) {
47 for (
int j=0; j<S; ++j) {
48 locs.push_back(pix.cache_location(j-halfsize, i-halfsize));
53 ImagePixelT vals[S*S];
54 for (
int y=halfsize;
y<H-halfsize; ++
y) {
55 xy_loc inpix = img.
xy_at(halfsize,
y), end = img.
xy_at(W-halfsize,
y);
57 inpix != end; ++inpix.x(), ++optr) {
58 for (
int i=0; i<SS; ++i)
59 vals[i] = inpix[locs[i]].
image();
60 std::nth_element(vals, vals+SS/2, vals+SS);
61 optr.image() = vals[SS/2];
62 optr.mask() = inpix.mask();
63 optr.variance() = inpix.variance();
68 for (
int y=0;
y<2*halfsize; ++
y) {
71 iy = H - 1 - (
y-halfsize);
74 for (; iptr != end; ++iptr,++optr)
77 for (
int y=halfsize;
y<H-halfsize; ++
y) {
80 for (; iptr != end; ++iptr,++optr)
85 for (; iptr != end; ++iptr,++optr)
115 template<
typename ImagePixelT,
typename MaskPixelT,
typename VariancePixelT>
122 int cx = peak.
getIx();
123 int cy = peak.
getIy();
124 int ix0 = mimg.
getX0();
125 int iy0 = mimg.
getY0();
139 for (s = 0; s <
std::max(DW,DH); s += S) {
141 for (p=0; p<S; p++) {
181 for (
int i=0; i<(8*L); i++, x +=
dx, y +=
dy) {
185 if (i % (2*L) == 0) {
188 dx = ( leg % 2) * (-1 + 2*(leg/2));
190 dy = ((leg+1) % 2) * ( 1 - 2*(leg/2));
193 int px = cx + x - ix0;
194 int py = cy + y - iy0;
196 if (px < 0 || px >= iW || py < 0 || py >= iH)
199 ImagePixelT pix = (*shadowingImg)(px,py);
206 const double A = 0.3;
212 ds0 = (double(y) / double(x)) - A;
215 for (shx=1; shx<=S; shx++) {
216 int xsign = (x>0?1:-1);
218 psx = cx + x + (xsign*shx) - ix0;
219 if (psx < 0 || psx >= iW)
222 for (shy = iround(shx * ds0);
223 shy <= iround(shx * ds1); shy++) {
224 psy = cy + y + xsign*shy - iy0;
225 if (psy < 0 || psy >= iH)
227 (*img)(psx, psy) =
std::min((*img)(psx, psy), pix);
233 ds0 = (double(x) / double(y)) - A;
236 for (shy=1; shy<=S; shy++) {
237 int ysign = (y>0?1:-1);
238 psy = cy + y + (ysign*shy) - iy0;
239 if (psy < 0 || psy >= iH)
242 for (shx = iround(shy * ds0);
243 shx <= iround(shy * ds1); shx++) {
244 psx = cx + x + ysign*shx - ix0;
245 if (psx < 0 || psx >= iW)
247 (*img)(psx, psy) =
std::min((*img)(psx, psy), pix);
254 shadowingImg->operator<<=(*img);
258 static double _get_contrib_r_to_footprint(
int x,
int y,
262 SpanList
const& tspans = tfoot->
getSpans();
263 for (SpanList::const_iterator ts = tspans.begin(); ts < tspans.end(); ++ts) {
272 dx = x - sp->
getX1();
281 minr2 =
std::min(minr2, (
double)(mindx*mindx + dy*dy));
284 return 1. / (1. + minr2);
288 template<
typename ImagePixelT,
typename MaskPixelT,
typename VariancePixelT>
294 int strayFluxOptions,
296 std::vector<bool>
const& ispsf,
297 std::vector<int>
const& pkx,
298 std::vector<int>
const& pky,
299 double clipStrayFluxFraction,
309 std::vector<PTR(det::Footprint) > strayfoot;
310 std::vector<std::vector<ImagePixelT> > straypix;
311 std::vector<std::vector<MaskPixelT> > straymask;
312 std::vector<std::vector<VariancePixelT> > strayvar;
314 int ix0 = img.
getX0();
315 int iy0 = img.
getY0();
320 for (
size_t i=0; i<tfoots.size(); ++i) {
322 straypix.push_back(std::vector<ImagePixelT>());
323 straymask.push_back(std::vector<MaskPixelT>());
324 strayvar.push_back(std::vector<VariancePixelT>());
327 bool always = (strayFluxOptions & STRAYFLUX_TO_POINT_SOURCES_ALWAYS);
329 typedef boost::uint16_t itype;
332 if (strayFluxOptions & STRAYFLUX_NEAREST_FOOTPRINT) {
335 typedef boost::uint16_t dtype;
339 std::vector<PTR(det::Footprint)> templist;
340 std::vector<PTR(det::Footprint)>* footlist = &tfoots;
342 if (!always && ispsf.size()) {
346 for (
size_t i=0; i<tfoots.size(); ++i) {
348 templist.push_back(empty);
350 templist.push_back(tfoots[i]);
353 footlist = &templist;
360 const SpanList& spans = foot.
getSpans();
361 for (SpanList::const_iterator s = spans.begin(); s < spans.end(); s++) {
362 int y = (*s)->getY();
363 int x0 = (*s)->getX0();
364 int x1 = (*s)->getX1();
366 tsum->row_begin(y - sumy0) + (x0 - sumx0);
369 double contrib[tfoots.size()];
371 for (
int x = x0; x <= x1; ++
x, ++tsum_it, ++in_it) {
375 if ((*tsum_it > 0) || (*in_it).image() <= 0) {
379 if (strayFluxOptions & STRAYFLUX_R_TO_FOOTPRINT) {
381 for (
size_t i=0; i<tfoots.size(); ++i) {
384 }
else if (strayFluxOptions & STRAYFLUX_NEAREST_FOOTPRINT) {
385 for (
size_t i=0; i<tfoots.size(); ++i) {
388 int i = nearest->get0(x, y);
392 for (
size_t i=0; i<tfoots.size(); ++i) {
397 contrib[i] = 1. / (1. + dx*dx + dy*
dy);
403 bool ptsrcs = always;
405 for (
size_t i=0; i<tfoots.size(); ++i) {
407 if ((!ptsrcs) && ispsf.size() && ispsf[i]) {
410 if (contrib[i] == -1.0) {
411 contrib[i] = _get_contrib_r_to_footprint(x, y, tfoots[i]);
417 STRAYFLUX_TO_POINT_SOURCES_WHEN_NECESSARY)) {
421 for (
size_t i=0; i<tfoots.size(); ++i) {
422 if (contrib[i] == -1.0) {
423 contrib[i] = _get_contrib_r_to_footprint(x, y, tfoots[i]);
430 double strayclip = (clipStrayFluxFraction * csum);
432 for (
size_t i=0; i<tfoots.size(); ++i) {
434 if ((!ptsrcs) && ispsf.size() && ispsf[i]) {
439 if (contrib[i] < strayclip) {
446 for (
size_t i=0; i<tfoots.size(); ++i) {
447 if (contrib[i] == 0.) {
451 double p = (contrib[i] / csum) * (*in_it).image();
455 strayfoot[i]->addSpanInSeries(y, x, x);
456 straypix[i].push_back(p);
457 straymask[i].push_back((*in_it).mask());
458 strayvar[i].push_back((*in_it).variance());
464 for (
size_t i=0; i<tfoots.size(); ++i) {
466 strays.push_back(HeavyFootprintPtrT());
471 HeavyFootprintPtrT heavy(
new HeavyFootprint(*strayfoot[i]));
473 typename std::vector<ImagePixelT>::const_iterator spix;
474 typename std::vector<MaskPixelT>::const_iterator smask;
475 typename std::vector<VariancePixelT>::const_iterator svar;
480 assert((
size_t)strayfoot[i]->getNpix() == straypix[i].size());
482 for (spix = straypix[i].begin(),
483 smask = straymask[i].begin(),
484 svar = strayvar [i].begin(),
486 mpix = heavy->getMaskArray().
begin(),
487 vpix = heavy->getVarianceArray().
begin();
488 spix != straypix[i].end();
489 ++spix, ++smask, ++svar, ++hpix, ++mpix, ++vpix) {
494 strays.push_back(heavy);
499 template<
typename ImagePixelT,
typename MaskPixelT,
typename VariancePixelT>
509 for (
size_t i=0; i<timgs.size(); ++i) {
526 tsum->row_begin(y - sumy0) + (copyx0 - sumx0);
527 for (; in_it != inend; ++in_it, ++tsum_it) {
528 *tsum_it +=
std::max((ImagePixelT)0., (*in_it).image());
583 template<
typename ImagePixelT,
typename MaskPixelT,
typename VariancePixelT>
584 std::vector<typename PTR(image::MaskedImage<ImagePixelT, MaskPixelT, VariancePixelT>)>
588 std::vector<MaskedImagePtrT> timgs,
591 std::vector<bool>
const& ispsf,
592 std::vector<int>
const& pkx,
593 std::vector<int>
const& pky,
594 std::vector<boost::shared_ptr<typename det::HeavyFootprint<ImagePixelT,MaskPixelT,VariancePixelT> > > & strays,
595 int strayFluxOptions,
596 double clipStrayFluxFraction
600 if (timgs.size() != tfoots.size()) {
601 throw LSST_EXCEPT(lsst::pex::exceptions::LengthError,
602 (
boost::format(
"Template images must be the same length as template footprints (%d vs %d)")
603 % timgs.size() % tfoots.size()).str());
606 for (
size_t i=0; i<timgs.size(); ++i) {
607 if (!timgs[i]->getBBox().contains(tfoots[i]->getBBox())) {
608 throw LSST_EXCEPT(lsst::pex::exceptions::RuntimeError,
609 "Template image MUST contain template footprint");
612 throw LSST_EXCEPT(lsst::pex::exceptions::RuntimeError,
613 "Image bbox MUST contain parent footprint");
621 std::vector<MaskedImagePtrT> portions;
624 "lsst.meas.deblender.apportionFlux");
625 bool findStrayFlux = (strayFluxOptions & ASSIGN_STRAYFLUX);
627 int ix0 = img.
getX0();
628 int iy0 = img.
getY0();
636 if (!tsum->getBBox().contains(foot.
getBBox())) {
637 throw LSST_EXCEPT(lsst::pex::exceptions::RuntimeError,
638 "Template sum image MUST contain parent footprint");
645 _sum_templates(timgs, tsum);
648 for (
size_t i=0; i<timgs.size(); ++i) {
652 port->setXY0(timg->getXY0());
653 portions.push_back(port);
666 timg->row_begin(y - ty0) + (copyx0 - tx0);
669 tsum->row_begin(y - sumy0) + (copyx0 - sumx0);
671 port->row_begin(y - ty0) + (copyx0 - tx0);
672 for (; tptr != tend; ++tptr, ++in_it, ++out_it, ++tsum_it) {
676 double frac =
std::max((ImagePixelT)0., (*tptr).image()) / (*tsum_it);
680 out_it.mask() = (*in_it).mask();
681 out_it.variance() = (*in_it).variance();
682 out_it.image() = (*in_it).image() * frac;
688 if ((ispsf.size() > 0) && (ispsf.size() != timgs.size())) {
689 throw LSST_EXCEPT(lsst::pex::exceptions::LengthError,
690 (
boost::format(
"'ispsf' must be the same length as templates (%d vs %d)")
691 % ispsf.size() % timgs.size()).str());
693 if ((pkx.size() != timgs.size()) || (pky.size() != timgs.size())) {
694 throw LSST_EXCEPT(lsst::pex::exceptions::LengthError,
695 (
boost::format(
"'pkx' and 'pky' must be the same length as templates (%d,%d vs %d)")
696 % pkx.size() % pky.size() % timgs.size()).str());
698 _find_stray_flux(foot, tsum, img, strayFluxOptions, tfoots,
699 ispsf, pkx, pky, clipStrayFluxFraction, strays);
721 int cx,
int cy,
bool forward=
true)
732 return _real == other;
735 return _real != other;
738 return _real <= other;
740 bool operator<(
const SpanList::const_iterator & other) {
741 return _real < other;
744 return _real >= other;
746 bool operator>(
const SpanList::const_iterator & other) {
747 return _real > other;
756 return !(*
this == other);
783 return (*_real)->getX0() -
_cx;
785 return _cx - (*_real)->getX1();
790 return (*_real)->getX1() -
_cx;
792 return _cx - (*_real)->getX0();
796 return std::abs((*_real)->getY() -
_cy);
799 return (*_real)->getX0();
802 return (*_real)->getX1();
805 return (*_real)->getY();
867 template<
typename ImagePixelT,
typename MaskPixelT,
typename VariancePixelT>
869 deblend::BaselineUtils<ImagePixelT,MaskPixelT,VariancePixelT>::
877 const SpanList spans = foot.getSpans();
878 assert(foot.isNormalized());
881 "lsst.meas.deblender.symmetrizeFootprint");
884 PTR(det::Span) target(
new det::Span(cy, cx, cx));
885 SpanList::const_iterator peakspan =
886 std::lower_bound(spans.begin(), spans.end(), target, span_ptr_compare);
891 if (peakspan == spans.begin()) {
893 if (!sp->contains(cx, cy)) {
895 "Failed to find span containing (%i,%i): before the beginning of this footprint", 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(),
911 log.debugf(
"Span containing (%i,%i): (x=[%i,%i], y=%i)",
912 cx, cy, sp->getX0(), sp->getX1(), sp->getY());
951 int fdxlo = fwd.
dxlo();
952 int bdxlo = back.
dxlo();
959 for (fend = fwd; fend.
notDone(); ++fend) {
963 for (bend = back; bend.
notDone(); ++bend) {
968 log.debugf(
"dy=%i, fy=%i, fx=[%i, %i], by=%i, fx=[%i, %i], fdx=%i, bdx=%i",
969 dy, fy, fwd.
x0(), fwd.
x1(), by, back.
x0(), back.
x1(),
974 log.debugf(
"Advancing forward.");
978 while ((fwd != fend) && (fwd.
dxhi() < bdxlo)) {
981 log.debugf(
"Reached fend");
983 log.debugf(
"Advanced to forward span %i, [%i, %i]",
984 fy, fwd.
x0(), fwd.
x1());
987 }
else if (fdxlo > bdxlo) {
988 log.debugf(
"Advancing backward.");
992 while ((back != bend) && (back.
dxhi() < fdxlo)) {
995 log.debugf(
"Reached bend");
997 log.debugf(
"Advanced to backward span %i, [%i, %i]",
998 by, back.
x0(), back.
x1());
1003 if ((back == bend) || (fwd == fend)) {
1007 log.debugf(
"Reached bend");
1010 log.debugf(
"Reached fend");
1022 log.debugf(
"Adding span fwd %i, [%i, %i], back %i, [%i, %i]",
1023 fy, cx+dxlo, cx+dxhi, by, cx-dxhi, cx-dxlo);
1024 sfoot->addSpan(fy, cx + dxlo, cx + dxhi);
1025 sfoot->addSpan(by, cx - dxhi, cx - dxlo);
1032 log.debugf(
"Stepped to fend");
1034 log.debugf(
"Stepped forward to span %i, [%i, %i]",
1035 fwd.
y(), fwd.
x0(), fwd.
x1());
1040 log.debugf(
"Stepped to bend");
1042 log.debugf(
"Stepped backward to span %i, [%i, %i]",
1043 back.
y(), back.
x0(), back.
x1());
1047 if ((back == bend) || (fwd == fend)) {
1050 log.debugf(
"Reached bend");
1053 log.debugf(
"Reached fend");
1081 template<
typename ImagePixelT,
typename MaskPixelT,
typename VariancePixelT>
1082 std::pair<typename PTR(lsst::afw::image::MaskedImage<ImagePixelT,MaskPixelT,VariancePixelT>),
1092 bool* patchedEdges) {
1097 *patchedEdges =
false;
1099 int cx = peak.
getIx();
1100 int cy = peak.
getIy();
1103 "lsst.meas.deblender.symmetricFootprint");
1107 return std::pair<MaskedImagePtrT, FootprintPtrT>(
MaskedImagePtrT(), sfoot);
1109 const SpanList spans = sfoot->getSpans();
1112 bool touchesEdge =
false;
1114 log.
debugf(
"Checking footprint for EDGE bits");
1117 MaskPixelT edgebit = mask->getPlaneBitMask(
"EDGE");
1118 for (SpanList::const_iterator fwd=spans.begin();
1119 fwd != spans.end(); ++fwd) {
1120 int x0 = (*fwd)->getX0();
1121 int x1 = (*fwd)->getX1();
1123 mask->x_at(x0 - mask->getX0(), (*fwd)->getY() - mask->getY0());
1124 for (
int x=x0; x<=x1; ++
x, ++xiter) {
1125 if ((*xiter) & edgebit) {
1134 log.
debugf(
"Footprint includes an EDGE pixel.");
1142 MaskPixelT symm1sig = img.
getMask()->getPlaneBitMask(
"SYMM_1SIG");
1143 MaskPixelT symm3sig = img.
getMask()->getPlaneBitMask(
"SYMM_3SIG");
1145 SpanList::const_iterator fwd = spans.begin();
1146 SpanList::const_iterator back = spans.end()-1;
1150 MaskPtrT targetmask = timg->getMask();
1152 for (; fwd <= back; fwd++, back--) {
1153 int fy = (*fwd)->getY();
1154 int by = (*back)->getY();
1156 for (
int fx=(*fwd)->getX0(), bx=(*back)->getX1();
1157 fx <= (*fwd)->getX1();
1167 ImagePixelT pixf = theimg->get0(fx, fy);
1168 ImagePixelT pixb = theimg->get0(bx, by);
1169 ImagePixelT pix =
std::min(pixf, pixb);
1171 pix =
std::max(pix, static_cast<ImagePixelT>(0));
1173 targetimg->set0(fx, fy, pix);
1174 targetimg->set0(bx, by, pix);
1180 if (pixf >= pix + 1.*sigma1) {
1181 targetmask->set0(fx, fy, targetmask->get0(fx, fy) | symm1sig);
1182 if (pixf >= pix + 3.*sigma1) {
1183 targetmask->set0(fx, fy, targetmask->get0(fx, fy) | symm3sig);
1186 if (pixb >= pix + 1.*sigma1) {
1187 targetmask->set0(bx, by, targetmask->get0(bx, by) | symm1sig);
1188 if (pixb >= pix + 3.*sigma1) {
1189 targetmask->set0(bx, by, targetmask->get0(bx, by) | symm3sig);
1207 log.
debugf(
"Footprint touches EDGE: start bbox [%i,%i],[%i,%i]",
1210 const SpanList ospans = foot.
getSpans();
1211 for (fwd = ospans.begin(); fwd != ospans.end(); ++fwd) {
1212 int y = (*fwd)->getY();
1213 int x = (*fwd)->getX0();
1215 int ym = cy + (cy -
y);
1216 int xm = cx + (cx -
x);
1220 x = (*fwd)->getX1();
1226 log.
debugf(
"Footprint touches EDGE: grown bbox [%i,%i],[%i,%i]",
1233 log.
debugf(
"Symmetric footprint spans:");
1234 const SpanList sspans = sfoot->getSpans();
1235 for (fwd = sspans.begin(); fwd != sspans.end(); ++fwd) {
1236 log.
debugf(
" %s", (*fwd)->toString().c_str());
1241 for (fwd = ospans.begin(); fwd != ospans.end(); ++fwd) {
1242 int y = (*fwd)->getY();
1243 int x0 = (*fwd)->getX0();
1244 int x1 = (*fwd)->getX1();
1246 int ym = cy + (cy -
y);
1247 int xm0 = cx + (cx -
x0);
1248 int xm1 = cx + (cx - x1);
1259 x0 = cx + (cx - (imbb.
getMinX() - 1));
1262 x1 = cx + (cx - (imbb.
getMaxX() + 1));
1264 log.
debugf(
"Span y=%i, x=[%i,%i] has mirror (%i,[%i,%i]) out-of-bounds; clipped to %i,[%i,%i]",
1265 y, (*fwd)->getX0(), (*fwd)->getX1(), ym, xm1, xm0,
y,
x0, x1);
1269 timg2->x_at(x0 - timg2->getX0(), y - timg2->getY0());
1270 for (
int x=x0; x<=x1; ++
x, ++outiter, ++initer) {
1273 sfoot->addSpan(y, x0, x1);
1279 *patchedEdges = touchesEdge;
1280 return std::pair<MaskedImagePtrT, FootprintPtrT>(timg, sfoot);
1287 template<
typename ImagePixelT,
typename MaskPixelT,
typename VariancePixelT>
1292 ImagePixelT thresh) {
1296 "lsst.meas.deblender.hasSignificantFluxAtEdge");
1302 const SpanList spans = sfoot->
getSpans();
1303 for (SpanList::const_iterator sp = spans.
begin();
1304 sp != spans.
end(); ++sp) {
1312 int y = (*sp)->getY();
1313 int x0 = (*sp)->getX0();
1314 int x1 = (*sp)->getX1();
1317 for (xiter = img->x_at(x0 - img->getX0(), y - img->getY0()), x=x0;
1318 x<=x1; ++
x, ++xiter) {
1322 if (*xiter < thresh)
1327 if ((x != x0) && (x != x1) &&
1333 log.
debugf(
"Found significant template-edge pixel: %i,%i = %f > %f",
1334 x, y, (
float)*xiter, (
float)thresh);
1345 template<
typename ImagePixelT,
typename MaskPixelT,
typename VariancePixelT>
1346 boost::shared_ptr<det::Footprint>
1350 ImagePixelT thresh) {
1353 "lsst.meas.deblender.getSignificantEdgePixels");
1355 const SpanList spans = sfoot->
getSpans();
1356 SpanList::const_iterator sp;
1359 for (sp = spans.begin(); sp != spans.end(); sp++) {
1360 int y = (*sp)->getY();
1361 int x0 = (*sp)->getX0();
1362 int x1 = (*sp)->getX1();
1365 for (xiter = img->x_at(x0 - img->getX0(), y - img->getY0()), x=x0;
1366 x<=x1; ++
x, ++xiter) {
1367 if (*xiter < thresh)
1372 if ((x != x0) && (x != x1) &&
1378 log.
debugf(
"Found significant edge pixel: %i,%i = %f > thresh %g",
1379 x, y, (
float)*xiter, (
float)thresh);
1380 edgepix->addSpanInSeries(y, x, x);
static boost::shared_ptr< lsst::afw::detection::Footprint > getSignificantEdgePixels(ImagePtrT, boost::shared_ptr< lsst::afw::detection::Footprint >, ImagePixelT threshold)
void nearestFootprint(std::vector< boost::shared_ptr< Footprint >> const &foots, lsst::afw::image::Image< boost::uint16_t >::Ptr argmin, lsst::afw::image::Image< boost::uint16_t >::Ptr dist)
int getWidth() const
Return the number of columns in the image.
ImagePtr getImage(bool const noThrow=false) const
Return a (Ptr to) the MaskedImage's image.
static void _find_stray_flux(lsst::afw::detection::Footprint const &foot, ImagePtrT tsum, MaskedImageT const &img, int strayFluxOptions, std::vector< boost::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< boost::shared_ptr< typename lsst::afw::detection::HeavyFootprint< ImagePixelT, MaskPixelT, VariancePixelT > > > &strays)
void clip(Box2I const &other)
Shrink this to ensure that other.contains(*this).
void debugf(const char *fmt,...)
bool operator>=(const SpanList::const_iterator &other)
static void makeMonotonic(MaskedImageT &img, lsst::afw::detection::Peak const &pk)
static bool hasSignificantFluxAtEdge(ImagePtrT, boost::shared_ptr< lsst::afw::detection::Footprint >, ImagePixelT threshold)
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.
bool operator<(const SpanList::const_iterator &other)
static Log & getDefaultLog()
bool operator==(RelativeSpanIterator &other)
lsst::afw::detection::Footprint Footprint
bool operator==(const SpanList::const_iterator &other)
x_iterator row_end(int y) const
Return an x_iterator to the end of the image.
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
An integer coordinate rectangle.
table::Key< table::Array< Kernel::Pixel > > image
Iterator begin() const
Return an iterator to the first pixel in the Span.
An iterator to the MaskedImage.
x_iterator x_at(int x, int y) const
Return an x_iterator at the point (x, y)
boost::shared_ptr< lsst::afw::image::Image< ImagePixelT > > ImagePtrT
A locator for the MaskedImage.
xy_locator xy_at(int x, int y) const
Return an xy_locator at the point (x, y)
_const_view_t::x_iterator const_x_iterator
A const iterator for traversing the pixels in a row.
Extent2I const getDimensions() const
static void medianFilter(MaskedImageT const &img, MaskedImageT &outimg, int halfsize)
geom::Box2I getBBox(ImageOrigin const origin=PARENT) const
int getIx() const
Return the column pixel position.
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
bool contains(Point2I const &point) const
Return true if the box contains the point.
bool operator<=(const SpanList::const_iterator &other)
void include(Point2I const &point)
Expand this to ensure that this->contains(point).
#define LSST_EXCEPT(type,...)
Iterator end() const
Return an iterator to one past the last pixel in the Span.
static std::pair< MaskedImagePtrT, FootprintPtrT > buildSymmetricTemplate(MaskedImageT const &img, lsst::afw::detection::Footprint const &foot, lsst::afw::detection::Peak const &pk, double sigma1, bool minZero, bool patchEdges, bool *patchedEdges)
SpanList::const_iterator _end
MaskPtr getMask(bool const noThrow=false) const
Return a (Ptr to) the MaskedImage's mask.
afw::table::Key< double > sigma1
boost::shared_ptr< lsst::afw::image::MaskedImage< ImagePixelT > MaskPixelT, VariancePixelT > MaskedImagePtrT
_view_t::x_iterator x_iterator
An iterator for traversing the pixels in a row.
bool operator>(const SpanList::const_iterator &other)
int getY() const
Return the y-value.
bool operator!=(RelativeSpanIterator &other)
x_iterator row_begin(int y) const
Return an x_iterator to the start of the image.
ExpressionTraits< Derived >::Iterator Iterator
Nested expression or element iterator.
bool operator!=(const SpanList::const_iterator &other)
RelativeSpanIterator operator++()
RelativeSpanIterator operator++(int dummy)
int getHeight() const
Return the number of rows in the image.
int getX1() const
Return the ending x-value.
void copyWithinFootprint(Footprint const &foot, boost::shared_ptr< ImageOrMaskedImageT > const input, boost::shared_ptr< ImageOrMaskedImageT > output)
static void _sum_templates(std::vector< MaskedImagePtrT > timgs, ImagePtrT tsum)
A const locator for the MaskedImage.
int getX0() const
Return the starting x-value.
Iterator begin() const
Return an Iterator to the beginning of the array.