LSSTApplications  17.0+11,17.0+34,17.0+56,17.0+57,17.0+59,17.0+7,17.0-1-g377950a+33,17.0.1-1-g114240f+2,17.0.1-1-g4d4fbc4+28,17.0.1-1-g55520dc+49,17.0.1-1-g5f4ed7e+52,17.0.1-1-g6dd7d69+17,17.0.1-1-g8de6c91+11,17.0.1-1-gb9095d2+7,17.0.1-1-ge9fec5e+5,17.0.1-1-gf4e0155+55,17.0.1-1-gfc65f5f+50,17.0.1-1-gfc6fb1f+20,17.0.1-10-g87f9f3f+1,17.0.1-11-ge9de802+16,17.0.1-16-ga14f7d5c+4,17.0.1-17-gc79d625+1,17.0.1-17-gdae4c4a+8,17.0.1-2-g26618f5+29,17.0.1-2-g54f2ebc+9,17.0.1-2-gf403422+1,17.0.1-20-g2ca2f74+6,17.0.1-23-gf3eadeb7+1,17.0.1-3-g7e86b59+39,17.0.1-3-gb5ca14a,17.0.1-3-gd08d533+40,17.0.1-30-g596af8797,17.0.1-4-g59d126d+4,17.0.1-4-gc69c472+5,17.0.1-6-g5afd9b9+4,17.0.1-7-g35889ee+1,17.0.1-7-gc7c8782+18,17.0.1-9-gc4bbfb2+3,w.2019.22
LSSTDataManagementBasePackage
Namespaces | Classes | Typedefs | Functions
lsst::afw::detection Namespace Reference

Namespaces

 detail
 
 detectionLib
 
 footprintMerge
 
 multiband
 
 peak
 
 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...
 
 PYBIND11_MODULE (footprint, mod)
 
 PYBIND11_MODULE (footprintCtrl, mod)
 
 PYBIND11_MODULE (footprintMerge, mod)
 
 PYBIND11_MODULE (footprintSet, mod)
 
 PYBIND11_MODULE (gaussianPsf, mod)
 
 PYBIND11_MODULE (heavyFootprint, mod)
 
 PYBIND11_MODULE (peak, mod)
 
 PYBIND11_MODULE (psf, mod)
 
 PYBIND11_MODULE (threshold, 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 358 of file Footprint.cc.

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

◆ 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 333 of file Footprint.cc.

333  {
334  // Bail out early if the schemas are not the same
335  if (footprint1.getPeaks().getSchema() != footprint2.getPeaks().getSchema()) {
336  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError,
337  "Cannot merge Footprints with different Schemas");
338  }
339 
340  // Merge the SpanSets
341  auto unionedSpanSet = footprint1.getSpans()->union_(*(footprint2.getSpans()));
342 
343  // Construct merged Footprint
344  auto mergedFootprint = std::make_shared<Footprint>(unionedSpanSet, footprint1.getPeaks().getSchema());
345  // Copy over the peaks from both footprints
346  mergedFootprint->setPeakCatalog(PeakCatalog(footprint1.getPeaks().getTable()));
347  PeakCatalog& peaks = mergedFootprint->getPeaks();
348  peaks.reserve(footprint1.getPeaks().size() + footprint2.getPeaks().size());
349  peaks.insert(peaks.end(), footprint1.getPeaks().begin(), footprint1.getPeaks().end(), true);
350  peaks.insert(peaks.end(), footprint2.getPeaks().begin(), footprint2.getPeaks().end(), true);
351 
352  // Sort the PeaksCatalog according to value
353  mergedFootprint->sortPeaks();
354 
355  return mergedFootprint;
356 }
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 }
A class to manipulate images, masks, and variance as a single object.
Definition: MaskedImage.h:74
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:333
table::Box2IKey bbox
Definition: Detector.cc:169
An integer coordinate rectangle.
Definition: Box.h:54

◆ 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:168

◆ PYBIND11_MODULE() [1/9]

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

Definition at line 35 of file threshold.cc.

