23 #include "pybind11/pybind11.h"
27 namespace py = pybind11;
29 using namespace py::literals;
36 template <
typename PixelT>
37 static void declareImageSlice(py::module &mod, std::string
const &suffix) {
38 using Class = ImageSlice<PixelT>;
40 py::class_<Class, std::shared_ptr<Class>, Image<PixelT>>
cls(mod, (
"ImageSlice" + suffix).c_str());
42 cls.def(py::init<Image<PixelT>
const &>(),
"img"_a);
44 py::enum_<typename Class::ImageSliceType>(
cls,
"ImageSliceType")
45 .value(
"ROW", Class::ImageSliceType::ROW)
46 .value(
"COLUMN", Class::ImageSliceType::COLUMN)
49 cls.def(
"getImageSliceType", &Class::getImageSliceType);
51 cls.def(
"__add__", [](ImageSlice<PixelT> &
self, Image<PixelT>
const &other) {
return self + other; },
53 cls.def(
"__mul__", [](ImageSlice<PixelT> &
self, Image<PixelT>
const &other) {
return self * other; },
55 cls.def(
"__iadd__", [](ImageSlice<PixelT> &
self, Image<PixelT>
const &other) {
59 cls.def(
"__imul__", [](ImageSlice<PixelT> &
self, Image<PixelT>
const &other) {
65 [](Image<PixelT>
const &
self, ImageSlice<PixelT>
const &other) {
return self + other; },
68 [](Image<PixelT>
const &
self, ImageSlice<PixelT>
const &other) {
return self - other; },
71 [](Image<PixelT>
const &
self, ImageSlice<PixelT>
const &other) {
return self * other; },
73 cls.def(
"__truediv__",
74 [](Image<PixelT>
const &
self, ImageSlice<PixelT>
const &other) {
return self / other; },
76 cls.def(
"__iadd__", [](Image<PixelT> &
self, ImageSlice<PixelT>
const &other) {
80 cls.def(
"__isub__", [](Image<PixelT> &
self, ImageSlice<PixelT>
const &other) {
84 cls.def(
"__imul__", [](Image<PixelT> &
self, ImageSlice<PixelT>
const &other) {
88 cls.def(
"__itruediv__", [](Image<PixelT> &
self, ImageSlice<PixelT>
const &other) {
95 py::module mod(
"imageSlice");
97 py::module::import(
"lsst.afw.image.image");
99 declareImageSlice<float>(mod,
"F");
100 declareImageSlice<double>(mod,
"D");
PYBIND11_PLUGIN(_cameraPoint)