LSSTApplications  18.0.0+106,18.0.0+50,19.0.0,19.0.0+1,19.0.0+10,19.0.0+11,19.0.0+13,19.0.0+17,19.0.0+2,19.0.0-1-g20d9b18+6,19.0.0-1-g425ff20,19.0.0-1-g5549ca4,19.0.0-1-g580fafe+6,19.0.0-1-g6fe20d0+1,19.0.0-1-g7011481+9,19.0.0-1-g8c57eb9+6,19.0.0-1-gb5175dc+11,19.0.0-1-gdc0e4a7+9,19.0.0-1-ge272bc4+6,19.0.0-1-ge3aa853,19.0.0-10-g448f008b,19.0.0-12-g6990b2c,19.0.0-2-g0d9f9cd+11,19.0.0-2-g3d9e4fb2+11,19.0.0-2-g5037de4,19.0.0-2-gb96a1c4+3,19.0.0-2-gd955cfd+15,19.0.0-3-g2d13df8,19.0.0-3-g6f3c7dc,19.0.0-4-g725f80e+11,19.0.0-4-ga671dab3b+1,19.0.0-4-gad373c5+3,19.0.0-5-ga2acb9c+2,19.0.0-5-gfe96e6c+2,w.2020.01
LSSTDataManagementBasePackage
Namespaces | Classes | Typedefs | Functions
lsst::afw::detection Namespace Reference

Namespaces

 _footprintMerge
 
 _peak
 
 detail
 
 multiband
 
 utils
 

Classes

class  Footprint
 Class to describe the properties of a detected object from an image. More...
 
class  FootprintControl
 A Control Object for Footprints, controlling e.g. More...
 
class  FootprintFactory
 
class  FootprintMerge
 
class  FootprintMergeList
 List of Merged Footprints. More...
 
class  FootprintSet
 A set of Footprints, associated with a MaskedImage. More...
 
class  GaussianPsf
 A circularly symmetric Gaussian Psf class with no spatial variation, intended mostly for testing purposes. More...
 
class  HeavyFootprint
 A set of pixels in an Image, including those pixels' actual values. More...
 
class  HeavyFootprintCtrl
 A control object for HeavyFootprints. More...
 
class  IdSpan
 run-length code for part of object More...
 
struct  IdSpanCompar
 comparison functor; sort by ID, then by row (y), then by column range start (x0) More...
 
class  PeakRecord
 Record class that represents a peak in a Footprint. More...
 
class  PeakTable
 Table class for Peaks in Footprints. More...
 
class  Psf
 A polymorphic base class for representing an image's Point Spread Function. More...
 
class  Threshold
 A Threshold is used to pass a threshold value to detection algorithms. More...
 

Typedefs

typedef std::uint64_t FootprintIdPixel
 Pixel type for FootprintSet::insertIntoImage() More...
 
typedef afw::table::ColumnViewT< PeakRecordPeakColumnView
 
typedef afw::table::CatalogT< PeakRecordPeakCatalog
 
typedef afw::table::CatalogT< PeakRecord const > ConstPeakCatalog
 

Functions

std::shared_ptr< FootprintmergeFootprints (Footprint const &footprint1, Footprint const &footprint2)
 Merges two Footprints – appends their peaks, and unions their spans, returning a new Footprint. More...
 
std::vector< lsst::geom::Box2IfootprintToBBoxList (Footprint const &footprint)
 Return a list of BBoxs, whose union contains exactly the pixels in the footprint, neither more nor less. More...
 
template<typename ImagePixelT , typename MaskPixelT , typename VariancePixelT >
HeavyFootprint< ImagePixelT, MaskPixelT, VariancePixelT > makeHeavyFootprint (Footprint const &foot, lsst::afw::image::MaskedImage< ImagePixelT, MaskPixelT, VariancePixelT > const &img, HeavyFootprintCtrl const *ctrl=NULL)
 Create a HeavyFootprint with footprint defined by the given Footprint and pixel values from the given MaskedImage. More...
 
template<typename ImagePixelT , typename MaskPixelT , typename VariancePixelT >
std::shared_ptr< HeavyFootprint< ImagePixelT, MaskPixelT, VariancePixelT > > mergeHeavyFootprints (HeavyFootprint< ImagePixelT, MaskPixelT, VariancePixelT > const &h1, HeavyFootprint< ImagePixelT, MaskPixelT, VariancePixelT > const &h2)
 Sum the two given HeavyFootprints h1 and h2, returning a HeavyFootprint with the union footprint, and summed pixels where they overlap. More...
 
std::ostreamoperator<< (std::ostream &os, PeakRecord const &record)
 
Threshold createThreshold (const double value, const std::string type="value", const bool polarity=true)
 Factory method for creating Threshold objects. More...
 
void wrapFootprint (WrapperCollection &)
 
void wrapFootprintCtrl (WrapperCollection &)
 
