25#ifndef LSST_AFW_MATH_CONVOLVEIMAGE_H
26#define LSST_AFW_MATH_CONVOLVEIMAGE_H
53 bool doCopyEdge =
false,
55 int maxInterpolationDistance = 10
58 : _doNormalize(doNormalize),
59 _doCopyEdge(doCopyEdge),
60 _maxInterpolationDistance(maxInterpolationDistance) {}
69 _maxInterpolationDistance = maxInterpolationDistance;
76 int _maxInterpolationDistance;
102template <
typename OutImageT,
typename InImageT>
103void scaledPlus(OutImageT& outImage,
double c1, InImageT
const& inImage1,
double c2,
104 InImageT
const& inImage2);
106template <
typename OutImageT,
typename InImageT>
108 typename InImageT::const_xy_locator inImageLocator,
110 int kWidth,
int kHeight);
112template <
typename OutImageT,
typename InImageT>
114 typename InImageT::const_xy_locator inImageLocator,
188template <
typename OutImageT,
typename InImageT,
typename KernelT>
189void convolve(OutImageT& convolvedImage, InImageT
const& inImage, KernelT
const& kernel,
190 ConvolutionControl
const& convolutionControl = ConvolutionControl());
197template <
typename ImageT>
201 using SinglePixelT =
typename ImageT::SinglePixel;
218template <
typename MaskedImageT>
223 using ImagePixelT =
typename MaskedImageT::Image::Pixel;
224 using VariancePixelT =
typename MaskedImageT::Variance::Pixel;
229 auto maskPixel = MaskedImageT::Mask::getPlaneBitMask(
"NO_DATA");
233 return typename MaskedImageT::SinglePixel(imagePixel, maskPixel, variancePixel);
256template <
typename OutImageT,
typename InImageT>
258 typename InImageT::const_xy_locator inImageLocator,
260 typename OutImageT::SinglePixel outValue = 0;
261 for (
int kRow = 0; kRow != kHeight; ++kRow) {
263 kernelLocator + image::detail::difference_type(kWidth, 0);
264 kernelLocator != kEnd; ++inImageLocator.x(), ++kernelLocator.x()) {
267 outValue += *inImageLocator * kVal;
271 inImageLocator += image::detail::difference_type(-kWidth, 1);
272 kernelLocator += image::detail::difference_type(-kWidth, 1);
292template <
typename OutImageT,
typename InImageT>
293inline typename OutImageT::SinglePixel
convolveAtAPoint(
typename InImageT::const_xy_locator inImageLocator,
298 using OutT =
typename OutImageT::SinglePixel;
300 for (
double kValY : kernelYList) {
302 for (k_iter kernelXIter = kernelXList.
begin(), xEnd = kernelXList.
end(); kernelXIter != xEnd;
303 ++kernelXIter, ++inImageLocator.x()) {
306 outValueY += *inImageLocator * kValX;
311 outValue += outValueY * kValY;
314 inImageLocator += image::detail::difference_type(-kernelXList.
size(), 1);
typename _view_t::xy_locator::const_t const_xy_locator
A const_xy_locator.
Parameters to control convolution.
void setDoCopyEdge(bool doCopyEdge)
bool getDoCopyEdge() const
void setDoNormalize(bool doNormalize)
int getMaxInterpolationDistance() const
ConvolutionControl(bool doNormalize=true, bool doCopyEdge=false, int maxInterpolationDistance=10)
bool getDoNormalize() const
void setMaxInterpolationDistance(int maxInterpolationDistance)
OutImageT::SinglePixel convolveAtAPoint(typename InImageT::const_xy_locator inImageLocator, typename lsst::afw::image::Image< lsst::afw::math::Kernel::Pixel >::const_xy_locator kernelLocator, int kWidth, int kHeight)
Apply convolution kernel to an image at one point.
void scaledPlus(OutImageT &outImage, double c1, InImageT const &inImage1, double c2, InImageT const &inImage2)
Compute the scaled sum of two images.
void convolve(OutImageT &convolvedImage, InImageT const &inImage, KernelT const &kernel, ConvolutionControl const &convolutionControl=ConvolutionControl())
Convolve an Image or MaskedImage with a Kernel, setting pixels of an existing output image.
ImageT::SinglePixel edgePixel(lsst::afw::image::detail::Image_tag)
Return an off-the-edge pixel appropriate for a given Image type.
A traits class for MaskedImage.