50 #include "boost/format.hpp"
61 namespace detection = lsst::afw::detection;
63 namespace math = lsst::afw::math;
64 namespace pexLogging = lsst::pex::logging;
65 namespace geom = lsst::afw::geom;
71 typedef boost::uint64_t IdPixelT;
73 struct Threshold_traits {
75 struct ThresholdLevel_traits :
public Threshold_traits {
77 struct ThresholdPixelLevel_traits :
public Threshold_traits {
79 struct ThresholdBitmask_traits :
public Threshold_traits {
87 inline bool isBadPixel(T) {
92 inline bool isBadPixel(
float val) {
97 inline bool isBadPixel(
double val) {
104 int nbit(
unsigned long i) {
118 template <
typename ImageT>
121 explicit FindIdsInFootprint(ImageT
const&
image
122 ) : detection::FootprintFunctor<ImageT>(image), _ids(), _old(0) {}
130 void operator()(
typename ImageT::xy_locator loc,
134 typename ImageT::Pixel
val = loc(0, 0);
142 std::set<typename ImageT::Pixel>
const& getIds()
const {
147 std::set<typename ImageT::Pixel> _ids;
148 typename ImageT::Pixel _old;
199 bool const left = ctrl.
isLeft().first && ctrl.
isLeft().second;
201 bool const up = ctrl.
isUp().first && ctrl.
isUp().second;
202 bool const down = ctrl.
isDown().first && ctrl.
isDown().second;
206 throw LSST_EXCEPT(lsst::pex::exceptions::InvalidParameterError,
207 boost::format(
"The two FootprintSets must have the same region").str());
216 int const nLhs = lhsFootprints.size();
217 int const nRhs = rhsFootprints.size();
222 int const lhsIdNbit = nbit(nLhs);
223 int const lhsIdMask = (lhsIdNbit == 0) ? 0x0 : (1 << lhsIdNbit) - 1;
226 throw LSST_EXCEPT(lsst::pex::exceptions::OverflowError,
227 (
boost::format(
"%d + %d footprints need too many bits; change IdPixelT typedef")
228 % nLhs % nRhs).str());
235 typedef std::map<int, std::set<boost::uint64_t> > OldIdMap;
236 OldIdMap overwrittenIds;
239 for (FootprintList::const_iterator ptr = lhsFootprints.begin(), end = lhsFootprints.end();
240 ptr != end; ++ptr, ++
id) {
245 growFootprint(*foot, rLhs, isotropic) : growFootprint(*foot, rLhs, left, right, up, down);
248 std::set<boost::uint64_t> overwritten;
249 foot->insertIntoImage(*idImage,
id,
true, 0x0, &overwritten);
251 if (!overwritten.empty()) {
252 overwrittenIds.insert(overwrittenIds.end(), std::make_pair(
id, overwritten));
256 assert (
id <= std::size_t(1 << lhsIdNbit));
257 id = (1 << lhsIdNbit);
258 for (FootprintList::const_iterator ptr = rhsFootprints.begin(), end = rhsFootprints.end();
259 ptr != end; ++ptr,
id += (1 << lhsIdNbit)) {
264 growFootprint(*foot, rRhs, isotropic) : growFootprint(*foot, rRhs, left, right, up, down);
267 std::set<boost::uint64_t> overwritten;
268 foot->insertIntoImage(*idImage,
id,
true, lhsIdMask, &overwritten);
270 if (!overwritten.empty()) {
271 overwrittenIds.insert(overwrittenIds.end(), std::make_pair(
id, overwritten));
288 FindIdsInFootprint<image::Image<IdPixelT> > idFinder(*idImage);
289 for (FootprintList::iterator ptr = fs.getFootprints()->begin(),
290 end = fs.getFootprints()->end(); ptr != end; ++ptr) {
291 PTR(Footprint) foot = *ptr;
293 idFinder.apply(*foot);
295 std::set<boost::uint64_t> lhsFootprintIndxs, rhsFootprintIndxs;
297 for (std::set<IdPixelT>::iterator idptr = idFinder.getIds().begin(),
298 idend = idFinder.getIds().end(); idptr != idend; ++idptr) {
299 unsigned int indx = *idptr;
300 if ((indx & lhsIdMask) > 0) {
301 boost::uint64_t i = (indx & lhsIdMask) - 1;
302 lhsFootprintIndxs.insert(i);
306 OldIdMap::iterator mapPtr = overwrittenIds.find(indx);
307 if (mapPtr != overwrittenIds.end()) {
308 std::set<boost::uint64_t> &overwritten = mapPtr->second;
310 for (std::set<boost::uint64_t>::iterator ptr = overwritten.begin(),
311 end = overwritten.end(); ptr != end; ++ptr){
312 lhsFootprintIndxs.insert((*ptr & lhsIdMask) - 1);
319 boost::uint64_t i = indx - 1;
320 rhsFootprintIndxs.insert(i);
324 OldIdMap::iterator mapPtr = overwrittenIds.find(indx);
325 if (mapPtr != overwrittenIds.end()) {
326 std::set<boost::uint64_t> &overwritten = mapPtr->second;
328 for (std::set<boost::uint64_t>::iterator ptr = overwritten.begin(),
329 end = overwritten.end(); ptr != end; ++ptr) {
330 rhsFootprintIndxs.insert(*ptr - 1);
339 Footprint::PeakList &peaks = foot->getPeaks();
341 for (std::set<boost::uint64_t>::iterator ptr = lhsFootprintIndxs.begin(),
342 end = lhsFootprintIndxs.end(); ptr != end; ++ptr) {
343 boost::uint64_t i = *ptr;
344 assert (i < lhsFootprints.size());
345 Footprint::PeakList
const& oldPeaks = lhsFootprints[i]->getPeaks();
347 int const nold = peaks.size();
348 peaks.insert(peaks.end(), oldPeaks.begin(), oldPeaks.end());
349 std::inplace_merge(peaks.begin(), peaks.begin() + nold, peaks.end(), SortPeaks());
352 for (std::set<boost::uint64_t>::iterator ptr = rhsFootprintIndxs.begin(),
353 end = rhsFootprintIndxs.end(); ptr != end; ++ptr) {
354 boost::uint64_t i = *ptr;
355 assert (i < rhsFootprints.size());
356 Footprint::PeakList
const& oldPeaks = rhsFootprints[i]->getPeaks();
358 int const nold = peaks.size();
359 peaks.insert(peaks.end(), oldPeaks.begin(), oldPeaks.end());
360 std::inplace_merge(peaks.begin(), peaks.begin() + nold, peaks.end(), SortPeaks());
371 typedef boost::shared_ptr<IdSpan> Ptr;
373 explicit IdSpan(
int id,
int y,
int x0,
int x1,
double good) :
374 id(id), y(y), x0(x0), x1(x1), good(good) {}
383 struct IdSpanCompar :
public std::binary_function<const IdSpan::Ptr, const IdSpan::Ptr, bool> {
384 bool operator()(IdSpan::Ptr
const a, IdSpan::Ptr
const b) {
387 }
else if (a->id > b->id) {
390 return (a->y < b->y) ?
true :
false;
401 while (
id != aliases[
id]) {
402 resolved =
id = aliases[
id];
416 template <
typename ImageT>
419 explicit FindPeaksInFootprint(ImageT
const&
image,
422 ) : detection::FootprintFunctor<ImageT>(image),
423 _polarity(polarity), _peaks(peaks) {}
426 void operator()(
typename ImageT::xy_locator loc,
430 typename ImageT::Pixel val = loc(0, 0);
433 if (loc(-1, 1) > val || loc( 0, 1) > val || loc( 1, 1) > val ||
434 loc(-1, 0) > val || loc( 1, 0) > val ||
435 loc(-1, -1) > val || loc( 0, -1) > val || loc( 1, -1) > val) {
439 if (loc(-1, 1) < val || loc( 0, 1) < val || loc( 1, 1) < val ||
440 loc(-1, 0) < val || loc( 1, 0) < val ||
441 loc(-1, -1) < val || loc( 0, -1) < val || loc( 1, -1) < val) {
456 template <
typename ImageT>
459 explicit FindMaxInFootprint(ImageT
const&
image,
461 ) : detection::FootprintFunctor<ImageT>(image),
462 _polarity(polarity), _x(0),
_y(0),
463 _min( std::numeric_limits<double>::
max()),
464 _max(-std::numeric_limits<double>::
max()) {}
475 void operator()(
typename ImageT::xy_locator loc,
479 typename ImageT::Pixel val = loc(0, 0);
498 return boost::make_shared<detection::Peak>(
detection::Peak(_x,
_y, _polarity ? _max : _min));
506 template<
typename ImageT,
typename ThresholdT>
509 FindPeaksInFootprint<ImageT> peakFinder(img, polarity, foot->
getPeaks());
510 peakFinder.apply(*foot, 1);
512 std::stable_sort(foot->
getPeaks().begin(), foot->
getPeaks().end(), SortPeaks());
515 FindMaxInFootprint<ImageT> maxFinder(img, polarity);
516 maxFinder.apply(*foot);
517 foot->
getPeaks().push_back(maxFinder.makePeak());
522 template<
typename ImageT>
533 template<
typename ImagePixelT,
typename IterT>
534 static inline bool inFootprint(ImagePixelT pixVal, IterT,
535 bool polarity,
double thresholdVal, ThresholdLevel_traits) {
536 return (polarity ? pixVal : -pixVal) >= thresholdVal;
539 template<
typename ImagePixelT,
typename IterT>
540 static inline bool inFootprint(ImagePixelT pixVal, IterT var,
541 bool polarity,
double thresholdVal, ThresholdPixelLevel_traits) {
542 return (polarity ? pixVal : -pixVal) >= thresholdVal*::sqrt(*var);
545 template<
typename ImagePixelT,
typename IterT>
546 static inline bool inFootprint(ImagePixelT pixVal, IterT,
547 bool,
double thresholdVal, ThresholdBitmask_traits) {
548 return (pixVal & static_cast<long>(thresholdVal));
554 template<
typename IterT>
556 advancePtr(IterT varPtr, Threshold_traits) {
560 template<
typename IterT>
562 advancePtr(IterT varPtr, ThresholdPixelLevel_traits) {
570 template<
typename ImagePixelT,
typename MaskPixelT,
typename VariancePixelT,
typename ThresholdTraitT>
571 static void findFootprints(
576 double const footprintThreshold,
577 double const includeThresholdMultiplier,
589 double includeThreshold = footprintThreshold * includeThresholdMultiplier;
591 int const row0 = img.
getY0();
592 int const col0 = img.
getX0();
599 std::vector<int> id1(width + 2);
600 std::fill(id1.begin(), id1.end(), 0);
601 std::vector<int> id2(width + 2);
602 std::fill(id2.begin(), id2.end(), 0);
603 std::vector<int>::iterator idc = id1.begin() + 1;
604 std::vector<int>::iterator idp = id2.begin() + 1;
606 std::vector<int> aliases;
607 aliases.reserve(1 + height/20);
609 std::vector<IdSpan::Ptr> spans;
610 spans.reserve(aliases.capacity());
612 aliases.push_back(0);
620 for (
int y = 0; y != height; ++
y) {
621 if (idc == id1.begin() + 1) {
622 idc = id2.
begin() + 1;
623 idp = id1.begin() + 1;
625 idc = id1.begin() + 1;
626 idp = id2.begin() + 1;
628 std::fill_n(idc - 1, width + 2, 0);
631 bool good = (includeThresholdMultiplier == 1.0);
634 x_var_iterator varPtr = (var == NULL) ? NULL : var->
row_begin(y);
635 for (
int x = 0; x < width; ++
x, ++pixPtr, varPtr = advancePtr(varPtr, ThresholdTraitT())) {
636 ImagePixelT
const pixVal = *pixPtr;
638 if (isBadPixel(pixVal) ||
639 !inFootprint(pixVal, varPtr, polarity, footprintThreshold, ThresholdTraitT())) {
641 IdSpan::Ptr sp(
new IdSpan(in_span, y, x0, x - 1, good));
648 if (idc[x - 1] != 0) {
650 }
else if (idp[x - 1] != 0) {
652 }
else if (idp[x] != 0) {
654 }
else if (idp[x + 1] != 0) {
658 aliases.push_back(
id);
669 if (idp[x + 1] != 0 && idp[x + 1] !=
id) {
672 idc[
x] =
id = idp[x + 1];
675 if (!good && inFootprint(pixVal, varPtr, polarity, includeThreshold, ThresholdTraitT())) {
682 IdSpan::Ptr sp(
new IdSpan(in_span, y, x0, width - 1, good));
689 for (
unsigned int i = 0; i < spans.size(); i++) {
695 if (spans.size() > 0) {
696 std::sort(spans.begin(), spans.end(), IdSpanCompar());
702 if (spans.size() > 0) {
705 for (
unsigned int i = 0; i <= spans.size(); i++) {
706 if (i == spans.size() || spans[i]->id !=
id) {
710 for (; i0 < i; i0++) {
711 good |= spans[i0]->good;
712 fp->addSpan(spans[i0]->y + row0, spans[i0]->x0 + col0, spans[i0]->x1 + col0);
715 if (good && !(fp->getNpix() < npixMin)) {
716 _footprints->push_back(fp);
720 if (i < spans.size()) {
729 typedef detection::FootprintSet::FootprintList::iterator fiterator;
730 for (fiterator ptr = _footprints->begin(), end = _footprints->end(); ptr != end; ++ptr) {
731 findPeaks(*ptr, img, polarity, ThresholdTraitT());
740 template<
typename ImagePixelT>
746 ) : lsst::daf::base::Citizen(typeid(this)),
747 _footprints(new FootprintList()),
748 _region(img.getBBox())
750 typedef float VariancePixelT;
752 findFootprints<ImagePixelT, afw::image::MaskPixel, VariancePixelT, ThresholdLevel_traits>(
768 template <
typename MaskPixelT>
773 ) : lsst::daf::base::Citizen(typeid(this)),
774 _footprints(new FootprintList()),
775 _region(msk.getBBox())
779 findFootprints<MaskPixelT, MaskPixelT, float, ThresholdBitmask_traits>(
785 findFootprints<MaskPixelT, MaskPixelT, float, ThresholdLevel_traits>(
791 throw LSST_EXCEPT(lsst::pex::exceptions::InvalidParameterError,
792 "You must specify a numerical threshold value with a Mask");
809 template<
typename ImagePixelT,
typename MaskPixelT>
813 std::string
const &planeName,
816 ) : lsst::daf::base::Citizen(typeid(this)),
817 _footprints(new FootprintList()),
819 geom::
Point2I(maskedImg.getX0(), maskedImg.getY0()),
820 geom::
Extent2I(maskedImg.getWidth(), maskedImg.getHeight())
827 findFootprints<ImagePixelT, MaskPixelT, VariancePixelT, ThresholdPixelLevel_traits>(
840 findFootprints<ImagePixelT, MaskPixelT, VariancePixelT, ThresholdLevel_traits>(
854 if (planeName ==
"") {
871 MaskFootprint(MaskT
const& mimage,
874 void operator()(
typename MaskT::xy_locator loc,
int,
int) {
881 MaskFootprint maskit(*maskedImg.
getMask(), bitPlane);
882 for (FootprintList::const_iterator fiter = _footprints->begin();
883 fiter != _footprints->end(); ++fiter
897 template <
typename ImagePixelT,
typename MaskPixelT>
904 ) : lsst::daf::base::Citizen(typeid(this)),
905 _footprints(new FootprintList()),
906 _region(geom::
Point2I(img.getX0(), img.getY0()),
907 geom::
Extent2I(img.getWidth(), img.getHeight()))
909 throw LSST_EXCEPT(lsst::pex::exceptions::LogicError,
"NOT IMPLEMENTED");
926 enum DIRECTION {DOWN = 0,
934 template<
typename MaskPixelT>
937 typedef std::vector<boost::shared_ptr<Startspan> > Ptr;
940 ~Startspan() {
delete _span; }
942 bool getSpan() {
return _span; }
943 bool Stop() {
return _stop; }
944 DIRECTION getDirection() {
return _direction; }
946 static int detectedPlane;
947 static int stopPlane;
949 detection::Span::Ptr
const _span;
950 DIRECTION _direction;
954 template<
typename MaskPixelT>
955 Startspan<MaskPixelT>::Startspan(detection::Span
const *span,
966 int const y = span->getY() - mask->
getY0();
967 for (
int x = span->getX0() - mask->
getX0(); x <= span->getX1() - mask->
getX0(); x++) {
968 if (mask(x, y, stopPlane)) {
976 template<
typename ImagePixelT,
typename MaskPixelT>
980 _image(image->getImage()),
981 _mask(image->getMask()) {}
984 bool add(detection::Span *span, DIRECTION
const dir,
bool addToMask =
true);
987 double const param = -1);
991 std::vector<typename Startspan<MaskPixelT>::Ptr> _spans;
997 template<
typename ImagePixelT,
typename MaskPixelT>
998 bool StartspanSet<ImagePixelT, MaskPixelT>::add(detection::Span *span,
1001 if (dir == RESTART) {
1002 if (add(span, UP) || add(span, DOWN,
false)) {
1006 typename Startspan<MaskPixelT>::Ptr sspan(
new Startspan<MaskPixelT>(span, dir));
1007 if (sspan->stop()) {
1010 _spans.push_back(sspan);
1026 template<
typename ImagePixelT,
typename MaskPixelT>
1027 bool StartspanSet<ImagePixelT, MaskPixelT>::process(
1032 int const row0 = _image->getY0();
1033 int const col0 = _image->getOffsetCols();
1034 int const height = _image->getHeight();
1038 typedef typename std::vector<typename Startspan<MaskPixelT>::Ptr> StartspanListT;
1039 typedef typename std::vector<typename Startspan<MaskPixelT>::Ptr>::iterator StartspanListIterT;
1041 Startspan<MaskPixelT> *sspan = NULL;
1042 for (StartspanListIterT
iter = _spans.begin();
iter != _spans.end();
iter++) {
1044 if (sspan->getDirection() != DONE) {
1047 if (sspan->Stop()) {
1051 if (sspan == NULL || sspan->getDirection() == DONE) {
1054 if (sspan->Stop()) {
1060 DIRECTION
const dir = sspan->getDirection();
1064 int x0 = sspan->getSpan()->getX0() - col0;
1069 int const di = (dir == UP) ? 1 : -1;
1073 double const thresholdVal = threshold.
getValue(param);
1076 for (
int i = sspan->span->y -row0 + di; i < height && i >= 0; i += di) {
1077 pixAccessT imgRow = _image->origin().advance(0, i);
1085 for (
int j = x0 - 1; j >= -1; j--) {
1086 ImagePixelT pixVal = (j < 0) ? thresholdVal - 100 : (polarity ? imgRow[j] : -imgRow[j]);
1087 if (_mask(j, i, Startspan<MaskPixelT>::detectedPlane) || pixVal < threshold) {
1102 for (
int j = nx0 + 1; j <= width; j++) {
1103 ImagePixelT pixVal = (j >= width) ? threshold - 100 :
1104 (polarity ? (F32 ? imgRowF32[j] : imgRowS32[j]) :
1105 (F32 ? -imgRowF32[j] : -imgRowS32[j]));
1106 if ((maskRow[j] & DETECTED) || pixVal < threshold) {
1112 pmSpan
const *sp = pmFootprintAddSpan(fp, i + row0, nx0 + col0, nx1 + col0);
1114 if (add_startspan(startspans, sp, mask, RESTART)) {
1130 for (
int j = nx1 + 1; j <= x1 + 1; j++) {
1131 ImagePixelT pixVal = (j >= width) ? threshold - 100 :
1132 (polarity ? (F32 ? imgRowF32[j] : imgRowS32[j]) : (F32 ? -imgRowF32[j] : -imgRowS32[j]));
1133 if (!(maskRow[j] & DETECTED) && pixVal >= threshold) {
1136 for (; j <= width; j++) {
1137 ImagePixelT pixVal = (j >= width) ? threshold - 100 :
1138 (polarity ? (F32 ? imgRowF32[j] : imgRowS32[j]) :
1139 (F32 ? -imgRowF32[j] : -imgRowS32[j]));
1140 if ((maskRow[j] & DETECTED) || pixVal < threshold) {
1150 sp = pmFootprintAddSpan(fp, i + row0, sx0 + col0, sx1 + col0 - 1);
1151 if (add_startspan(startspans, sp, mask, DONE)) {
1156 sp = pmFootprintAddSpan(fp, i + row0, sx0 + col0, x1 + col0);
1157 if (add_startspan(startspans, sp, mask, DONE)) {
1161 sp = pmFootprintAddSpan(fp, i + row0, x1 + 1 + col0, sx1 + col0 - 1);
1162 if (add_startspan(startspans, sp, mask, RESTART)) {
1169 sp = pmFootprintAddSpan(fp, i + row0, sx0 + col0, sx1 + col0 - 1);
1170 if (add_startspan(startspans, sp, mask, RESTART)) {
1178 if (stop || first ==
false) {
1190 sspan->_direction = DONE;
1191 return stop ?
false :
true;
1212 pmFindFootprintAtPoint(psImage
const *img,
1213 Threshold
const &threshold,
1214 psArray
const *peaks,
1216 assert(img != NULL);
1219 if (img->type.type == PS_TYPE_F32) {
1221 }
else if (img->type.type == PS_TYPE_S32) {
1224 psError(PS_ERR_UNKNOWN,
true,
"Unsupported psImage type: %d", img->type.type);
1227 psF32 *imgRowF32 = NULL;
1228 psS32 *imgRowS32 = NULL;
1230 int const row0 = img->row0;
1231 int const col0 = img->col0;
1232 int const height = img->getHeight();
1233 int const width = img->getWidth();
1239 if (row < 0 || row >= height ||
1240 col < 0 || col >= width) {
1241 psError(PS_ERR_BAD_PARAMETER_VALUE,
true,
1242 "row/col == (%d, %d) are out of bounds [%d--%d, %d--%d]",
1243 row + row0, col + col0, row0, row0 + height - 1, col0, col0 + width - 1);
1247 ImagePixelT pixVal = F32 ? img->data.F32[
row][
col] : img->data.S32[
row][
col];
1248 if (pixVal < threshold) {
1249 return pmFootprintAlloc(0, img);
1252 pmFootprint *fp = pmFootprintAlloc(1 + img->getHeight()/10, img);
1258 psImage *mask = psImageAlloc(width, height, PS_TYPE_MASK);
1259 P_PSIMAGE_SET_ROW0(mask, row0);
1260 P_PSIMAGE_SET_COL0(mask, col0);
1261 psImageInit(mask, INITIAL);
1265 assert (peaks == NULL || peaks->n == 0 || pmIsPeak(peaks->data[0]));
1266 if (peaks != NULL) {
1267 for (
int i = 0; i < peaks->n; i++) {
1268 pmPeak *peak = peaks->data[i];
1269 mask->data.PS_TYPE_MASK_DATA[peak->y - mask->row0][peak->x - mask->col0] |= STOP;
1275 psArray *startspans = psArrayAllocEmpty(1);
1277 imgRowF32 = img->data.F32[
row];
1278 imgRowS32 = img->data.S32[
row];
1279 psMaskType *maskRow = mask->data.PS_TYPE_MASK_DATA[
row];
1282 for (i = col; i >= 0; i--) {
1283 pixVal = F32 ? imgRowF32[i] : imgRowS32[i];
1284 if ((maskRow[i] & DETECTED) || pixVal < threshold) {
1289 for (i = col; i < width; i++) {
1290 pixVal = F32 ? imgRowF32[i] : imgRowS32[i];
1291 if ((maskRow[i] & DETECTED) || pixVal < threshold) {
1296 pmSpan
const *sp = pmFootprintAddSpan(fp, row + row0, i0 + col0 + 1, i1 + col0 - 1);
1298 (void)add_startspan(startspans, sp, mask, RESTART);
1303 while (do_startspan(fp, img, mask, threshold, startspans))
continue;
1320 lsst::daf::base::Citizen(typeid(this)),
1321 _footprints(
PTR(FootprintList)(new FootprintList)), _region(region) {
1330 lsst::daf::base::Citizen(typeid(this)),
1331 _footprints(new FootprintList), _region(rhs._region)
1334 for (FootprintSet::FootprintList::const_iterator ptr = rhs.
_footprints->begin(),
1335 end = rhs.
_footprints->end(); ptr != end; ++ptr) {
1336 _footprints->push_back(
PTR(Footprint)(
new Footprint(**ptr)));
1373 for (FootprintSet::FootprintList::iterator ptr = _footprints->begin(),
1374 end = _footprints->end(); ptr != end; ++ptr
1376 (*ptr)->setRegion(region);
1392 : lsst::daf::base::Citizen(typeid(this)), _footprints(new FootprintList), _region(rhs._region)
1399 throw LSST_EXCEPT(lsst::pex::exceptions::InvalidParameterError,
1400 (
boost::format(
"I cannot grow by negative numbers: %d") % r).str());
1413 : lsst::daf::base::Citizen(typeid(this)), _footprints(new FootprintList), _region(rhs._region)
1419 }
else if (ngrow < 0) {
1420 throw LSST_EXCEPT(lsst::pex::exceptions::InvalidParameterError,
1421 str(
boost::format(
"I cannot grow by negative numbers: %d") % ngrow));
1439 : lsst::daf::base::Citizen(typeid(this)),
1440 _footprints(new FootprintList()),
1441 _region(fs1._region)
1444 throw LSST_EXCEPT(lsst::pex::exceptions::LogicError,
"NOT IMPLEMENTED");
1455 bool const relativeIDs
1463 for (FootprintList::const_iterator fiter = _footprints->begin();
1464 fiter != _footprints->end(); fiter++
1474 foot->insertIntoImage(*im.get(),
id);
1484 template<
typename ImagePixelT,
typename MaskPixelT>
1497 for (FootprintList::iterator ptr = _footprints->begin(),
1498 end = _footprints->end(); ptr != end; ++ptr) {
1506 for (FootprintList::const_iterator i = _footprints->begin(); i != _footprints->end(); ++i) {
1508 r->setFootprint(*i);
1520 #define INSTANTIATE(PIXEL) \
1521 template detection::FootprintSet::FootprintSet( \
1522 image::Image<PIXEL> const &, Threshold const &, int const, bool const); \
1523 template detection::FootprintSet::FootprintSet( \
1524 image::MaskedImage<PIXEL,image::MaskPixel> const &, Threshold const &, \
1525 std::string const &, int const, bool const);\
1526 template detection::FootprintSet::FootprintSet( \
1527 image::MaskedImage<PIXEL,image::MaskPixel> const &, Threshold const &, \
1528 int, int, std::vector<PTR(Peak)> const *); \
1529 template void detection::FootprintSet::makeHeavy(image::MaskedImage<PIXEL,image::MaskPixel> const &, \
1530 HeavyFootprintCtrl const *)
int getIx() const
Return the column pixel position.
double getValue(const double param=-1) const
void swap(ImageBase< PixelT > &a, ImageBase< PixelT > &b)
ThresholdType getType() const
return type of threshold
double getIncludeMultiplier() const
return includeMultiplier
definition of the Trace messaging facilities
PixelT Pixel
A pixel in this ImageBase.
Use (pixels & (given mask))
A Threshold is used to pass a threshold value to detection algorithms.
ImagePtr getImage(bool const noThrow=false) const
Return a (Ptr to) the MaskedImage's image.
int getId() const
Return the Peak's unique ID.
The base class for all image classed (Image, Mask, MaskedImage, ...)
Extent< int, 2 > Extent2I
An integer coordinate rectangle.
VariancePtr getVariance(bool const noThrow=false) const
Return a (Ptr to) the MaskedImage's variance.
table::Key< table::Array< Kernel::Pixel > > image
boost::shared_ptr< Footprint > growFootprint(Footprint const &foot, int nGrow, bool isotropic=true)
Include files required for standard LSST Exception handling.
Custom catalog class for record/table subclasses that are guaranteed to have an ID, and should generally be sorted by that ID.
Represent a 2-dimensional array of bitmask pixels.
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.
void setMaskPlaneValues(const int plane, const int x0, const int x1, const int y)
Set the bit specified by "planeId" for pixels (x0, y) ... (x1, y)
int getHeight() const
Return the number of rows in the image.
static MaskPixelT getPlaneBitMask(const std::vector< std::string > &names)
Return the bitmask corresponding to a vector of plane names OR'd together.
Support for peaks in images.
boost::shared_ptr< Mask > Ptr
#define LSST_EXCEPT(type,...)
lsst::afw::detection::Footprint Footprint
int resolve_alias(const std::vector< int > &aliases, int id)
boost::shared_ptr< RecordT > addNew()
Create a new record, add it to the end of the catalog, and return a pointer to it.
Compute Image Statistics.
afw::table::Key< double > b
bool getPolarity() const
return Threshold's polarity
Record class that contains measurements made on a single exposure.
Implementation of the Class MaskedImage.
x_iterator row_begin(int y) const
Use number of sigma given per-pixel s.d.
int getWidth() const
Return the number of columns in the image.
float getPeakValue() const
Return the value of the image at the peak.
A class to represent a 2-dimensional array of pixels.
static int addMaskPlane(const std::string &name)
boost::uint64_t FootprintIdPixel