35  {
36  py::class_<Threshold, std::shared_ptr<Threshold>> clsThreshold(mod, "Threshold");
37 
38  /* Member types and enums */
39  py::enum_<Threshold::ThresholdType>(clsThreshold, "ThresholdType")
40  .value("VALUE", Threshold::ThresholdType::VALUE)
41  .value("BITMASK", Threshold::ThresholdType::BITMASK)
42  .value("STDEV", Threshold::ThresholdType::STDEV)
43  .value("VARIANCE", Threshold::ThresholdType::VARIANCE)
44  .value("PIXEL_STDEV", Threshold::ThresholdType::PIXEL_STDEV)
45  .export_values();
46 
47  /* Constructors */
48  clsThreshold.def(
49  py::init<double const, typename Threshold::ThresholdType const, bool const, double const>(),
50  "value"_a, "type"_a = Threshold::VALUE, "polarity"_a = true, "includeMultiplier"_a = 1.0);
51 
52  /* Members */
53  clsThreshold.def("getType", &Threshold::getType);
54  clsThreshold.def_static("parseTypeString", Threshold::parseTypeString);
55  clsThreshold.def_static("getTypeString", Threshold::getTypeString);
56  clsThreshold.def("getValue", (double (Threshold::*)(const double) const) & Threshold::getValue,
57  "param"_a = -1);
58  //
59  // template<typename ImageT>
60  // double getValue(ImageT const& image) const;
61  //
62  clsThreshold.def("getPolarity", &Threshold::getPolarity);
63  clsThreshold.def("setPolarity", &Threshold::setPolarity);
64  clsThreshold.def("getIncludeMultiplier", &Threshold::getIncludeMultiplier);
65  clsThreshold.def("setIncludeMultiplier", &Threshold::setIncludeMultiplier);
66 
67  /* Module level */
68  mod.def("createThreshold", createThreshold, "value"_a, "type"_a = "value", "polarity"_a = true);
69 }
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

◆ PYBIND11_MODULE() [2/9]

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

Definition at line 36 of file footprintMerge.cc.

36  {
37  py::class_<FootprintMergeList> clsFootprintMergeList(mod, "FootprintMergeList");
38 
39  /* Constructors */
40  clsFootprintMergeList.def(
41  py::init<afw::table::Schema &, std::vector<std::string> const &, afw::table::Schema const &>(),
42  "sourceSchema"_a, "filterList"_a, "initialPeakSchema"_a);
43  clsFootprintMergeList.def(py::init<afw::table::Schema &, std::vector<std::string> const &>(),
44  "sourceSchema"_a, "filterList"_a);
45 
46  /* Members */
47  clsFootprintMergeList.def("getPeakSchema", &FootprintMergeList::getPeakSchema);
48  clsFootprintMergeList.def("addCatalog", &FootprintMergeList::addCatalog, "sourceTable"_a, "inputCat"_a,
49  "filter"_a, "minNewPeakDist"_a = -1., "doMerge"_a = true,
50  "maxSamePeakDist"_a = -1.);
51  clsFootprintMergeList.def("clearCatalog", &FootprintMergeList::clearCatalog);
52  clsFootprintMergeList.def("getFinalSources", &FootprintMergeList::getFinalSources, "outputCat"_a);
53 }
def init()
Definition: tests.py:75

◆ PYBIND11_MODULE() [3/9]

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

Definition at line 37 of file footprintCtrl.cc.

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

◆ PYBIND11_MODULE() [4/9]

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

Definition at line 37 of file gaussianPsf.cc.

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

◆ PYBIND11_MODULE() [5/9]

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

Definition at line 45 of file psf.cc.

