25 #ifndef LSST_AFW_MATH_DETAIL_CONVOLVE_H 26 #define LSST_AFW_MATH_DETAIL_CONVOLVE_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>
229 ImagePtr bottomRightImagePtr, ImagePtr topLeftImagePtr, ImagePtr topRightImagePtr);
254 KernelConstPtr
getKernel()
const {
return _kernelPtr; };
288 void _computeImage(
Location location)
const;
289 inline void _insertImage(
Location location, ImagePtr imagePtr)
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);
320 KernelConstPtr _kernelPtr;
326 static int const _MinInterpolationSize;
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(); };
380 bool hasData()
const {
return static_cast<bool>(_regionList[0]); };
388 RegionList _regionList;
410 template <
typename OutImageT,
typename InImageT>
422 : leftImage(dimensions),
423 rightImage(dimensions),
424 leftDeltaImage(dimensions),
425 rightDeltaImage(dimensions),
426 deltaImage(dimensions),
427 kernelImage(dimensions) {}
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()) {
484 os <<
"image dimensions = ( " << imagePtr->getWidth() <<
", " << imagePtr->getHeight() <<
") != (" 485 << _kernelPtr->getWidth() <<
", " << _kernelPtr->getHeight() <<
") = kernel dimensions";
488 _imagePtrList[location] = imagePtr;
496 #endif // !defined(LSST_AFW_MATH_DETAIL_CONVOLVE_H)
lsst::geom::Point2I getXY0() const
Get xy0 of the image.
std::shared_ptr< Image > ImagePtr
lsst::geom::Box2I getBBox() const
Get the bounding box for the region.
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.
ImagePtr getImage(Location location) const
Return the image and sum at the specified location.
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 > front()
Return the first region in 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.
kernel images used by convolveRegionWithInterpolation
RegionList::const_iterator ConstIterator
afw::table::PointKey< int > dimensions
A base class for image defects.
lsst::afw::image::Image< lsst::afw::math::Kernel::Pixel > Image
bool computeNextRow(RowOfKernelImagesForRegion ®ionRow) const
Compute next row of subregions.
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.
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
lsst::geom::Point2I getPixelIndex(Location location) const
Compute pixel index of a given location, relative to the parent image (thus offset by bottom left cor...
RegionList::const_iterator end() const
Return the end iterator for the list.
KernelImagesForRegion(KernelConstPtr kernelPtr, lsst::geom::Box2I const &bbox, lsst::geom::Point2I const &xy0, bool doNormalize)
Construct a KernelImagesForRegion.
std::shared_ptr< Image const > ImageConstPtr
RegionList::const_iterator begin() const
Return the begin iterator for the list.
std::shared_ptr< KernelImagesForRegion > back()
Return the last region in the list.
Reports invalid arguments.
ConvolveWithInterpolationWorkingImages(lsst::geom::Extent2I const &dimensions)
std::shared_ptr< KernelImagesForRegion const > getRegion(int ind) const
get the specified region (range-checked)
KernelConstPtr getKernel() const
Get the kernel (as a shared pointer to const)
Kernels are used for convolution with MaskedImages and (eventually) Images.
An integer coordinate rectangle.
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