49 template <
typename OutImageT,
typename InImageT>
52 if (outImage.getDimensions() != inImage.getDimensions()) {
54 os <<
"outImage dimensions = ( " << outImage.getWidth() <<
", " << outImage.getHeight() <<
") != ("
55 << inImage.getWidth() <<
", " << inImage.getHeight() <<
") = inImage dimensions";
65 LOGL_DEBUG(
"TRACE5.afw.math.convolve.convolveWithInterpolation",
66 "convolveWithInterpolation: full bbox minimum=(%d, %d), extent=(%d, %d)", fullBBox.
getMinX(),
68 LOGL_DEBUG(
"TRACE5.afw.math.convolve.convolveWithInterpolation",
69 "convolveWithInterpolation: goodRegion bbox minimum=(%d, %d), extent=(%d, %d)",
76 LOGL_DEBUG(
"TRACE3.afw.math.convolve.convolveWithInterpolation",
77 "convolveWithInterpolation: divide into %d x %d subregions", nx, ny);
82 for (
auto const &rgnIter : regionRow) {
83 LOGL_DEBUG(
"TRACE5.afw.math.convolve.convolveWithInterpolation",
84 "convolveWithInterpolation: bbox minimum=(%d, %d), extent=(%d, %d)",
85 rgnIter->getBBox().getMinX(), rgnIter->getBBox().getMinY(),
86 rgnIter->getBBox().getWidth(), rgnIter->getBBox().getHeight());
92 template <
typename OutImageT,
typename InImageT>
96 using OutLocator =
typename OutImageT::xy_locator;
97 using InConstLocator =
typename InImageT::const_xy_locator;
99 using KernelConstLocator = KernelImage::const_xy_locator;
112 double xfrac = 1.0 /
static_cast<double>(goodBBox.
getWidth());
113 double yfrac = 1.0 /
static_cast<double>(goodBBox.
getHeight());
119 KernelConstLocator
const kernelLocator = workingImages.
kernelImage.
xy_at(0, 0);
125 InConstLocator inLocator = inImage.xy_at(fullBBox.
getMinX(), fullBBox.
getMinY());
126 OutLocator outLocator = outImage.xy_at(goodBBox.
getMinX(), goodBBox.
getMinY());
128 auto inLocatorInitialPosition = inLocator;
129 auto outLocatorInitialPosition = outLocator;
133 *outLocator = math::convolveAtAPoint<OutImageT, InImageT>(
134 inLocator, kernelLocator, kernelDimensions.getX(), kernelDimensions.getY());
156 inLocator = inLocatorInitialPosition;
157 outLocator = outLocatorInitialPosition;
167 #define IMAGE(PIXTYPE) image::Image<PIXTYPE>
168 #define MASKEDIMAGE(PIXTYPE) image::MaskedImage<PIXTYPE, image::MaskPixel, image::VariancePixel>
171 #define INSTANTIATE_IM_OR_MI(IMGMACRO, OUTPIXTYPE, INPIXTYPE) \
172 template void convolveWithInterpolation(IMGMACRO(OUTPIXTYPE) &, IMGMACRO(INPIXTYPE) const &, \
173 math::Kernel const &, math::ConvolutionControl const &); \
174 NL template void convolveRegionWithInterpolation(IMGMACRO(OUTPIXTYPE) &, IMGMACRO(INPIXTYPE) const &, \
175 KernelImagesForRegion const &, \
176 ConvolveWithInterpolationWorkingImages &);
178 #define INSTANTIATE(OUTPIXTYPE, INPIXTYPE) \
179 INSTANTIATE_IM_OR_MI(IMAGE, OUTPIXTYPE, INPIXTYPE) \
180 INSTANTIATE_IM_OR_MI(MASKEDIMAGE, OUTPIXTYPE, INPIXTYPE)
#define INSTANTIATE(FROMSYS, TOSYS)
#define LSST_EXCEPT(type,...)
#define LOGL_DEBUG(logger, message...)
xy_locator xy_at(int x, int y) const
Return an xy_locator at the point (x, y) in the image.
void assign(ImageBase const &rhs, lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin origin=PARENT)
Copy pixels from another image to a specified subregion of this image.
Parameters to control convolution.
int getMaxInterpolationDistance() const
bool getDoNormalize() const
Kernels are used for convolution with MaskedImages and (eventually) Images.
lsst::geom::Extent2I const getDimensions() const
Return the Kernel's dimensions (width, height)
virtual std::shared_ptr< Kernel > clone() const =0
Return a pointer to a deep copy of this kernel.
lsst::geom::Box2I shrinkBBox(lsst::geom::Box2I const &bbox) const
Given a bounding box for an image one wishes to convolve with this kernel, return the bounding box fo...
A collection of Kernel images for special locations on a rectangular region of an image.
KernelConstPtr getKernel() const
Get the kernel (as a shared pointer to const)
bool computeNextRow(RowOfKernelImagesForRegion ®ionRow) const
Compute next row of subregions.
ImagePtr getImage(Location location) const
Return the image and sum at the specified location.
lsst::geom::Box2I getBBox() const
Get the bounding box for the region.
lsst::afw::image::Image< lsst::afw::math::Kernel::Pixel > Image
A row of KernelImagesForRegion.
int getMinY() const noexcept
int getHeight() const noexcept
int getMinX() const noexcept
int getWidth() const noexcept
void convolveRegionWithInterpolation(OutImageT &outImage, InImageT const &inImage, KernelImagesForRegion const ®ion, ConvolveWithInterpolationWorkingImages &workingImages)
Convolve a region of an Image or MaskedImage with a spatially varying Kernel using interpolation.
void convolveWithInterpolation(OutImageT &outImage, InImageT const &inImage, lsst::afw::math::Kernel const &kernel, ConvolutionControl const &convolutionControl)
Convolve an Image or MaskedImage with a spatially varying Kernel using linear interpolation.
void scaledPlus(OutImageT &outImage, double c1, InImageT const &inImage1, double c2, InImageT const &inImage2)
Compute the scaled sum of two images.
A base class for image defects.
kernel images used by convolveRegionWithInterpolation