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);
136 py::class_<Background, std::shared_ptr<Background>> clsBackground(mod,
"Background");
139 declareGetImage<float>(clsBackground,
"F");
141 clsBackground.def(
"getAsUsedInterpStyle", &Background::getAsUsedInterpStyle);
142 clsBackground.def(
"getAsUsedUndersampleStyle", &Background::getAsUsedUndersampleStyle);
143 clsBackground.def(
"getApproximate", &Background::getApproximate,
"actrl"_a,
146 Background::getBackgroundControl);
148 py::class_<BackgroundMI, std::shared_ptr<BackgroundMI>,
Background> clsBackgroundMI(mod,
"BackgroundMI");
153 "imageDimensions"_a,
"statsImage"_a);
156 clsBackgroundMI.def(
"__iadd__", &BackgroundMI::operator+=);
157 clsBackgroundMI.def(
"__isub__", &BackgroundMI::operator-=);
160 clsBackgroundMI.def(
"getStatsImage", &BackgroundMI::getStatsImage);
161 clsBackgroundMI.def(
"getImageBBox", &BackgroundMI::getImageBBox);
164 declareMakeBackground<image::Image<float>>(mod);
165 declareMakeBackground<image::MaskedImage<float>>(mod);