24 #include "pybind11/pybind11.h" 25 #include "pybind11/stl.h" 29 #include "ndarray/pybind11.h" 44 template <
typename MaskT>
45 void declareMaskFromFootprintList(
py::module &mod) {
48 MaskT
const bitmask,
bool doClip) {
49 for (
auto const &foot : footprints) {
52 auto tmpSpan = foot->getSpans()->clippedTo(mask->
getBBox());
53 tmpSpan->setMask(*mask, bitmask);
55 foot->getSpans()->setMask(*mask, bitmask);
59 "Bounds of a Footprint fall outside mask set doClip to force");
63 mod.def(
"setMaskFromFootprintList",
std::move(maskSetter),
"mask"_a,
"footprints"_a,
"bitmask"_a,
71 py::class_<Footprint, std::shared_ptr<Footprint>,
daf::base::Citizen> clsFootprint(mod,
"Footprint");
78 clsFootprint.def(py::init<Footprint const &>());
79 clsFootprint.def(py::init<>());
81 table::io::python::addPersistableMethods<Footprint>(clsFootprint);
84 clsFootprint.def(
"getSpans", &Footprint::getSpans);
85 clsFootprint.def(
"setSpans", &Footprint::setSpans);
87 py::return_value_policy::reference_internal);
88 clsFootprint.def(
"addPeak", &Footprint::addPeak);
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);
97 clsFootprint.def(
"getBBox", &Footprint::getBBox);
98 clsFootprint.def(
"getRegion", &Footprint::getRegion);
99 clsFootprint.def(
"setRegion", &Footprint::setRegion);
100 clsFootprint.def(
"clipTo", &Footprint::clipTo);
106 "source"_a,
"target"_a,
"region"_a,
"doClip"_a =
true);
109 Footprint::transform);
112 Footprint::transform);
113 clsFootprint.def(
"transform",
116 Footprint::transform);
118 "stencil"_a = geom::Stencil::CIRCLE);
121 "stencil"_a = geom::Stencil::CIRCLE);
123 clsFootprint.def(
"removeOrphanPeaks", &Footprint::removeOrphanPeaks);
124 clsFootprint.def(
"isContiguous", &Footprint::isContiguous);
125 clsFootprint.def(
"isHeavy", &Footprint::isHeavy);
132 for (
auto &
ptr :
self.split()) {
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);
145 return self.contains(point);
147 clsFootprint.def(
"__eq__",
151 declareMaskFromFootprintList<lsst::afw::image::MaskPixel>(mod);
Defines the fields and offsets for a table.
Stencil
An enumeration class which describes the shapes.
bool contains(VertexIterator const begin, VertexIterator const end, UnitVector3d const &v)
A compact representation of a collection of pixels.
A base class for image defects.
lsst::geom::Box2I getBBox(ImageOrigin origin=PARENT) const
Represent a 2-dimensional array of bitmask pixels.
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...
PYBIND11_MODULE(footprint, mod)
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...
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Reports attempts to access elements outside a valid range of indices.
ItemVariant const * other
Citizen is a class that should be among all LSST classes base classes, and handles basic memory manag...
An integer coordinate rectangle.
daf::base::PropertyList * list