23 #include <pybind11/pybind11.h> 25 #include <pybind11/stl.h> 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 BackgroundMI::getImage<PixelT>,
52 cls.def((
"getImage" + suffix).c_str(),
55 BackgroundMI::getImage<PixelT>,
56 "interpStyle"_a,
"undersampleStyle"_a =
"THROW_EXCEPTION");
57 cls.def((
"getImage" + suffix).c_str(),
60 BackgroundMI::getImage<PixelT>,
62 cls.def((
"getImage" + suffix).c_str(),
65 BackgroundMI::getImage<PixelT>,
66 "bbox"_a,
"interpStyle"_a,
"undersampleStyle"_a =
"THROW_EXCEPTION");
67 cls.def((
"getImage" + suffix).c_str(),
69 BackgroundMI::getImage<PixelT>);
74 py::module mod(
"_background",
"Python wrapper for afw _background library");
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 declareGetImage<float>(clsBackgroundMI,
"F");
168 clsBackgroundMI.def(
"getPixel",
170 BackgroundMI::getPixel);
171 clsBackgroundMI.def(
"getPixel",
172 (
double (
BackgroundMI::*)(
int const,
int const)
const) & BackgroundMI::getPixel);
173 clsBackgroundMI.def(
"getStatsImage", &BackgroundMI::getStatsImage);
174 clsBackgroundMI.def(
"getImageBBox", &BackgroundMI::getImageBBox);
177 declareMakeBackground<image::Image<float>>(mod);
178 declareMakeBackground<image::MaskedImage<float>>(mod);
UndersampleStyle stringToUndersampleStyle(std::string const &style)
Conversion function to switch a string to an UndersampleStyle.
Pass parameters to a Background object.
A virtual base class to evaluate image background levels.
Control how to make an approximation.
Pass parameters to a Statistics object.
estimate sample N-sigma clipped mean (N set in StatisticsControl, default=3)
A base class for image defects.
A class to manipulate images, masks, and variance as a single object.
A class to evaluate image background levels.
Property
control what is calculated
An integer coordinate rectangle.
PYBIND11_PLUGIN(_background)
A class to represent a 2-dimensional array of pixels.