void wrapFootprintMerge (WrapperCollection &)
 
void wrapFootprintSet (WrapperCollection &)
 
void wrapGaussianPsf (WrapperCollection &)
 
void wrapHeavyFootprint (WrapperCollection &)
 
void wrapPeak (WrapperCollection &)
 
void wrapPsf (WrapperCollection &)
 
void wrapThreshold (WrapperCollection &)
 
 PYBIND11_MODULE (_detection, mod)
 
int resolve_alias (const std::vector< int > &aliases, int id)
 Follow a chain of aliases, returning the final resolved value. More...
 

Typedef Documentation

◆ ConstPeakCatalog

Definition at line 245 of file Peak.h.

◆ FootprintIdPixel

Pixel type for FootprintSet::insertIntoImage()

This is independent of the template parameters for FootprintSet, and including it within FootprintSet makes it difficult for SWIG to interpret the type.

Definition at line 48 of file FootprintSet.h.

◆ PeakCatalog

Definition at line 244 of file Peak.h.

◆ PeakColumnView

Definition at line 243 of file Peak.h.

Function Documentation

◆ createThreshold()

Threshold lsst::afw::detection::createThreshold ( const double  value,
const std::string  type = "value",
const bool  polarity = true 
)

Factory method for creating Threshold objects.

Parameters
valuevalue of threshold
typestring representation of a ThresholdType. This parameter is optional. Allowed values are: "variance", "value", "stdev", "pixel_stdev"
polarityIf true detect positive objects, false for negative
Returns
desired Threshold

Definition at line 109 of file Threshold.cc.

109  {
110  return Threshold(value, Threshold::parseTypeString(typeStr), polarity);
111 }

◆ footprintToBBoxList()

std::vector< lsst::geom::Box2I > lsst::afw::detection::footprintToBBoxList ( Footprint const &  footprint)

Return a list of BBoxs, whose union contains exactly the pixels in the footprint, neither more nor less.

Useful in generating sets of meas::algorithms::Defects for the ISR

Parameters
footprintFootprint to turn into bounding box list

Definition at line 352 of file Footprint.cc.

352  {
353  typedef std::uint16_t PixelT;
354  lsst::geom::Box2I fpBBox = footprint.getBBox();
356  *idImage = 0;
357  int const height = fpBBox.getHeight();
358  lsst::geom::Extent2I shift(fpBBox.getMinX(), fpBBox.getMinY());
359  footprint.getSpans()->setImage(*idImage, static_cast<PixelT>(1), fpBBox, true);
360 
362  /*
363  * Our strategy is to find a row of pixels in the Footprint and interpret it as the first
364  * row of a rectangular set of pixels. We then extend this rectangle upwards as far as it
365  * will go, and define that as a BBox. We clear all those pixels, and repeat until there
366  * are none left. I.e. a Footprint will get cut up like this:
367  *
368  * .555...
369  * 22.3314
370  * 22.331.
371  * .000.1.
372  * (as shown in Footprint_1.py)
373  */
374 
375  int y0 = 0; // the first row with non-zero pixels in it
376  while (y0 < height) {
377  lsst::geom::Box2I bbox; // our next BBox
378  for (int y = y0; y != height; ++y) {
379  // Look for a set pixel in this row
380  image::Image<PixelT>::x_iterator begin = idImage->row_begin(y), end = idImage->row_end(y);
382 
383  if (first != end) { // A pixel is set in this row
384  image::Image<PixelT>::x_iterator last = std::find(first, end, 0) - 1;
385  int const x0 = first - begin;
386  int const x1 = last - begin;
387 
388  std::fill(first, last + 1, 0); // clear pixels; we don't want to see them again
389 
390  bbox.include(lsst::geom::Point2I(x0, y)); // the LLC
391  bbox.include(lsst::geom::Point2I(x1, y)); // the LRC; initial guess for URC
392 
393  // we found at least one pixel so extend the BBox upwards
394  for (++y; y != height; ++y) {
395  if (std::find(idImage->at(x0, y), idImage->at(x1 + 1, y), 0) != idImage->at(x1 + 1, y)) {
396  break; // some pixels weren't set, so the BBox stops here, (actually in previous row)
397  }
398  std::fill(idImage->at(x0, y), idImage->at(x1 + 1, y), 0);
399 
400  bbox.include(lsst::geom::Point2I(x1, y)); // the new URC
401  }
402 
403  bbox.shift(shift);
404  bboxes.push_back(bbox);
405  } else {
406  y0 = y + 1;
407  }
408  break;
409  }
410  }
411 
412  return bboxes;
413 }
AmpInfoBoxKey bbox
Definition: Amplifier.cc:117
int getHeight() const noexcept
Definition: Box.h:188
int y
Definition: SpanSet.cc:49
T push_back(T... args)
int getMinX() const noexcept
Definition: Box.h:157
T find(T... args)
STL class.
T begin(T... args)
void include(Point2I const &point)
Expand this to ensure that this->contains(point).
Definition: Box.cc:152
void shift(Extent2I const &offset)
Shift the position of the box by the given offset.
Definition: Box.cc:134
T fill(T... args)
An integer coordinate rectangle.
Definition: Box.h:55
A class to represent a 2-dimensional array of pixels.
Definition: Image.h:58
int end
int getMinY() const noexcept
Definition: Box.h:158

