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) ? 0
x0 : (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, 0
x0, &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 Startspan<MaskPixelT> *sspan = NULL;
1039 for (
auto iter = _spans.begin();
iter != _spans.end();
iter++) {
1041 if (sspan->getDirection() != DONE) {
1044 if (sspan->Stop()) {
1048 if (sspan == NULL || sspan->getDirection() == DONE) {
1051 if (sspan->Stop()) {
1057 DIRECTION
const dir = sspan->getDirection();
1061 int x0 = sspan->getSpan()->getX0() - col0;
1066 int const di = (dir == UP) ? 1 : -1;
1070 double const thresholdVal = threshold.
getValue(param);
1073 for (
int i = sspan->span->y -row0 + di; i < height && i >= 0; i += di) {
1074 pixAccessT imgRow = _image->origin().advance(0, i);
1082 for (
int j = x0 - 1; j >= -1; j--) {
1083 ImagePixelT pixVal = (j < 0) ? thresholdVal - 100 : (polarity ? imgRow[j] : -imgRow[j]);
1084 if (_mask(j, i, Startspan<MaskPixelT>::detectedPlane) || pixVal < threshold) {
1099 for (
int j = nx0 + 1; j <= width; j++) {
1100 ImagePixelT pixVal = (j >= width) ? threshold - 100 :
1101 (polarity ? (F32 ? imgRowF32[j] : imgRowS32[j]) :
1102 (F32 ? -imgRowF32[j] : -imgRowS32[j]));
1103 if ((maskRow[j] & DETECTED) || pixVal < threshold) {
1109 pmSpan
const *sp = pmFootprintAddSpan(fp, i + row0, nx0 + col0, nx1 + col0);
1111 if (add_startspan(startspans, sp, mask, RESTART)) {
1127 for (
int j = nx1 + 1; j <= x1 + 1; j++) {
1128 ImagePixelT pixVal = (j >= width) ? threshold - 100 :
1129 (polarity ? (F32 ? imgRowF32[j] : imgRowS32[j]) : (F32 ? -imgRowF32[j] : -imgRowS32[j]));
1130 if (!(maskRow[j] & DETECTED) && pixVal >= threshold) {
1133 for (; j <= width; j++) {
1134 ImagePixelT pixVal = (j >= width) ? threshold - 100 :
1135 (polarity ? (F32 ? imgRowF32[j] : imgRowS32[j]) :
1136 (F32 ? -imgRowF32[j] : -imgRowS32[j]));
1137 if ((maskRow[j] & DETECTED) || pixVal < threshold) {
1147 sp = pmFootprintAddSpan(fp, i + row0, sx0 + col0, sx1 + col0 - 1);
1148 if (add_startspan(startspans, sp, mask, DONE)) {
1153 sp = pmFootprintAddSpan(fp, i + row0, sx0 + col0, x1 + col0);
1154 if (add_startspan(startspans, sp, mask, DONE)) {
1158 sp = pmFootprintAddSpan(fp, i + row0, x1 + 1 + col0, sx1 + col0 - 1);
1159 if (add_startspan(startspans, sp, mask, RESTART)) {
1166 sp = pmFootprintAddSpan(fp, i + row0, sx0 + col0, sx1 + col0 - 1);
1167 if (add_startspan(startspans, sp, mask, RESTART)) {
1175 if (stop || first ==
false) {
1187 sspan->_direction = DONE;
1188 return stop ?
false :
true;
1209 pmFindFootprintAtPoint(psImage
const *img,
1210 Threshold
const &threshold,
1211 psArray
const *peaks,
1213 assert(img != NULL);
1216 if (img->type.type == PS_TYPE_F32) {
1218 }
else if (img->type.type == PS_TYPE_S32) {
1221 psError(PS_ERR_UNKNOWN,
true,
"Unsupported psImage type: %d", img->type.type);
1224 psF32 *imgRowF32 = NULL;
1225 psS32 *imgRowS32 = NULL;
1227 int const row0 = img->row0;
1228 int const col0 = img->col0;
1229 int const height = img->getHeight();
1230 int const width = img->getWidth();
1236 if (row < 0 || row >= height ||
1237 col < 0 || col >= width) {
1238 psError(PS_ERR_BAD_PARAMETER_VALUE,
true,
1239 "row/col == (%d, %d) are out of bounds [%d--%d, %d--%d]",
1240 row + row0, col + col0, row0, row0 + height - 1, col0, col0 + width - 1);
1244 ImagePixelT pixVal = F32 ? img->data.F32[
row][
col] : img->data.S32[
row][
col];
1245 if (pixVal < threshold) {
1246 return pmFootprintAlloc(0, img);
1249 pmFootprint *fp = pmFootprintAlloc(1 + img->getHeight()/10, img);
1255 psImage *mask = psImageAlloc(width, height, PS_TYPE_MASK);
1256 P_PSIMAGE_SET_ROW0(mask, row0);
1257 P_PSIMAGE_SET_COL0(mask, col0);
1258 psImageInit(mask, INITIAL);
1262 assert (peaks == NULL || peaks->n == 0 || pmIsPeak(peaks->data[0]));
1263 if (peaks != NULL) {
1264 for (
int i = 0; i < peaks->n; i++) {
1265 pmPeak *peak = peaks->data[i];
1266 mask->data.PS_TYPE_MASK_DATA[peak->y - mask->row0][peak->x - mask->col0] |= STOP;
1272 psArray *startspans = psArrayAllocEmpty(1);
1274 imgRowF32 = img->data.F32[
row];
1275 imgRowS32 = img->data.S32[
row];
1276 psMaskType *maskRow = mask->data.PS_TYPE_MASK_DATA[
row];
1279 for (i = col; i >= 0; i--) {
1280 pixVal = F32 ? imgRowF32[i] : imgRowS32[i];
1281 if ((maskRow[i] & DETECTED) || pixVal < threshold) {
1286 for (i = col; i < width; i++) {
1287 pixVal = F32 ? imgRowF32[i] : imgRowS32[i];
1288 if ((maskRow[i] & DETECTED) || pixVal < threshold) {
1293 pmSpan
const *sp = pmFootprintAddSpan(fp, row + row0, i0 + col0 + 1, i1 + col0 - 1);
1295 (void)add_startspan(startspans, sp, mask, RESTART);
1300 while (do_startspan(fp, img, mask, threshold, startspans))
continue;
1317 lsst::daf::base::Citizen(typeid(this)),
1318 _footprints(
PTR(FootprintList)(new FootprintList)), _region(region) {
1327 lsst::daf::base::Citizen(typeid(this)),
1328 _footprints(new FootprintList), _region(rhs._region)
1331 for (FootprintSet::FootprintList::const_iterator ptr = rhs.
_footprints->begin(),
1332 end = rhs.
_footprints->end(); ptr != end; ++ptr) {
1333 _footprints->push_back(
PTR(Footprint)(
new Footprint(**ptr)));
1370 for (FootprintSet::FootprintList::iterator ptr = _footprints->begin(),
1371 end = _footprints->end(); ptr != end; ++ptr
1373 (*ptr)->setRegion(region);
1389 : lsst::daf::base::Citizen(typeid(this)), _footprints(new FootprintList), _region(rhs._region)
1396 throw LSST_EXCEPT(lsst::pex::exceptions::InvalidParameterError,
1397 (
boost::format(
"I cannot grow by negative numbers: %d") % r).str());
1410 : lsst::daf::base::Citizen(typeid(this)), _footprints(new FootprintList), _region(rhs._region)
1416 }
else if (ngrow < 0) {
1417 throw LSST_EXCEPT(lsst::pex::exceptions::InvalidParameterError,
1418 str(
boost::format(
"I cannot grow by negative numbers: %d") % ngrow));
1436 : lsst::daf::base::Citizen(typeid(this)),
1437 _footprints(new FootprintList()),
1438 _region(fs1._region)
1441 throw LSST_EXCEPT(lsst::pex::exceptions::LogicError,
"NOT IMPLEMENTED");
1452 bool const relativeIDs
1460 for (FootprintList::const_iterator fiter = _footprints->begin();
1461 fiter != _footprints->end(); fiter++
1471 foot->insertIntoImage(*im.get(),
id);
1481 template<
typename ImagePixelT,
typename MaskPixelT>
1494 for (FootprintList::iterator ptr = _footprints->begin(),
1495 end = _footprints->end(); ptr != end; ++ptr) {
1503 for (FootprintList::const_iterator i = _footprints->begin(); i != _footprints->end(); ++i) {
1505 r->setFootprint(*i);
1517 #define INSTANTIATE(PIXEL) \
1518 template detection::FootprintSet::FootprintSet( \
1519 image::Image<PIXEL> const &, Threshold const &, int const, bool const); \
1520 template detection::FootprintSet::FootprintSet( \
1521 image::MaskedImage<PIXEL,image::MaskPixel> const &, Threshold const &, \
1522 std::string const &, int const, bool const);\
1523 template detection::FootprintSet::FootprintSet( \
1524 image::MaskedImage<PIXEL,image::MaskPixel> const &, Threshold const &, \
1525 int, int, std::vector<PTR(Peak)> const *); \
1526 template void detection::FootprintSet::makeHeavy(image::MaskedImage<PIXEL,image::MaskPixel> const &, \
1527 HeavyFootprintCtrl const *)
ImagePtr getImage(bool const noThrow=false) const
Return a (Ptr to) the MaskedImage's image.
x_iterator row_begin(int y) const
for(FootprintList::const_iterator ptr=feet->begin(), end=feet->end();ptr!=end;++ptr)
void swap(ImageBase< PixelT > &a, ImageBase< PixelT > &b)
lsst::afw::detection::Footprint Footprint
definition of the Trace messaging facilities
Use number of sigma given per-pixel s.d.
A Threshold is used to pass a threshold value to detection algorithms.
The base class for all image classed (Image, Mask, MaskedImage, ...)
static int addMaskPlane(const std::string &name)
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)
PixelT Pixel
A pixel in this ImageBase.
boost::shared_ptr< RecordT > addNew()
Create a new record, add it to the end of the catalog, and return a pointer to it.
boost::shared_ptr< Mask > Ptr
An integer coordinate rectangle.
table::Key< table::Array< Kernel::Pixel > > image
VariancePtr getVariance(bool const noThrow=false) const
Return a (Ptr to) the MaskedImage's variance.
boost::uint64_t FootprintIdPixel
float getPeakValue() const
Return the value of the image at the peak.
int getWidth() const
Return the number of columns in the image.
boost::shared_ptr< Footprint > growFootprint(Footprint const &foot, int nGrow, bool isotropic=true)
Use (pixels & (given mask))
static MaskPixelT getPlaneBitMask(const std::vector< std::string > &names)
Return the bitmask corresponding to a vector of plane names OR'd together.
Custom catalog class for record/table subclasses that are guaranteed to have an ID, and should generally be sorted by that ID.
bool getPolarity() const
return Threshold's polarity
Represent a 2-dimensional array of bitmask pixels.
#define INSTANTIATE(TYPE)
int getIx() const
Return the column pixel position.
A class to manipulate images, masks, and variance as a single object.
if(width!=gim.getWidth()||height!=gim.getHeight()||x0!=gim.getX0()||y0!=gim.getY0())
detection::FootprintSet::FootprintList FootprintList
double getIncludeMultiplier() const
return includeMultiplier
Support for peaks in images.
double getValue(const double param=-1) const
#define LSST_EXCEPT(type,...)
MaskPtr getMask(bool const noThrow=false) const
Return a (Ptr to) the MaskedImage's mask.
int resolve_alias(const std::vector< int > &aliases, int id)
Compute Image Statistics.
afw::table::Key< double > b
Record class that contains measurements made on a single exposure.
Implementation of the Class MaskedImage.
int getHeight() const
Return the number of rows in the image.
int getId() const
Return the Peak's unique ID.
ThresholdType getType() const
return type of threshold
A class to represent a 2-dimensional array of pixels.
Extent< int, 2 > Extent2I
Include files required for standard LSST Exception handling.