48 namespace pexExcept = lsst::pex::exceptions;
49 namespace afwGeom = lsst::afw::geom;
51 namespace afwMath = lsst::afw::math;
52 namespace mathDetail = lsst::afw::math::detail;
68 template <
typename OutImageT,
typename InImageT>
71 InImageT
const &inImage,
75 if (outImage.getDimensions() != inImage.getDimensions()) {
76 std::ostringstream os;
77 os <<
"outImage dimensions = ( "
78 << outImage.getWidth() <<
", " << outImage.getHeight()
79 <<
") != (" << inImage.getWidth() <<
", " << inImage.getHeight() <<
") = inImage dimensions";
80 throw LSST_EXCEPT(pexExcept::InvalidParameterError, os.str());
93 LOGL_DEBUG(
"TRACE5.afw.math.convolve.convolveWithInterpolation",
94 "convolveWithInterpolation: full bbox minimum=(%d, %d), extent=(%d, %d)",
97 LOGL_DEBUG(
"TRACE5.afw.math.convolve.convolveWithInterpolation",
98 "convolveWithInterpolation: goodRegion bbox minimum=(%d, %d), extent=(%d, %d)",
105 LOGL_DEBUG(
"TRACE3.afw.math.convolve.convolveWithInterpolation",
106 "convolveWithInterpolation: divide into %d x %d subregions", nx, ny);
112 rgnIter != rgnEnd; ++rgnIter) {
113 LOGL_DEBUG(
"TRACE5.afw.math.convolve.convolveWithInterpolation",
114 "convolveWithInterpolation: bbox minimum=(%d, %d), extent=(%d, %d)",
115 (*rgnIter)->getBBox().getMinX(), (*rgnIter)->getBBox().getMinY(),
116 (*rgnIter)->getBBox().getWidth(), (*rgnIter)->getBBox().getHeight());
129 template <
typename OutImageT,
typename InImageT>
132 InImageT
const &inImage,
136 typedef typename OutImageT::xy_locator OutLocator;
137 typedef typename InImageT::const_xy_locator InConstLocator;
139 typedef KernelImage::const_xy_locator KernelConstLocator;
142 geom::Extent2I const kernelDimensions(kernelPtr->getDimensions());
152 double xfrac = 1.0 /
static_cast<double>(goodBBox.
getWidth());
153 double yfrac = 1.0 /
static_cast<double>(goodBBox.
getHeight());
161 KernelConstLocator
const kernelLocator = workingImages.
kernelImage.
xy_at(0, 0);
167 InConstLocator inLocator = inImage.xy_at(fullBBox.
getMinX(), fullBBox.
getMinY());
168 OutLocator outLocator = outImage.xy_at(goodBBox.
getMinX(), goodBBox.
getMinY());
169 for (
int j = 0; ; ) {
170 auto inLocatorInitialPosition = inLocator;
171 auto outLocatorInitialPosition = outLocator;
174 for (
int i = 0; ; ) {
175 *outLocator = afwMath::convolveAtAPoint<OutImageT, InImageT>(
176 inLocator, kernelLocator, kernelDimensions.getX(), kernelDimensions.getY());
198 inLocator = inLocatorInitialPosition;
199 outLocator = outLocatorInitialPosition;
209 #define IMAGE(PIXTYPE) afwImage::Image<PIXTYPE>
210 #define MASKEDIMAGE(PIXTYPE) afwImage::MaskedImage<PIXTYPE, afwImage::MaskPixel, afwImage::VariancePixel>
213 #define INSTANTIATE_IM_OR_MI(IMGMACRO, OUTPIXTYPE, INPIXTYPE) \
214 template void mathDetail::convolveWithInterpolation( \
215 IMGMACRO(OUTPIXTYPE)&, IMGMACRO(INPIXTYPE) const&, afwMath::Kernel const&, \
216 afwMath::ConvolutionControl const&); NL \
217 template void mathDetail::convolveRegionWithInterpolation( \
218 IMGMACRO(OUTPIXTYPE)&, IMGMACRO(INPIXTYPE) const&, KernelImagesForRegion const&, \
219 ConvolveWithInterpolationWorkingImages&);
221 #define INSTANTIATE(OUTPIXTYPE, INPIXTYPE) \
222 INSTANTIATE_IM_OR_MI(IMAGE, OUTPIXTYPE, INPIXTYPE) \
223 INSTANTIATE_IM_OR_MI(MASKEDIMAGE, OUTPIXTYPE, INPIXTYPE)
void scaledPlus(OutImageT &outImage, double c1, InImageT const &inImage1, double c2, InImageT const &inImage2)
An include file to include the header files for lsst::afw::geom.
Declare the Kernel class and subclasses.
lsst::afw::geom::Box2I getBBox() const
geom::Extent2I const getDimensions() const
Return the Kernel's dimensions (width, height)
ImagePtr getImage(Location location) const
#define LOGL_DEBUG(logger, message...)
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...
Parameters to control convolution.
An integer coordinate rectangle.
kernel images used by convolveRegionWithInterpolation
table::Key< table::Array< Kernel::Pixel > > image
RegionList::const_iterator ConstIterator
void assign(ImageBase const &rsh, geom::Box2I const &bbox=geom::Box2I(), ImageOrigin origin=PARENT)
bool getDoNormalize() const
A row of KernelImagesForRegion.
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.
virtual boost::shared_ptr< Kernel > clone() const =0
Return a pointer to a deep copy of this kernel.
#define LSST_EXCEPT(type,...)
xy_locator xy_at(int x, int y) const
Implementation of the Class MaskedImage.
Include files required for standard LSST Exception handling.
bool computeNextRow(RowOfKernelImagesForRegion ®ionRow) const
Compute next row of subregions.
Kernels are used for convolution with MaskedImages and (eventually) Images.
KernelConstPtr getKernel() const
int getMaxInterpolationDistance() const
lsst::afw::geom::Box2I shrinkBBox(lsst::afw::geom::Box2I const &bbox) const