45  {
46  /* Module level */
47  py::class_<Psf, std::shared_ptr<Psf>, daf::base::Citizen> cls(mod, "Psf");
48 
49  /* Member types and enums */
50  py::enum_<Psf::ImageOwnerEnum>(cls, "ImageOwnerEnum")
51  .value("COPY", Psf::ImageOwnerEnum::COPY)
52  .value("INTERNAL", Psf::ImageOwnerEnum::INTERNAL)
53  .export_values();
54 
55  table::io::python::addPersistableMethods<Psf>(cls);
56 
57  /* Members */
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, "color"_a = image::Color(),
61  "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, "color"_a = image::Color());
65  cls.def("computeApertureFlux", &Psf::computeApertureFlux, "radius"_a, "position"_a = NullPoint,
66  "color"_a = image::Color());
67  cls.def("computeShape", &Psf::computeShape, "position"_a = NullPoint, "color"_a = image::Color());
68  cls.def("computeBBox", &Psf::computeBBox, "position"_a = NullPoint, "color"_a = image::Color());
69  cls.def("getLocalKernel", &Psf::getLocalKernel, "position"_a = NullPoint, "color"_a = image::Color());
70  cls.def("getAverageColor", &Psf::getAverageColor);
71  cls.def("getAveragePosition", &Psf::getAveragePosition);
72  cls.def_static("recenterKernelImage", &Psf::recenterKernelImage, "im"_a, "position"_a,
73  "warpAlgorithm"_a = "lanczos5", "warpBuffer"_a = 5);
74  cls.def("getCacheCapacity", &Psf::getCacheCapacity);
75  cls.def("setCacheCapacity", &Psf::setCacheCapacity);
76 }
Describe the colour of a source.
Definition: Color.h:26

◆ PYBIND11_MODULE() [6/9]

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

Definition at line 69 of file footprint.cc.