◆ makeHeavyFootprint()

template<typename ImagePixelT , typename MaskPixelT , typename VariancePixelT >
HeavyFootprint<ImagePixelT, MaskPixelT, VariancePixelT> lsst::afw::detection::makeHeavyFootprint ( Footprint const &  foot,
lsst::afw::image::MaskedImage< ImagePixelT, MaskPixelT, VariancePixelT > const &  img,
HeavyFootprintCtrl const *  ctrl = NULL 
)

Create a HeavyFootprint with footprint defined by the given Footprint and pixel values from the given MaskedImage.

Definition at line 148 of file HeavyFootprint.h.

151  {
152  return HeavyFootprint<ImagePixelT, MaskPixelT, VariancePixelT>(foot, img, ctrl);
153 }

◆ mergeFootprints()

std::shared_ptr< Footprint > lsst::afw::detection::mergeFootprints ( Footprint const &  footprint1,
Footprint const &  footprint2 
)

Merges two Footprints – appends their peaks, and unions their spans, returning a new Footprint.

Region is not preserved, and is set to an empty lsst::geom::Box2I object.

Definition at line 327 of file Footprint.cc.

327  {
328  // Bail out early if the schemas are not the same
329  if (footprint1.getPeaks().getSchema() != footprint2.getPeaks().getSchema()) {
330  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError,
331  "Cannot merge Footprints with different Schemas");
332  }
333 
334  // Merge the SpanSets
335  auto unionedSpanSet = footprint1.getSpans()->union_(*(footprint2.getSpans()));
336 
337  // Construct merged Footprint
338  auto mergedFootprint = std::make_shared<Footprint>(unionedSpanSet, footprint1.getPeaks().getSchema());
339  // Copy over the peaks from both footprints
340  mergedFootprint->setPeakCatalog(PeakCatalog(footprint1.getPeaks().getTable()));
341  PeakCatalog& peaks = mergedFootprint->getPeaks();
342  peaks.reserve(footprint1.getPeaks().size() + footprint2.getPeaks().size());
343  peaks.insert(peaks.end(), footprint1.getPeaks().begin(), footprint1.getPeaks().end(), true);
344  peaks.insert(peaks.end(), footprint2.getPeaks().begin(), footprint2.getPeaks().end(), true);
345 
346  // Sort the PeaksCatalog according to value
347  mergedFootprint->sortPeaks();
348 
349  return mergedFootprint;
350 }
afw::table::CatalogT< PeakRecord > PeakCatalog
Definition: Peak.h:244
void reserve(size_type n)
Increase the capacity of the catalog to the given size.
Definition: Catalog.h:428
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48

◆ mergeHeavyFootprints()

template<typename ImagePixelT , typename MaskPixelT , typename VariancePixelT >
std::shared_ptr< HeavyFootprint< ImagePixelT, MaskPixelT, VariancePixelT > > lsst::afw::detection::mergeHeavyFootprints ( HeavyFootprint< ImagePixelT, MaskPixelT, VariancePixelT > const &  h1,
HeavyFootprint< ImagePixelT, MaskPixelT, VariancePixelT > const &  h2 
)

Sum the two given HeavyFootprints h1 and h2, returning a HeavyFootprint with the union footprint, and summed pixels where they overlap.

The peak list is the union of the two inputs.

Definition at line 132 of file HeavyFootprint.cc.

134  {
135  // Merge the Footprints (by merging the Spans)
137 
138  // Find the union bounding-box
139  lsst::geom::Box2I bbox(h1.getBBox());
140  bbox.include(h2.getBBox());
141 
142  // Create union-bb-sized images and insert the heavies
145  h1.insert(im1);
146  h2.insert(im2);
147  // Add the pixels
148  im1 += im2;
149 
150  // Build new HeavyFootprint from the merged spans and summed pixels.
151  return std::make_shared<HeavyFootprint<ImagePixelT, MaskPixelT, VariancePixelT>>(*foot, im1);
152 }
AmpInfoBoxKey bbox
Definition: Amplifier.cc:117
A class to manipulate images, masks, and variance as a single object.
Definition: MaskedImage.h:73
std::shared_ptr< Footprint > mergeFootprints(Footprint const &footprint1, Footprint const &footprint2)
Merges two Footprints – appends their peaks, and unions their spans, returning a new Footprint...
Definition: Footprint.cc:327
An integer coordinate rectangle.
Definition: Box.h:55

◆ operator<<()

