44template <
typename OutImageT,
typename InImageT>
47 if (outImage.getDimensions() != inImage.getDimensions()) {
49 os <<
"outImage dimensions = ( " << outImage.getWidth() <<
", " << outImage.getHeight() <<
") != ("
50 << inImage.getWidth() <<
", " << inImage.getHeight() <<
") = inImage dimensions";
60 LOGL_DEBUG(
"TRACE5.lsst.afw.math.convolve.convolveWithInterpolation",
61 "convolveWithInterpolation: full bbox minimum=(%d, %d), extent=(%d, %d)", fullBBox.
getMinX(),
63 LOGL_DEBUG(
"TRACE5.lsst.afw.math.convolve.convolveWithInterpolation",
64 "convolveWithInterpolation: goodRegion bbox minimum=(%d, %d), extent=(%d, %d)",
71 LOGL_DEBUG(
"TRACE3.lsst.afw.math.convolve.convolveWithInterpolation",
72 "convolveWithInterpolation: divide into %d x %d subregions", nx, ny);
77 for (
auto const &rgnIter : regionRow) {
78 LOGL_DEBUG(
"TRACE5.lsst.afw.math.convolve.convolveWithInterpolation",
79 "convolveWithInterpolation: bbox minimum=(%d, %d), extent=(%d, %d)",
80 rgnIter->getBBox().getMinX(), rgnIter->getBBox().getMinY(),
81 rgnIter->getBBox().getWidth(), rgnIter->getBBox().getHeight());
87template <
typename OutImageT,
typename InImageT>
91 using OutLocator =
typename OutImageT::xy_locator;
92 using InConstLocator =
typename InImageT::const_xy_locator;
94 using KernelConstLocator = KernelImage::const_xy_locator;
107 double xfrac = 1.0 /
static_cast<double>(goodBBox.
getWidth());
108 double yfrac = 1.0 /
static_cast<double>(goodBBox.
getHeight());
114 KernelConstLocator
const kernelLocator = workingImages.
kernelImage.
xy_at(0, 0);
120 InConstLocator inLocator = inImage.xy_at(fullBBox.
getMinX(), fullBBox.
getMinY());
121 OutLocator outLocator = outImage.xy_at(goodBBox.
getMinX(), goodBBox.
getMinY());
123 auto inLocatorInitialPosition = inLocator;
124 auto outLocatorInitialPosition = outLocator;
128 *outLocator = math::convolveAtAPoint<OutImageT, InImageT>(
129 inLocator, kernelLocator, kernelDimensions.getX(), kernelDimensions.getY());
151 inLocator = inLocatorInitialPosition;
152 outLocator = outLocatorInitialPosition;
162#define IMAGE(PIXTYPE) image::Image<PIXTYPE>
163#define MASKEDIMAGE(PIXTYPE) image::MaskedImage<PIXTYPE, image::MaskPixel, image::VariancePixel>
166#define INSTANTIATE_IM_OR_MI(IMGMACRO, OUTPIXTYPE, INPIXTYPE) \
167 template void convolveWithInterpolation(IMGMACRO(OUTPIXTYPE) &, IMGMACRO(INPIXTYPE) const &, \
168 math::Kernel const &, math::ConvolutionControl const &); \
169 NL template void convolveRegionWithInterpolation(IMGMACRO(OUTPIXTYPE) &, IMGMACRO(INPIXTYPE) const &, \
170 KernelImagesForRegion const &, \
171 ConvolveWithInterpolationWorkingImages &);
173#define INSTANTIATE(OUTPIXTYPE, INPIXTYPE) \
174 INSTANTIATE_IM_OR_MI(IMAGE, OUTPIXTYPE, INPIXTYPE) \
175 INSTANTIATE_IM_OR_MI(MASKEDIMAGE, OUTPIXTYPE, INPIXTYPE)
#define INSTANTIATE(FROMSYS, TOSYS)
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
LSST DM logging module built on log4cxx.
#define LOGL_DEBUG(logger, message...)
Log a debug-level message using a varargs/printf style interface.
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)
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...
virtual std::shared_ptr< Kernel > clone() const =0
Return a pointer to a deep copy of this kernel.
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.
An integer coordinate rectangle.
int getMinY() const noexcept
int getHeight() const noexcept
int getMinX() const noexcept
int getWidth() const noexcept
Reports invalid arguments.
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