23 #include <pybind11/pybind11.h>
25 #include <pybind11/stl.h>
29 namespace py = pybind11;
30 using namespace py::literals;
37 template <
typename PixelT,
typename PyClass>
38 void declareMakeHeavy(PyClass &
cls) {
48 HeavyFootprintCtrl
const *)) &
49 FootprintSet::makeHeavy<PixelT, image::MaskPixel>,
50 "mimg"_a,
"ctrl"_a =
nullptr);
53 template <
typename PixelT,
typename PyClass>
54 void declareSetMask(PyClass &cls) {
56 FootprintSet::setMask<PixelT>,
57 "mask"_a,
"planeName"_a);
60 template <
typename PixelT,
typename PyClass>
61 void declareTemplatedMembers(PyClass &cls) {
64 "threshold"_a,
"npixMin"_a = 1,
"setPeaks"_a =
true);
66 std::string
const &,
int const,
bool const>(),
67 "img"_a,
"threshold"_a,
"planeName"_a =
"",
"npixMin"_a = 1,
"setPeaks"_a =
true);
70 declareMakeHeavy<int>(
cls);
71 declareMakeHeavy<float>(
cls);
72 declareMakeHeavy<double>(
cls);
73 declareMakeHeavy<std::uint16_t>(
cls);
75 declareSetMask<image::MaskPixel>(
cls);
80 py::module mod(
"_footprintSet",
"Python wrapper for afw _footprintSet library");
82 py::class_<FootprintSet, std::shared_ptr<FootprintSet>, lsst::daf::base::Citizen> clsFootprintSet(
85 declareTemplatedMembers<std::uint16_t>(clsFootprintSet);
86 declareTemplatedMembers<int>(clsFootprintSet);
87 declareTemplatedMembers<float>(clsFootprintSet);
88 declareTemplatedMembers<double>(clsFootprintSet);
91 "img"_a,
"threshold"_a,
"npixMin"_a = 1);
94 clsFootprintSet.def(py::init<geom::Box2I>(),
"region"_a);
95 clsFootprintSet.def(py::init<FootprintSet const &>(),
"set"_a);
96 clsFootprintSet.def(py::init<FootprintSet const &, int, FootprintControl const &>(),
"set"_a,
"rGrow"_a,
98 clsFootprintSet.def(py::init<FootprintSet const &, int, bool>(),
"set"_a,
"rGrow"_a,
"isotropic"_a);
99 clsFootprintSet.def(py::init<FootprintSet const &, FootprintSet const &, bool>(),
"footprints1"_a,
100 "footprints2"_a,
"includePeaks"_a);
111 clsFootprintSet.def(
"setFootprints",
112 [](
FootprintSet &
self, std::shared_ptr<FootprintSet::FootprintList> footListPtr) {
113 self.setFootprints(footListPtr);
116 self.setFootprints(std::make_shared<FootprintSet::FootprintList>(footList));
119 clsFootprintSet.def(
"getFootprints", [](
FootprintSet &
self) {
return *(
self.getFootprints()); });
120 clsFootprintSet.def(
"makeSources", &FootprintSet::makeSources);
121 clsFootprintSet.def(
"setRegion", &FootprintSet::setRegion);
122 clsFootprintSet.def(
"getRegion", &FootprintSet::getRegion);
123 clsFootprintSet.def(
"insertIntoImage", &FootprintSet::insertIntoImage);
125 std::string
const &)) &
126 FootprintSet::setMask<lsst::afw::image::MaskPixel>);
127 clsFootprintSet.def(
"setMask",
129 std::string
const &)) &
130 FootprintSet::setMask<lsst::afw::image::MaskPixel>);
131 clsFootprintSet.def(
"merge", &FootprintSet::merge,
"rhs"_a,
"tGrow"_a = 0,
"rGrow"_a = 0,
132 "isotropic"_a =
true);
A Threshold is used to pass a threshold value to detection algorithms.
PYBIND11_PLUGIN(_cameraPoint)
Represent a 2-dimensional array of bitmask pixels.
A class to manipulate images, masks, and variance as a single object.
void swap(Image< PixelT > &a, Image< PixelT > &b)
A class to represent a 2-dimensional array of pixels.