std::ostream & lsst::afw::detection::operator<< ( std::ostream os,
PeakRecord const &  record 
)

Definition at line 93 of file Peak.cc.

93  {
94  return os << (boost::format("%d: (%d,%d) (%.3f,%.3f)") % record.getId() % record.getIx() %
95  record.getIy() % record.getFx() % record.getFy());
96 }
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:174

◆ PYBIND11_MODULE()

lsst::afw::detection::PYBIND11_MODULE ( _detection  ,
mod   
)

Definition at line 47 of file _detection.cc.

47  {
48  WrapperCollection wrappers(mod, "lsst.afw.detection");
49  wrapPsf(wrappers);
50  wrapFootprintCtrl(wrappers);
51  wrapFootprint(wrappers);
52  wrapThreshold(wrappers);
53  wrapFootprintSet(wrappers);
54  wrapFootprintMerge(wrappers);
55  wrapPeak(wrappers);
56  wrapGaussianPsf(wrappers);
57  wrapHeavyFootprint(wrappers);
58  wrappers.finish();
59 }
void wrapFootprintMerge(WrapperCollection &)
void wrapGaussianPsf(WrapperCollection &)
Definition: _gaussianPsf.cc:38
void wrapHeavyFootprint(WrapperCollection &)
void wrapFootprintCtrl(WrapperCollection &)
void wrapFootprintSet(WrapperCollection &)
void wrapPeak(WrapperCollection &)
Definition: _peak.cc:101
void wrapPsf(WrapperCollection &)
Definition: _psf.cc:47
void wrapThreshold(WrapperCollection &)
Definition: _threshold.cc:38
void wrapFootprint(WrapperCollection &)
Definition: _footprint.cc:76

◆ resolve_alias()

int lsst::afw::detection::resolve_alias ( const std::vector< int > &  aliases,
int  id 
)

Follow a chain of aliases, returning the final resolved value.

Definition at line 96 of file CR.cc.

97  { /* alias to look up */
98  int resolved = id; /* resolved alias */
99 
100  while (id != aliases[id]) {
101  resolved = id = aliases[id];
102  }
103 
104  return (resolved);
105 }
int id
Definition: CR.cc:143

◆ wrapFootprint()

void lsst::afw::detection::wrapFootprint ( WrapperCollection wrappers)

Definition at line 76 of file _footprint.cc.