69  {
70  /* Footprint Constructors */
71  py::class_<Footprint, std::shared_ptr<Footprint>, daf::base::Citizen> clsFootprint(mod, "Footprint");
72  clsFootprint.def(py::init<std::shared_ptr<geom::SpanSet>, lsst::geom::Box2I const &>(), "inputSpans"_a,
73  "region"_a = lsst::geom::Box2I());
74 
75  clsFootprint.def(
76  py::init<std::shared_ptr<geom::SpanSet>, afw::table::Schema const &, lsst::geom::Box2I const &>(),
77  "inputSpans"_a, "peakSchema"_a, "region"_a = lsst::geom::Box2I());
78  clsFootprint.def(py::init<Footprint const &>());
79  clsFootprint.def(py::init<>());
80 
81  table::io::python::addPersistableMethods<Footprint>(clsFootprint);
82 
83  /* Footprint Methods */
84  clsFootprint.def("getSpans", &Footprint::getSpans);
85  clsFootprint.def("setSpans", &Footprint::setSpans);
86  clsFootprint.def("getPeaks", (PeakCatalog & (Footprint::*)()) & Footprint::getPeaks,
87  py::return_value_policy::reference_internal);
88  clsFootprint.def("addPeak", &Footprint::addPeak);
89  clsFootprint.def("sortPeaks", &Footprint::sortPeaks, "key"_a = afw::table::Key<float>());
90  clsFootprint.def("setPeakSchema", &Footprint::setPeakSchema);
91  clsFootprint.def("setPeakCatalog", &Footprint::setPeakCatalog, "otherPeaks"_a);
92  clsFootprint.def("getArea", &Footprint::getArea);
93  clsFootprint.def("getCentroid", &Footprint::getCentroid);
94  clsFootprint.def("getShape", &Footprint::getShape);
95  clsFootprint.def("shift", (void (Footprint::*)(int, int)) & Footprint::shift);
96  clsFootprint.def("shift", (void (Footprint::*)(lsst::geom::ExtentI const &)) & Footprint::shift);
97  clsFootprint.def("getBBox", &Footprint::getBBox);
98  clsFootprint.def("getRegion", &Footprint::getRegion);
99  clsFootprint.def("setRegion", &Footprint::setRegion);
100  clsFootprint.def("clipTo", &Footprint::clipTo);
101  clsFootprint.def("contains", &Footprint::contains);
102  clsFootprint.def("transform", (std::shared_ptr<Footprint> (Footprint::*)(
104  lsst::geom::Box2I const &, bool) const) &
106  "source"_a, "target"_a, "region"_a, "doClip"_a = true);
107  clsFootprint.def("transform", (std::shared_ptr<Footprint> (Footprint::*)(
108  lsst::geom::LinearTransform const &, lsst::geom::Box2I const &, bool) const) &
109  Footprint::transform);
110  clsFootprint.def("transform", (std::shared_ptr<Footprint> (Footprint::*)(
111  lsst::geom::AffineTransform const &, lsst::geom::Box2I const &, bool) const) &
112  Footprint::transform);
113  clsFootprint.def("transform",
115  lsst::geom::Box2I const &, bool) const) &
116  Footprint::transform);
117  clsFootprint.def("dilate", (void (Footprint::*)(int, geom::Stencil)) & Footprint::dilate, "r"_a,
118  "stencil"_a = geom::Stencil::CIRCLE);
119  clsFootprint.def("dilate", (void (Footprint::*)(geom::SpanSet const &)) & Footprint::dilate);
120  clsFootprint.def("erode", (void (Footprint::*)(int, geom::Stencil)) & Footprint::erode, "r"_a,
121  "stencil"_a = geom::Stencil::CIRCLE);
122  clsFootprint.def("erode", (void (Footprint::*)(geom::SpanSet const &)) & Footprint::erode);
123  clsFootprint.def("removeOrphanPeaks", &Footprint::removeOrphanPeaks);
124  clsFootprint.def("isContiguous", &Footprint::isContiguous);
125  clsFootprint.def("isHeavy", &Footprint::isHeavy);
126  clsFootprint.def("assign", (Footprint & (Footprint::*)(Footprint const &)) & Footprint::operator=);
127  clsFootprint.def("split", [](Footprint const &self) -> py::list {
128  // This is a work around for pybind not properly
129  // handling converting a vector of unique pointers
130  // to python lists of shared pointers
131  py::list l;
132  for (auto &ptr : self.split()) {
133  l.append(py::cast(std::shared_ptr<Footprint>(std::move(ptr))));
134  }
135  return l;
136  });
137 
138  /* Define python level properties */
139  clsFootprint.def_property("spans", &Footprint::getSpans, &Footprint::setSpans);
140  clsFootprint.def_property_readonly("peaks", (PeakCatalog & (Footprint::*)()) & Footprint::getPeaks,
141  py::return_value_policy::reference);
142 
143  /* Python Operators functions */
144  clsFootprint.def("__contains__", [](Footprint const &self, lsst::geom::Point2I const &point) -> bool {
145  return self.contains(point);
146  });
147  clsFootprint.def("__eq__",
148  [](Footprint const &self, Footprint const &other) -> bool { return self == other; },
149  py::is_operator());
150 
151  declareMaskFromFootprintList<lsst::afw::image::MaskPixel>(mod);
152 
153  mod.def("mergeFootprints", &mergeFootprints);
154  mod.def("footprintToBBoxList", &footprintToBBoxList);
155 }
uint64_t * ptr
Definition: RangeSet.cc:88
Stencil
An enumeration class which describes the shapes.
Definition: SpanSet.h:66
bool contains(VertexIterator const begin, VertexIterator const end, UnitVector3d const &v)
An affine coordinate transformation consisting of a linear transformation and an offset.
def init()
Definition: tests.py:75
Transform< Point2Endpoint, Point2Endpoint > TransformPoint2ToPoint2
Definition: Transform.h:300
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:333
T move(T... args)
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:358
lsst::afw::detection::Footprint Footprint
Definition: Source.h:61
ItemVariant const * other
Definition: Schema.cc:56
table::Key< int > transform
An integer coordinate rectangle.
Definition: Box.h:54
daf::base::PropertyList * list
Definition: fits.cc:885
A 2D linear coordinate transformation.

◆ PYBIND11_MODULE() [7/9]

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

Definition at line 80 of file footprintSet.cc.

