25 #ifndef LSST_AFW_MATH_DETAIL_CONVOLVE_H
26 #define LSST_AFW_MATH_DETAIL_CONVOLVE_H
33 #include "lsst/pex/exceptions.h"
40 #define IS_INSTANCE(A, B) (dynamic_cast<B const*>(&(A)) != NULL)
67 template <
typename OutImageT,
typename InImageT>
79 template <
typename OutImageT,
typename InImageT>
80 void basicConvolve(OutImageT& convolvedImage, InImageT
const& inImage,
105 template <
typename OutImageT,
typename InImageT>
106 void basicConvolve(OutImageT& convolvedImage, InImageT
const& inImage,
118 template <
typename OutImageT,
typename InImageT>
119 void basicConvolve(OutImageT& convolvedImage, InImageT
const& inImage,
146 template <
typename OutImageT,
typename InImageT>
281 typedef std::vector<Location> LocationList;
288 void _computeImage(
Location location)
const;
303 void _moveUp(
bool isFirst,
int newHeight);
306 static inline int _computeNextSubregionLength(
int length,
int nDivisions);
317 static std::vector<int> _computeSubregionLengths(
int length,
int nDivisions);
324 mutable std::vector<ImagePtr> _imagePtrList;
326 static int const _MinInterpolationSize;
336 typedef std::vector<std::shared_ptr<KernelImagesForRegion>>
RegionList;
350 RegionList::const_iterator
begin()
const {
return _regionList.begin(); };
354 RegionList::const_iterator
end()
const {
return _regionList.end(); };
358 RegionList::iterator
begin() {
return _regionList.begin(); };
362 RegionList::iterator
end() {
return _regionList.end(); };
366 std::shared_ptr<KernelImagesForRegion>
front() {
return _regionList.front(); };
370 std::shared_ptr<KernelImagesForRegion>
back() {
return _regionList.back(); };
379 std::shared_ptr<KernelImagesForRegion const>
getRegion(
int ind)
const {
return _regionList.at(ind); };
380 bool hasData()
const {
return static_cast<bool>(_regionList[0]); };
410 template <
typename OutImageT,
typename InImageT>
448 template <
typename OutImageT,
typename InImageT>
464 inline int KernelImagesForRegion::_computeNextSubregionLength(
468 return static_cast<int>(
469 std::floor(0.5 + (static_cast<double>(length) / static_cast<double>(nDivisions))));
478 inline void KernelImagesForRegion::_insertImage(Location location,
482 if (_kernelPtr->getDimensions() != imagePtr->getDimensions()) {
483 std::ostringstream os;
484 os <<
"image dimensions = ( " << imagePtr->getWidth() <<
", " << imagePtr->getHeight() <<
") != ("
485 << _kernelPtr->getWidth() <<
", " << _kernelPtr->getHeight() <<
") = kernel dimensions";
486 throw LSST_EXCEPT(lsst::pex::exceptions::InvalidParameterError, os.str());
488 _imagePtrList[location] = imagePtr;
496 #endif // !defined(LSST_AFW_MATH_DETAIL_CONVOLVE_H)
std::shared_ptr< Image > ImagePtr
afw::table::PointKey< int > dimensions
lsst::afw::geom::Box2I getBBox() const
Get the bounding box for the region.
lsst::afw::geom::Point2I getXY0() const
Get xy0 of the image.
RegionList::const_iterator begin() const
Return the begin iterator for the list.
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.
A kernel described by a pair of functions: func(x, y) = colFunc(x) * rowFunc(y)
Location
locations of various points in the region
RegionList::iterator Iterator
RegionList::iterator begin()
Return the begin iterator for the list.
std::shared_ptr< KernelImagesForRegion const > getRegion(int ind) const
get the specified region (range-checked)
std::shared_ptr< KernelImagesForRegion > front()
Return the first region in the list.
RegionList::const_iterator end() const
Return the end iterator for the list.
RegionList::iterator end()
Return the end iterator for the list.
void convolveWithBruteForce(OutImageT &convolvedImage, InImageT const &inImage, lsst::afw::math::Kernel const &kernel, lsst::afw::math::ConvolutionControl const &convolutionControl)
Convolve an Image or MaskedImage with a Kernel by computing the kernel image at every point...
bool getDoNormalize() const
Get the doNormalize parameter.
static int getMinInterpolationSize()
Get the minInterpolationSize class constant.
An integer coordinate rectangle.
kernel images used by convolveRegionWithInterpolation
ImagePtr getImage(Location location) const
Return the image and sum at the specified location.
RegionList::const_iterator ConstIterator
Extent< int, N > floor(Extent< double, N > const &input)
Return the component-wise floor (round towards more negative).
lsst::afw::image::Image< lsst::afw::math::Kernel::Pixel > Image
std::shared_ptr< lsst::afw::math::Kernel const > KernelConstPtr
A kernel that is a linear combination of fixed basis kernels.
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.
lsst::afw::geom::Point2I getPixelIndex(Location location) const
Compute pixel index of a given location, relative to the parent image (thus offset by bottom left cor...
std::shared_ptr< Image const > ImageConstPtr
ConvolveWithInterpolationWorkingImages(geom::Extent2I const &dimensions)
RowOfKernelImagesForRegion(int nx, int ny)
Construct a RowOfKernelImagesForRegion.
std::shared_ptr< KernelImagesForRegion > back()
Return the last region in the list.
KernelImagesForRegion(KernelConstPtr kernelPtr, lsst::afw::geom::Box2I const &bbox, lsst::afw::geom::Point2I const &xy0, bool doNormalize)
Construct a KernelImagesForRegion.
bool computeNextRow(RowOfKernelImagesForRegion ®ionRow) const
Compute next row of subregions.
Kernels are used for convolution with MaskedImages and (eventually) Images.
KernelConstPtr getKernel() const
Get the kernel (as a shared pointer to const)
void basicConvolve(OutImageT &convolvedImage, InImageT const &inImage, lsst::afw::math::Kernel const &kernel, lsst::afw::math::ConvolutionControl const &convolutionControl)
Low-level convolution function that does not set edge pixels.
A collection of Kernel images for special locations on a rectangular region of an image...
A kernel that has only one non-zero pixel (of value 1)
lsst::afw::image::Image< lsst::afw::math::Kernel::Pixel > Image
std::vector< std::shared_ptr< KernelImagesForRegion > > RegionList