76  {
77  wrappers.addInheritanceDependency("lsst.afw.table.io");
78  wrappers.addSignatureDependency("lsst.afw.geom");
79  wrappers.addSignatureDependency("lsst.afw.table");
80 
81  wrappers.wrapType(
82  py::class_<Footprint, std::shared_ptr<Footprint>>(wrappers.module, "Footprint"),
83  [](auto &mod, auto &cls) {
84  cls.def(py::init<std::shared_ptr<geom::SpanSet>, lsst::geom::Box2I const &>(), "inputSpans"_a,
85  "region"_a = lsst::geom::Box2I());
86 
87  cls.def(py::init<std::shared_ptr<geom::SpanSet>, afw::table::Schema const &,
88  lsst::geom::Box2I const &>(),
89  "inputSpans"_a, "peakSchema"_a, "region"_a = lsst::geom::Box2I());
90  cls.def(py::init<Footprint const &>());
91  cls.def(py::init<>());
92 
93  table::io::python::addPersistableMethods<Footprint>(cls);
94 
95  cls.def("getSpans", &Footprint::getSpans);
96  cls.def("setSpans", &Footprint::setSpans);
97  cls.def("getPeaks", (PeakCatalog & (Footprint::*)()) & Footprint::getPeaks,
98  py::return_value_policy::reference_internal);
99  cls.def("addPeak", &Footprint::addPeak);
100  cls.def("sortPeaks", &Footprint::sortPeaks, "key"_a = afw::table::Key<float>());
101  cls.def("setPeakSchema", &Footprint::setPeakSchema);
102  cls.def("setPeakCatalog", &Footprint::setPeakCatalog, "otherPeaks"_a);
103  cls.def("getArea", &Footprint::getArea);
104  cls.def("getCentroid", &Footprint::getCentroid);
105  cls.def("getShape", &Footprint::getShape);
106  cls.def("shift", (void (Footprint::*)(int, int)) & Footprint::shift);
107  cls.def("shift", (void (Footprint::*)(lsst::geom::ExtentI const &)) & Footprint::shift);
108  cls.def("getBBox", &Footprint::getBBox);
109  cls.def("getRegion", &Footprint::getRegion);
110  cls.def("setRegion", &Footprint::setRegion);
111  cls.def("clipTo", &Footprint::clipTo);
112  cls.def("contains", &Footprint::contains);
113  cls.def("transform",
114  (std::shared_ptr<Footprint>(Footprint::*)(std::shared_ptr<geom::SkyWcs>,
115  std::shared_ptr<geom::SkyWcs>,
116  lsst::geom::Box2I const &, bool) const) &
117  Footprint::transform,
118  "source"_a, "target"_a, "region"_a, "doClip"_a = true);
119  cls.def("transform",
120  (std::shared_ptr<Footprint>(Footprint::*)(lsst::geom::LinearTransform const &,
121  lsst::geom::Box2I const &, bool) const) &
122  Footprint::transform);
123  cls.def("transform",
124  (std::shared_ptr<Footprint>(Footprint::*)(lsst::geom::AffineTransform const &,
125  lsst::geom::Box2I const &, bool) const) &
126  Footprint::transform);
127  cls.def("transform",
128  (std::shared_ptr<Footprint>(Footprint::*)(geom::TransformPoint2ToPoint2 const &,
129  lsst::geom::Box2I const &, bool) const) &
130  Footprint::transform);
131  cls.def("dilate", (void (Footprint::*)(int, geom::Stencil)) & Footprint::dilate, "r"_a,
132  "stencil"_a = geom::Stencil::CIRCLE);
133  cls.def("dilate", (void (Footprint::*)(geom::SpanSet const &)) & Footprint::dilate);
134  cls.def("erode", (void (Footprint::*)(int, geom::Stencil)) & Footprint::erode, "r"_a,
135  "stencil"_a = geom::Stencil::CIRCLE);
136  cls.def("erode", (void (Footprint::*)(geom::SpanSet const &)) & Footprint::erode);
137  cls.def("removeOrphanPeaks", &Footprint::removeOrphanPeaks);
138  cls.def("isContiguous", &Footprint::isContiguous);
139  cls.def("isHeavy", &Footprint::isHeavy);
140  cls.def("assign", (Footprint & (Footprint::*)(Footprint const &)) & Footprint::operator=);
141 
142  cls.def("split", [](Footprint const &self) -> py::list {
143  /* This is a work around for pybind not properly
144  * handling converting a vector of unique pointers
145  * to python lists of shared pointers */
146  py::list l;
147  for (auto &ptr : self.split()) {
148  l.append(py::cast(std::shared_ptr<Footprint>(std::move(ptr))));
149  }
150  return l;
151  });
152 
153  cls.def_property("spans", &Footprint::getSpans, &Footprint::setSpans);
154  cls.def_property_readonly("peaks", (PeakCatalog & (Footprint::*)()) & Footprint::getPeaks,
155  py::return_value_policy::reference_internal);
156 
157  cls.def("__contains__", [](Footprint const &self, lsst::geom::Point2I const &point) -> bool {
158  return self.contains(point);
159  });
160  cls.def("__eq__",
161  [](Footprint const &self, Footprint const &other) -> bool { return self == other; },
162  py::is_operator());
163  });
164 
165  declareMaskFromFootprintList<lsst::afw::image::MaskPixel>(wrappers);
166 
167  wrappers.wrap([](auto &mod) {
168  mod.def("mergeFootprints", &mergeFootprints);
169  mod.def("footprintToBBoxList", &footprintToBBoxList);
170  });
171 }
ItemVariant const * other
Definition: Schema.cc:56
afw::table::CatalogT< PeakRecord > PeakCatalog
Definition: Peak.h:244
std::shared_ptr< Footprint > mergeFootprints(Footprint const &footprint1, Footprint const &footprint2)
Merges two Footprints – appends their peaks, and unions their spans, returning a new Footprint...
Definition: Footprint.cc:327
std::vector< lsst::geom::Box2I > footprintToBBoxList(Footprint const &footprint)
Return a list of BBoxs, whose union contains exactly the pixels in the footprint, neither more nor le...
Definition: Footprint.cc:352
lsst::afw::detection::Footprint Footprint
Definition: Source.h:59

◆ wrapFootprintCtrl()

void lsst::afw::detection::wrapFootprintCtrl ( WrapperCollection wrappers)

Definition at line 39 of file _footprintCtrl.cc.

