23 #include <pybind11/pybind11.h>
25 #include <pybind11/stl.h>
33 using namespace py::literals;
40 template <
typename ImageT>
42 mod.def(
"makeBackground", makeBackground<ImageT>,
"img"_a,
"bgCtrl"_a);
45 template <
typename PixelT,
typename PyClass>
47 cls.def((
"getImage" + suffix).c_str(),
50 Background::getImage<PixelT>,
52 cls.def((
"getImage" + suffix).c_str(),
55 Background::getImage<PixelT>,
56 "interpStyle"_a,
"undersampleStyle"_a =
"THROW_EXCEPTION");
57 cls.def((
"getImage" + suffix).c_str(),
60 Background::getImage<PixelT>,
62 cls.def((
"getImage" + suffix).c_str(),
65 Background::getImage<PixelT>,
66 "bbox"_a,
"interpStyle"_a,
"undersampleStyle"_a =
"THROW_EXCEPTION");
67 cls.def((
"getImage" + suffix).c_str(),
69 Background::getImage<PixelT>);
74 py::module::import(
"lsst.afw.image.image");
77 py::enum_<UndersampleStyle>(mod,
"UndersampleStyle")
83 py::class_<BackgroundControl, std::shared_ptr<BackgroundControl>> clsBackgroundControl(
84 mod,
"BackgroundControl");
93 "nxSample"_a,
"nySample"_a,
"sctrl"_a,
"prop"_a,
97 "style"_a,
"nxSample"_a = 10,
"nySample"_a = 10,
101 clsBackgroundControl.def(
104 "style"_a,
"nxSample"_a = 10,
"nySample"_a = 10,
"undersampleStyle"_a =
"THROW_EXCEPTION",
109 clsBackgroundControl.def(
"setNxSample", &BackgroundControl::setNxSample);
110 clsBackgroundControl.def(
"setNySample", &BackgroundControl::setNySample);
112 BackgroundControl::setInterpStyle);
114 BackgroundControl::setInterpStyle);
116 BackgroundControl::setUndersampleStyle);
118 BackgroundControl::setUndersampleStyle);
119 clsBackgroundControl.def(
"getNxSample", &BackgroundControl::getNxSample);
120 clsBackgroundControl.def(
"getNySample", &BackgroundControl::getNySample);
121 clsBackgroundControl.def(
"getInterpStyle", &BackgroundControl::getInterpStyle);
122 clsBackgroundControl.def(
"getUndersampleStyle", &BackgroundControl::getUndersampleStyle);
123 clsBackgroundControl.def(
"getStatisticsControl",
125 BackgroundControl::getStatisticsControl);
126 clsBackgroundControl.def(
"getStatisticsProperty", &BackgroundControl::getStatisticsProperty);
128 BackgroundControl::setStatisticsProperty);
130 BackgroundControl::setStatisticsProperty);
131 clsBackgroundControl.def(
"setApproximateControl", &BackgroundControl::setApproximateControl);
132 clsBackgroundControl.def(
"getApproximateControl",
134 BackgroundControl::getApproximateControl);
142 py::class_<Background, std::unique_ptr<Background, py::nodelete>> clsBackground(mod,
"Background");
145 declareGetImage<float>(clsBackground,
"F");
147 clsBackground.def(
"getAsUsedInterpStyle", &Background::getAsUsedInterpStyle);
148 clsBackground.def(
"getAsUsedUndersampleStyle", &Background::getAsUsedUndersampleStyle);
149 clsBackground.def(
"getApproximate", &Background::getApproximate,
"actrl"_a,
152 Background::getBackgroundControl);
154 py::class_<BackgroundMI, std::shared_ptr<BackgroundMI>,
Background> clsBackgroundMI(mod,
"BackgroundMI");
159 "imageDimensions"_a,
"statsImage"_a);
162 clsBackgroundMI.def(
"__iadd__", &BackgroundMI::operator+=);
163 clsBackgroundMI.def(
"__isub__", &BackgroundMI::operator-=);
166 clsBackgroundMI.def(
"getPixel",
168 BackgroundMI::getPixel);
169 clsBackgroundMI.def(
"getPixel",
170 (
double (
BackgroundMI::*)(
int const,
int const)
const) & BackgroundMI::getPixel);
171 clsBackgroundMI.def(
"getStatsImage", &BackgroundMI::getStatsImage);
172 clsBackgroundMI.def(
"getImageBBox", &BackgroundMI::getImageBBox);
175 declareMakeBackground<image::Image<float>>(mod);
176 declareMakeBackground<image::MaskedImage<float>>(mod);