27 #include <pybind11/pybind11.h>
38 using namespace py::literals;
53 template <
typename KernelT>
54 py::class_<KernelT, std::shared_ptr<KernelT>, SeparableKernel> declareWarpingKernel(
py::module &mod,
56 py::class_<KernelT, std::shared_ptr<KernelT>, SeparableKernel>
cls(mod,
name.c_str());
70 template <
typename KernelT>
71 py::class_<KernelT, std::shared_ptr<KernelT>, SeparableKernel> declareSimpleWarpingKernel(
73 auto cls = declareWarpingKernel<KernelT>(mod,
name);
74 cls.def(py::init<>());
86 template <
typename DestImageT,
typename SrcImageT>
87 void declareImageWarpingFunctions(
py::module &mod) {
88 auto const EdgePixel =
89 edgePixel<DestImageT>(
typename image::detail::image_traits<DestImageT>::image_category());
90 mod.def(
"warpImage", (
int (*)(DestImageT &, geom::SkyWcs
const &, SrcImageT
const &, geom::SkyWcs
const &,
91 WarpingControl
const &,
typename DestImageT::SinglePixel)) &
92 warpImage<DestImageT, SrcImageT>,
93 "destImage"_a,
"destWcs"_a,
"srcImage"_a,
"srcWcs"_a,
"control"_a,
"padValue"_a = EdgePixel);
97 WarpingControl
const &,
typename DestImageT::SinglePixel)) &
98 warpImage<DestImageT, SrcImageT>,
99 "destImage"_a,
"srcImage"_a,
"srcToDest"_a,
"control"_a,
"padValue"_a = EdgePixel);
101 mod.def(
"warpCenteredImage", &warpCenteredImage<DestImageT, SrcImageT>,
"destImage"_a,
"srcImage"_a,
102 "linearTransform"_a,
"centerPoint"_a,
"control"_a,
"padValue"_a = EdgePixel);
115 template <
typename DestPixelT,
typename SrcPixelT>
116 void declareWarpingFunctions(
py::module &mod) {
124 mod.def(
"warpExposure", &warpExposure<DestExposureT, SrcExposureT>,
"destExposure"_a,
"srcExposure"_a,
125 "control"_a,
"padValue"_a = edgePixel<DestMaskedImageT>(
126 typename image::detail::image_traits<DestMaskedImageT>::image_category()));
128 declareImageWarpingFunctions<DestImageT, SrcImageT>(mod);
129 declareImageWarpingFunctions<DestMaskedImageT, SrcMaskedImageT>(mod);
135 auto clsLanczosWarpingKernel = declareWarpingKernel<LanczosWarpingKernel>(mod,
"LanczosWarpingKernel");
136 declareSimpleWarpingKernel<BilinearWarpingKernel>(mod,
"BilinearWarpingKernel");
137 declareSimpleWarpingKernel<NearestWarpingKernel>(mod,
"NearestWarpingKernel");
139 py::class_<WarpingControl, std::shared_ptr<WarpingControl>> clsWarpingControl(mod,
"WarpingControl");
141 declareWarpingFunctions<double, double>(mod);
142 declareWarpingFunctions<double, float>(mod);
143 declareWarpingFunctions<double, int>(mod);
144 declareWarpingFunctions<double, std::uint16_t>(mod);
145 declareWarpingFunctions<float, float>(mod);
146 declareWarpingFunctions<float, int>(mod);
147 declareWarpingFunctions<float, std::uint16_t>(mod);
148 declareWarpingFunctions<int, int>(mod);
149 declareWarpingFunctions<std::uint16_t, std::uint16_t>(mod);
154 clsLanczosWarpingKernel.def(py::init<int>(),
"order"_a);
156 clsWarpingControl.def(py::init<std::string, std::string, int, int, image::MaskPixel>(),
157 "warpingKernelName"_a,
"maskWarpingKernelName"_a =
"",
"cacheSize"_a = 0,
158 "interpLength"_a = 0,
"growFullMask"_a = 0);
161 clsLanczosWarpingKernel.def(
"getOrder", &LanczosWarpingKernel::getOrder);
163 clsWarpingControl.def(
"getCacheSize", &WarpingControl::getCacheSize);
164 clsWarpingControl.def(
"setCacheSize", &WarpingControl::setCacheSize,
"cacheSize"_a);
165 clsWarpingControl.def(
"getInterpLength", &WarpingControl::getInterpLength);
166 clsWarpingControl.def(
"setInterpLength", &WarpingControl::setInterpLength,
"interpLength"_a);
167 clsWarpingControl.def(
"setWarpingKernelName", &WarpingControl::setWarpingKernelName,
168 "warpingKernelName"_a);
169 clsWarpingControl.def(
"getWarpingKernel", &WarpingControl::getWarpingKernel);
170 clsWarpingControl.def(
"setWarpingKernel", &WarpingControl::setWarpingKernel,
"warpingKernel"_a);
171 clsWarpingControl.def(
"setMaskWarpingKernelName", &WarpingControl::setMaskWarpingKernelName,
172 "maskWarpingKernelName"_a);
173 clsWarpingControl.def(
"getMaskWarpingKernel", &WarpingControl::getMaskWarpingKernel);
174 clsWarpingControl.def(
"hasMaskWarpingKernel", &WarpingControl::hasMaskWarpingKernel);
175 clsWarpingControl.def(
"setMaskWarpingKernelName", &WarpingControl::setMaskWarpingKernelName,
176 "maskWarpingKernelName"_a);
177 clsWarpingControl.def(
"setMaskWarpingKernel", &WarpingControl::setMaskWarpingKernel,
178 "maskWarpingKernel"_a);
179 clsWarpingControl.def(
"getGrowFullMask", &WarpingControl::getGrowFullMask);
180 clsWarpingControl.def(
"setGrowFullMask", &WarpingControl::setGrowFullMask,
"growFullMask"_a);
A class to contain the data, WCS, and other information needed to describe an image of the sky.
A class to represent a 2-dimensional array of pixels.
A class to manipulate images, masks, and variance as a single object.
Transform< Point2Endpoint, Point2Endpoint > TransformPoint2ToPoint2
PYBIND11_MODULE(warpExposure, mod)
int warpExposure(DestExposureT &destExposure, SrcExposureT const &srcExposure, WarpingControl const &control, typename DestExposureT::MaskedImageT::SinglePixel padValue=lsst::afw::math::edgePixel< typename DestExposureT::MaskedImageT >(typename lsst::afw::image::detail::image_traits< typename DestExposureT::MaskedImageT >::image_category()))
Warp (remap) one exposure to another.
A base class for image defects.