39  {
40  wrappers.wrapType(py::class_<FootprintControl>(wrappers.module, "FootprintControl"),
41  [](auto& mod, auto& cls) {
42  cls.def(py::init<>());
43  cls.def(py::init<bool, bool>(), "circular"_a, "isotropic"_a = false);
44  cls.def(py::init<bool, bool, bool, bool>(), "left"_a, "right"_a, "up"_a, "down"_a);
45 
46  cls.def("growCircular", &FootprintControl::growCircular);
47  cls.def("growIsotropic", &FootprintControl::growIsotropic);
48  cls.def("growLeft", &FootprintControl::growLeft);
49  cls.def("growRight", &FootprintControl::growRight);
50  cls.def("growUp", &FootprintControl::growUp);
51  cls.def("growDown", &FootprintControl::growDown);
52 
53  cls.def("isCircular", &FootprintControl::isCircular);
54  cls.def("isIsotropic", &FootprintControl::isIsotropic);
55  cls.def("isLeft", &FootprintControl::isLeft);
56  cls.def("isRight", &FootprintControl::isRight);
57  cls.def("isUp", &FootprintControl::isUp);
58  cls.def("isDown", &FootprintControl::isDown);
59  });
60 
61  auto clsHeavyFootprintCtrl = wrappers.wrapType(
62  py::class_<HeavyFootprintCtrl>(wrappers.module, "HeavyFootprintCtrl"), [](auto& mod, auto& cls) {
63  cls.def(py::init<HeavyFootprintCtrl::ModifySource>(),
64  "modifySource"_a = HeavyFootprintCtrl::ModifySource::NONE);
65 
66  cls.def("getModifySource", &HeavyFootprintCtrl::getModifySource);
67  cls.def("setModifySource", &HeavyFootprintCtrl::setModifySource);
68  cls.def("getImageVal", &HeavyFootprintCtrl::getImageVal);
69  cls.def("setImageVal", &HeavyFootprintCtrl::setImageVal);
70  cls.def("getMaskVal", &HeavyFootprintCtrl::getMaskVal);
71  cls.def("setMaskVal", &HeavyFootprintCtrl::setMaskVal);
72  cls.def("getVarianceVal", &HeavyFootprintCtrl::getVarianceVal);
73  cls.def("setVarianceVal", &HeavyFootprintCtrl::setVarianceVal);
74  });
75 
76  wrappers.wrapType(py::enum_<HeavyFootprintCtrl::ModifySource>(clsHeavyFootprintCtrl, "ModifySource"),
77  [](auto& mod, auto& enm) {
78  enm.value("NONE", HeavyFootprintCtrl::ModifySource::NONE);
79  enm.value("SET", HeavyFootprintCtrl::ModifySource::SET);
80  enm.export_values();
81  });
82 }

◆ wrapFootprintMerge()

void lsst::afw::detection::wrapFootprintMerge ( WrapperCollection wrappers)

Definition at line 38 of file _footprintMerge.cc.

38  {
39  wrappers.addSignatureDependency("lsst.afw.table");
40 
41  wrappers.wrapType(
42  py::class_<FootprintMergeList>(wrappers.module, "FootprintMergeList"), [](auto &mod, auto &cls) {
43  cls.def(py::init<afw::table::Schema &, std::vector<std::string> const &,
44  afw::table::Schema const &>(),
45  "sourceSchema"_a, "filterList"_a, "initialPeakSchema"_a);
46  cls.def(py::init<afw::table::Schema &, std::vector<std::string> const &>(), "sourceSchema"_a,
47  "filterList"_a);
48 
49  cls.def("getPeakSchema", &FootprintMergeList::getPeakSchema);
50  cls.def("addCatalog", &FootprintMergeList::addCatalog, "sourceTable"_a, "inputCat"_a,
51  "filter"_a, "minNewPeakDist"_a = -1., "doMerge"_a = true, "maxSamePeakDist"_a = -1.);
52  cls.def("clearCatalog", &FootprintMergeList::clearCatalog);
53  cls.def("getFinalSources", &FootprintMergeList::getFinalSources, "outputCat"_a);
54  });
55 }

◆ wrapFootprintSet()

void lsst::afw::detection::wrapFootprintSet ( WrapperCollection wrappers)

Definition at line 84 of file _footprintSet.cc.

84  {
85  wrappers.addSignatureDependency("lsst.afw.image");
86  wrappers.addSignatureDependency("lsst.afw.table");
87 
88  wrappers.wrapType(
89  py::class_<FootprintSet, std::shared_ptr<FootprintSet>>(wrappers.module, "FootprintSet"),
90  [](auto &mod, auto &cls) {
91  declareTemplatedMembers<std::uint16_t>(cls);
92  declareTemplatedMembers<int>(cls);
93  declareTemplatedMembers<float>(cls);
94  declareTemplatedMembers<double>(cls);
95 
96  cls.def(py::init<image::Mask<image::MaskPixel> const &, Threshold const &, int const>(),
97  "img"_a, "threshold"_a, "npixMin"_a = 1);
98 
99  cls.def(py::init<lsst::geom::Box2I>(), "region"_a);
100  cls.def(py::init<FootprintSet const &>(), "set"_a);
101  cls.def(py::init<FootprintSet const &, int, FootprintControl const &>(), "set"_a, "rGrow"_a,
102  "ctrl"_a);
103  cls.def(py::init<FootprintSet const &, int, bool>(), "set"_a, "rGrow"_a, "isotropic"_a);
104  cls.def(py::init<FootprintSet const &, FootprintSet const &, bool>(), "footprints1"_a,
105  "footprints2"_a, "includePeaks"_a);
106 
107  cls.def("swap", &FootprintSet::swap);
108  // setFootprints takes shared_ptr<FootprintList> and getFootprints returns it,
109  // but pybind11 can't handle that type, so use a custom getter and setter
110  cls.def("setFootprints", [](FootprintSet &self, FootprintSet::FootprintList footList) {
111  self.setFootprints(std::make_shared<FootprintSet::FootprintList>(std::move(footList)));
112  });
113  cls.def("getFootprints", [](FootprintSet &self) { return *(self.getFootprints()); });
114  cls.def("makeSources", &FootprintSet::makeSources);
115  cls.def("setRegion", &FootprintSet::setRegion);
116  cls.def("getRegion", &FootprintSet::getRegion);
117  cls.def("insertIntoImage", &FootprintSet::insertIntoImage);
118  cls.def("setMask", (void (FootprintSet::*)(image::Mask<lsst::afw::image::MaskPixel> *,
119  std::string const &)) &
120  FootprintSet::setMask<lsst::afw::image::MaskPixel>);
121  cls.def("setMask",
123  std::string const &)) &
124  FootprintSet::setMask<lsst::afw::image::MaskPixel>);
125  cls.def("merge", &FootprintSet::merge, "rhs"_a, "tGrow"_a = 0, "rGrow"_a = 0,
126  "isotropic"_a = true);
127  });
128 }
STL class.
Represent a 2-dimensional array of bitmask pixels.
Definition: Mask.h:77

