22 #include "pybind11/pybind11.h"
23 #include "pybind11/stl.h"
28 #include "lsst/afw/image/ImagePca.h"
29 #include "lsst/afw/math/Kernel.h"
30 #include "lsst/afw/math/SpatialCell.h"
33 namespace py = pybind11;
34 using namespace pybind11::literals;
50 template <
typename PixelT>
51 void declareKernelPca(py::module& mod, std::string
const& suffix) {
52 using ImageT = afw::image::Image<PixelT>;
53 py::class_<KernelPca<ImageT>, std::shared_ptr<KernelPca<ImageT>>, afw::image::ImagePca<ImageT>> cls(
54 mod, (
"KernelPca" + suffix).c_str());
56 cls.def(py::init<bool>(),
"constantWeight"_a =
true);
58 cls.def(
"analyze", &KernelPca<ImageT>::analyze);
68 template <
typename PixelT>
69 void declareKernelPcaVisitor(py::module& mod, std::string
const& suffix) {
70 py::class_<KernelPcaVisitor<PixelT>, std::shared_ptr<KernelPcaVisitor<PixelT>>,
71 afw::math::CandidateVisitor>
72 cls(mod, (
"KernelPcaVisitor" + suffix).c_str());
76 using KernelImageT =
typename KernelPcaVisitor<PixelT>::ImageT;
77 cls.def(py::init<std::shared_ptr<KernelPca<KernelImageT>>>(),
"imagePca"_a);
79 cls.def(
"getEigenKernels", &KernelPcaVisitor<PixelT>::getEigenKernels);
80 cls.def(
"processCandidate", &KernelPcaVisitor<PixelT>::processCandidate,
"candidate"_a);
81 cls.def(
"subtractMean", &KernelPcaVisitor<PixelT>::subtractMean);
82 cls.def(
"returnMean", &KernelPcaVisitor<PixelT>::returnMean);
84 mod.def(
"makeKernelPcaVisitor", &makeKernelPcaVisitor<PixelT>,
"imagePca"_a);
90 py::module::import(
"lsst.afw.image");
91 py::module::import(
"lsst.afw.math");
93 py::module mod(
"kernelPca");
95 declareKernelPca<afw::math::Kernel::Pixel>(mod,
"D");
96 declareKernelPcaVisitor<float>(mod,
"F");
Declaration of KernelPca and KernelPcaVisitor.
PYBIND11_PLUGIN(basisLists)