80  {
81  py::module::import("lsst.afw.detection.footprint");
82 
83  py::class_<FootprintSet, std::shared_ptr<FootprintSet>, lsst::daf::base::Citizen> clsFootprintSet(
84  mod, "FootprintSet");
85 
86  declareTemplatedMembers<std::uint16_t>(clsFootprintSet);
87  declareTemplatedMembers<int>(clsFootprintSet);
88  declareTemplatedMembers<float>(clsFootprintSet);
89  declareTemplatedMembers<double>(clsFootprintSet);
90 
91  clsFootprintSet.def(py::init<image::Mask<image::MaskPixel> const &, Threshold const &, int const>(),
92  "img"_a, "threshold"_a, "npixMin"_a = 1);
93 
94  /* Members */
95  clsFootprintSet.def(py::init<lsst::geom::Box2I>(), "region"_a);
96  clsFootprintSet.def(py::init<FootprintSet const &>(), "set"_a);
97  clsFootprintSet.def(py::init<FootprintSet const &, int, FootprintControl const &>(), "set"_a, "rGrow"_a,
98  "ctrl"_a);
99  clsFootprintSet.def(py::init<FootprintSet const &, int, bool>(), "set"_a, "rGrow"_a, "isotropic"_a);
100  clsFootprintSet.def(py::init<FootprintSet const &, FootprintSet const &, bool>(), "footprints1"_a,
101  "footprints2"_a, "includePeaks"_a);
102 
103  clsFootprintSet.def("swap", &FootprintSet::swap);
104  // setFootprints takes shared_ptr<FootprintList> and getFootprints returns it,
105  // but pybind11 can't handle that type, so use a custom getter and setter
106  clsFootprintSet.def("setFootprints", [](FootprintSet &self, FootprintSet::FootprintList footList) {
107  self.setFootprints(std::make_shared<FootprintSet::FootprintList>(std::move(footList)));
108  });
109  clsFootprintSet.def("getFootprints", [](FootprintSet &self) { return *(self.getFootprints()); });
110  clsFootprintSet.def("makeSources", &FootprintSet::makeSources);
111  clsFootprintSet.def("setRegion", &FootprintSet::setRegion);
112  clsFootprintSet.def("getRegion", &FootprintSet::getRegion);
113  clsFootprintSet.def("insertIntoImage", &FootprintSet::insertIntoImage);
114  clsFootprintSet.def("setMask", (void (FootprintSet::*)(image::Mask<lsst::afw::image::MaskPixel> *,
115  std::string const &)) &
116  FootprintSet::setMask<lsst::afw::image::MaskPixel>);
117  clsFootprintSet.def("setMask",
119  std::string const &)) &
120  FootprintSet::setMask<lsst::afw::image::MaskPixel>);
121  clsFootprintSet.def("merge", &FootprintSet::merge, "rhs"_a, "tGrow"_a = 0, "rGrow"_a = 0,
122  "isotropic"_a = true);
123 
124  /* Module level */
125 
126  /* Member types and enums */
127 }
def init()
Definition: tests.py:75
STL class.
Represent a 2-dimensional array of bitmask pixels.
Definition: Mask.h:78
T move(T... args)
void swap(Image< PixelT > &a, Image< PixelT > &b)
Definition: Image.cc:471
Citizen is a class that should be among all LSST classes base classes, and handles basic memory manag...
Definition: Citizen.h:55

◆ PYBIND11_MODULE() [8/9]

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

Definition at line 84 of file heavyFootprint.cc.

84  {
85  declareHeavyFootprint<int>(mod, "I");
86  declareHeavyFootprint<std::uint16_t>(mod, "U");
87  declareHeavyFootprint<float>(mod, "F");
88  declareHeavyFootprint<double>(mod, "D");
89 }

◆ PYBIND11_MODULE() [9/9]

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

Definition at line 102 of file peak.cc.

102  {
103  /* Module level */
104  PyPeakRecord clsPeakRecord(mod, "PeakRecord");
105  PyPeakTable clsPeakTable(mod, "PeakTable");
106 
107  /* Members */
108  declarePeakRecord(clsPeakRecord);
109  declarePeakTable(clsPeakTable);
110  auto clsPeakColumnView = table::python::declareColumnView<PeakRecord>(mod, "Peak");
111  auto clsPeakCatalog = table::python::declareCatalog<PeakRecord>(mod, "Peak");
112 
113  clsPeakRecord.attr("Table") = clsPeakTable;
114  clsPeakRecord.attr("ColumnView") = clsPeakColumnView;
115  clsPeakRecord.attr("Catalog") = clsPeakCatalog;
116  clsPeakTable.attr("Record") = clsPeakRecord;
117  clsPeakTable.attr("ColumnView") = clsPeakColumnView;
118  clsPeakTable.attr("Catalog") = clsPeakCatalog;
119  clsPeakCatalog.attr("Record") = clsPeakRecord;
120  clsPeakCatalog.attr("Table") = clsPeakTable;
121  clsPeakCatalog.attr("ColumnView") = clsPeakColumnView;
122 }

◆ 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