◆ wrapGaussianPsf()

void lsst::afw::detection::wrapGaussianPsf ( WrapperCollection wrappers)

Definition at line 38 of file _gaussianPsf.cc.

38  {
39  wrappers.wrapType(
40  py::class_<GaussianPsf, std::shared_ptr<GaussianPsf>, Psf>(wrappers.module, "GaussianPsf"),
41  [](auto& mod, auto& cls) {
42  table::io::python::addPersistableMethods<GaussianPsf>(cls);
43 
44  cls.def(py::init<int, int, double>(), "width"_a, "height"_a, "sigma"_a);
45  cls.def(py::init<lsst::geom::Extent2I const&, double>(), "dimensions"_a, "sigma"_a);
46 
47  cls.def("clone", &GaussianPsf::clone);
48  cls.def("resized", &GaussianPsf::resized, "width"_a, "height"_a);
49  cls.def("getDimensions", &GaussianPsf::getDimensions);
50  cls.def("getSigma", &GaussianPsf::getSigma);
51  cls.def("isPersistable", &GaussianPsf::isPersistable);
52  });
53 }

◆ wrapHeavyFootprint()

void lsst::afw::detection::wrapHeavyFootprint ( WrapperCollection wrappers)

Definition at line 88 of file _heavyFootprint.cc.

88  {
89  wrappers.addSignatureDependency("lsst.afw.image");
90 
91  declareHeavyFootprint<int>(wrappers, "I");
92  declareHeavyFootprint<std::uint16_t>(wrappers, "U");
93  declareHeavyFootprint<float>(wrappers, "F");
94  declareHeavyFootprint<double>(wrappers, "D");
95 }

◆ wrapPeak()

void lsst::afw::detection::wrapPeak ( WrapperCollection wrappers)

Definition at line 101 of file _peak.cc.

101  {
102  wrappers.addInheritanceDependency("lsst.afw.table");
103 
104  auto clsPeakRecord = wrappers.wrapType(PyPeakRecord(wrappers.module, "PeakRecord"),
105  [](auto &mod, auto &cls) { declarePeakRecord(cls); });
106  auto clsPeakTable = wrappers.wrapType(PyPeakTable(wrappers.module, "PeakTable"),
107  [](auto &mod, auto &cls) { declarePeakTable(cls); });
108 
109  auto clsPeakColumnView = table::python::declareColumnView<PeakRecord>(wrappers, "Peak");
110  auto clsPeakCatalog = table::python::declareCatalog<PeakRecord>(wrappers, "Peak");
111 
112  clsPeakRecord.attr("Table") = clsPeakTable;
113  clsPeakRecord.attr("ColumnView") = clsPeakColumnView;
114  clsPeakRecord.attr("Catalog") = clsPeakCatalog;
115  clsPeakTable.attr("Record") = clsPeakRecord;
116  clsPeakTable.attr("ColumnView") = clsPeakColumnView;
117  clsPeakTable.attr("Catalog") = clsPeakCatalog;
118  clsPeakCatalog.attr("Record") = clsPeakRecord;
119  clsPeakCatalog.attr("Table") = clsPeakTable;
120  clsPeakCatalog.attr("ColumnView") = clsPeakColumnView;
121 }

◆ wrapPsf()

void lsst::afw::detection::wrapPsf ( WrapperCollection wrappers)

Definition at line 47 of file _psf.cc.

