40 #include "boost/cstdint.hpp"
49 namespace pexExcept = lsst::pex::exceptions;
50 namespace pexLog = lsst::pex::logging;
51 namespace afwGeom = lsst::afw::geom;
53 namespace afwMath = lsst::afw::math;
54 namespace mathDetail = lsst::afw::math::detail;
70 template <
typename OutImageT,
typename InImageT>
73 InImageT
const &inImage,
77 if (outImage.getDimensions() != inImage.getDimensions()) {
78 std::ostringstream os;
79 os <<
"outImage dimensions = ( "
80 << outImage.getWidth() <<
", " << outImage.getHeight()
81 <<
") != (" << inImage.getWidth() <<
", " << inImage.getHeight() <<
") = inImage dimensions";
82 throw LSST_EXCEPT(pexExcept::InvalidParameterError, os.str());
95 pexLog::TTrace<6>(
"lsst.afw.math.convolve",
96 "convolveWithInterpolation: full bbox minimum=(%d, %d), extent=(%d, %d)",
99 pexLog::TTrace<6>(
"lsst.afw.math.convolve",
100 "convolveWithInterpolation: goodRegion bbox minimum=(%d, %d), extent=(%d, %d)",
107 pexLog::TTrace<4>(
"lsst.afw.math.convolve",
108 "convolveWithInterpolation: divide into %d x %d subregions", nx, ny);
114 rgnIter != rgnEnd; ++rgnIter) {
115 pexLog::TTrace<6>(
"lsst.afw.math.convolve",
116 "convolveWithInterpolation: bbox minimum=(%d, %d), extent=(%d, %d)",
117 (*rgnIter)->getBBox().getMinX(), (*rgnIter)->getBBox().getMinY(),
118 (*rgnIter)->getBBox().getWidth(), (*rgnIter)->getBBox().getHeight());
131 template <
typename OutImageT,
typename InImageT>
134 InImageT
const &inImage,
138 typedef typename OutImageT::xy_locator OutLocator;
139 typedef typename InImageT::const_xy_locator InConstLocator;
141 typedef KernelImage::const_xy_locator KernelConstLocator;
144 geom::Extent2I const kernelDimensions(kernelPtr->getDimensions());
154 double xfrac = 1.0 /
static_cast<double>(goodBBox.
getWidth());
155 double yfrac = 1.0 /
static_cast<double>(goodBBox.
getHeight());
163 KernelConstLocator
const kernelLocator = workingImages.
kernelImage.
xy_at(0, 0);
169 InConstLocator inLocator = inImage.xy_at(fullBBox.
getMinX(), fullBBox.
getMinY());
170 OutLocator outLocator = outImage.xy_at(goodBBox.
getMinX(), goodBBox.
getMinY());
171 for (
int j = 0; ; ) {
174 for (
int i = 0; ; ) {
175 *outLocator = afwMath::convolveAtAPoint<OutImageT, InImageT>(
176 inLocator, kernelLocator, kernelDimensions.getX(), kernelDimensions.getY());
193 inLocator += lsst::afw::image::detail::difference_type(-goodBBox.
getWidth(), 1);
194 outLocator += lsst::afw::image::detail::difference_type(-goodBBox.
getWidth(), 1);
202 #define IMAGE(PIXTYPE) afwImage::Image<PIXTYPE>
203 #define MASKEDIMAGE(PIXTYPE) afwImage::MaskedImage<PIXTYPE, afwImage::MaskPixel, afwImage::VariancePixel>
206 #define INSTANTIATE_IM_OR_MI(IMGMACRO, OUTPIXTYPE, INPIXTYPE) \
207 template void mathDetail::convolveWithInterpolation( \
208 IMGMACRO(OUTPIXTYPE)&, IMGMACRO(INPIXTYPE) const&, afwMath::Kernel const&, \
209 afwMath::ConvolutionControl const&); NL \
210 template void mathDetail::convolveRegionWithInterpolation( \
211 IMGMACRO(OUTPIXTYPE)&, IMGMACRO(INPIXTYPE) const&, KernelImagesForRegion const&, \
212 ConvolveWithInterpolationWorkingImages&);
214 #define INSTANTIATE(OUTPIXTYPE, INPIXTYPE) \
215 INSTANTIATE_IM_OR_MI(IMAGE, OUTPIXTYPE, INPIXTYPE) \
216 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.
KernelConstPtr getKernel() const
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.
definition of the Trace messaging facilities
lsst::afw::geom::Box2I getBBox() const
bool getDoNormalize() const
ImagePtr getImage(Location location) const
An integer coordinate rectangle.
kernel images used by convolveRegionWithInterpolation
table::Key< table::Array< Kernel::Pixel > > image
virtual boost::shared_ptr< Kernel > clone() const =0
Return a pointer to a deep copy of this kernel.
geom::Extent2I const getDimensions() const
Return the Kernel's dimensions (width, height)
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.
bool computeNextRow(RowOfKernelImagesForRegion ®ionRow) const
Compute next row of subregions.
#define LSST_EXCEPT(type,...)
int getMaxInterpolationDistance() const
xy_locator xy_at(int x, int y) const
Implementation of the Class MaskedImage.
RegionList::const_iterator ConstIterator
lsst::afw::geom::Box2I shrinkBBox(lsst::afw::geom::Box2I const &bbox) const
Kernels are used for convolution with MaskedImages and (eventually) Images.
Include files required for standard LSST Exception handling.