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);
83 rgnIter != rgnEnd; ++rgnIter) {
84 LOGL_DEBUG(
"TRACE5.afw.math.convolve.convolveWithInterpolation",
85 "convolveWithInterpolation: bbox minimum=(%d, %d), extent=(%d, %d)",
86 (*rgnIter)->getBBox().getMinX(), (*rgnIter)->getBBox().getMinY(),
87 (*rgnIter)->getBBox().getWidth(), (*rgnIter)->getBBox().getHeight());
93 template <
typename OutImageT,
typename InImageT>
97 typedef typename OutImageT::xy_locator OutLocator;
98 typedef typename InImageT::const_xy_locator InConstLocator;
100 typedef KernelImage::const_xy_locator KernelConstLocator;
113 double xfrac = 1.0 /
static_cast<double>(goodBBox.
getWidth());
114 double yfrac = 1.0 /
static_cast<double>(goodBBox.
getHeight());
120 KernelConstLocator
const kernelLocator = workingImages.
kernelImage.
xy_at(0, 0);
126 InConstLocator inLocator = inImage.xy_at(fullBBox.
getMinX(), fullBBox.
getMinY());
127 OutLocator outLocator = outImage.xy_at(goodBBox.
getMinX(), goodBBox.
getMinY());
129 auto inLocatorInitialPosition = inLocator;
130 auto outLocatorInitialPosition = outLocator;
134 *outLocator = math::convolveAtAPoint<OutImageT, InImageT>(
135 inLocator, kernelLocator, kernelDimensions.getX(), kernelDimensions.getY());
157 inLocator = inLocatorInitialPosition;
158 outLocator = outLocatorInitialPosition;
168 #define IMAGE(PIXTYPE) image::Image<PIXTYPE>
169 #define MASKEDIMAGE(PIXTYPE) image::MaskedImage<PIXTYPE, image::MaskPixel, image::VariancePixel>
172 #define INSTANTIATE_IM_OR_MI(IMGMACRO, OUTPIXTYPE, INPIXTYPE) \
173 template void convolveWithInterpolation(IMGMACRO(OUTPIXTYPE) &, IMGMACRO(INPIXTYPE) const &, \
174 math::Kernel const &, math::ConvolutionControl const &); \
175 NL template void convolveRegionWithInterpolation(IMGMACRO(OUTPIXTYPE) &, IMGMACRO(INPIXTYPE) const &, \
176 KernelImagesForRegion const &, \
177 ConvolveWithInterpolationWorkingImages &);
179 #define INSTANTIATE(OUTPIXTYPE, INPIXTYPE) \
180 INSTANTIATE_IM_OR_MI(IMAGE, OUTPIXTYPE, INPIXTYPE) \
181 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)
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.
A row of KernelImagesForRegion.
RegionList::const_iterator begin() const
Return the begin iterator for the list.
RegionList::const_iterator ConstIterator
RegionList::const_iterator end() const
Return the end iterator for the list.
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