47  {
48  wrappers.addInheritanceDependency("lsst.afw.typehandling");
49  wrappers.addSignatureDependency("lsst.afw.geom.ellipses");
50  wrappers.addSignatureDependency("lsst.afw.image");
51  wrappers.addSignatureDependency("lsst.afw.fits");
52 
53  auto clsPsf = wrappers.wrapType(
54  py::class_<Psf, std::shared_ptr<Psf>, typehandling::Storable>(wrappers.module, "Psf"),
55  [](auto& mod, auto& cls) {
56  table::io::python::addPersistableMethods<Psf>(cls);
57 
58  cls.def("clone", &Psf::clone);
59  cls.def("resized", &Psf::resized, "width"_a, "height"_a);
60  cls.def("computeImage", &Psf::computeImage, "position"_a = NullPoint,
61  "color"_a = image::Color(), "owner"_a = Psf::ImageOwnerEnum::COPY);
62  cls.def("computeKernelImage", &Psf::computeKernelImage, "position"_a = NullPoint,
63  "color"_a = image::Color(), "owner"_a = Psf::ImageOwnerEnum::COPY);
64  cls.def("computePeak", &Psf::computePeak, "position"_a = NullPoint,
65  "color"_a = image::Color());
66  cls.def("computeApertureFlux", &Psf::computeApertureFlux, "radius"_a,
67  "position"_a = NullPoint, "color"_a = image::Color());
68  cls.def("computeShape", &Psf::computeShape, "position"_a = NullPoint,
69  "color"_a = image::Color());
70  cls.def("computeBBox", &Psf::computeBBox, "position"_a = NullPoint,
71  "color"_a = image::Color());
72  cls.def("getLocalKernel", &Psf::getLocalKernel, "position"_a = NullPoint,
73  "color"_a = image::Color());
74  cls.def("getAverageColor", &Psf::getAverageColor);
75  cls.def("getAveragePosition", &Psf::getAveragePosition);
76  cls.def_static("recenterKernelImage", &Psf::recenterKernelImage, "im"_a, "position"_a,
77  "warpAlgorithm"_a = "lanczos5", "warpBuffer"_a = 5);
78  cls.def("getCacheCapacity", &Psf::getCacheCapacity);
79  cls.def("setCacheCapacity", &Psf::setCacheCapacity);
80  });
81 
82  wrappers.wrapType(py::enum_<Psf::ImageOwnerEnum>(clsPsf, "ImageOwnerEnum"), [](auto& mod, auto& enm) {
83  enm.value("COPY", Psf::ImageOwnerEnum::COPY);
84  enm.value("INTERNAL", Psf::ImageOwnerEnum::INTERNAL);
85  enm.export_values();
86  });
87 }

◆ wrapThreshold()

void lsst::afw::detection::wrapThreshold ( WrapperCollection wrappers)

Definition at line 38 of file _threshold.cc.

38  {
39  auto clsThreshold = wrappers.wrapType(
40  py::class_<Threshold, std::shared_ptr<Threshold>>(wrappers.module, "Threshold"),
41  [](auto& mod, auto& cls) {
42  cls.def(py::init<double const, typename Threshold::ThresholdType const, bool const,
43  double const>(),
44  "value"_a, "type"_a = Threshold::VALUE, "polarity"_a = true,
45  "includeMultiplier"_a = 1.0);
46 
47  cls.def("getType", &Threshold::getType);
48  cls.def_static("parseTypeString", Threshold::parseTypeString);
49  cls.def_static("getTypeString", Threshold::getTypeString);
50  cls.def("getValue", (double (Threshold::*)(const double) const) & Threshold::getValue,
51  "param"_a = -1);
52  //
53  // template<typename ImageT>
54  // double getValue(ImageT const& image) const;
55  //
56  cls.def("getPolarity", &Threshold::getPolarity);
57  cls.def("setPolarity", &Threshold::setPolarity);
58  cls.def("getIncludeMultiplier", &Threshold::getIncludeMultiplier);
59  cls.def("setIncludeMultiplier", &Threshold::setIncludeMultiplier);
60  });
61 
62  wrappers.wrapType(py::enum_<Threshold::ThresholdType>(clsThreshold, "ThresholdType"),
63  [](auto& mod, auto& enm) {
64  enm.value("VALUE", Threshold::ThresholdType::VALUE);
65  enm.value("BITMASK", Threshold::ThresholdType::BITMASK);
66  enm.value("STDEV", Threshold::ThresholdType::STDEV);
67  enm.value("VARIANCE", Threshold::ThresholdType::VARIANCE);
68  enm.value("PIXEL_STDEV", Threshold::ThresholdType::PIXEL_STDEV);
69  enm.export_values();
70  });
71 
72  wrappers.wrap([](auto& mod) {
73  mod.def("createThreshold", createThreshold, "value"_a, "type"_a = "value", "polarity"_a = true);
74  });
75 }
estimate sample standard deviation
Definition: Statistics.h:68
Threshold createThreshold(const double value, const std::string type="value", const bool polarity=true)
Factory method for creating Threshold objects.
Definition: Threshold.cc:109
estimate sample variance
Definition: Statistics.h:69