34 #include "boost/assign/list_of.hpp"
51 : _kernelPtr(kernelPtr), _bbox(
bbox), _xy0(xy0), _doNormalize(doNormalize), _imagePtrList(4) {
55 LOGL_DEBUG(
"TRACE5.afw.math.convolve.KernelImagesForRegion",
56 "KernelImagesForRegion(bbox(minimum=(%d, %d), extent=(%d, %d)), xy0=(%d, %d), doNormalize=%d, "
66 : _kernelPtr(kernelPtr), _bbox(
bbox), _xy0(xy0), _doNormalize(doNormalize), _imagePtrList(4) {
72 _insertImage(
TOP_LEFT, topLeftImagePtr);
73 _insertImage(
TOP_RIGHT, topRightImagePtr);
74 LOGL_DEBUG(
"TRACE5.afw.math.convolve.KernelImagesForRegion",
75 "KernelImagesForRegion(bbox(minimum=(%d, %d), extent=(%d, %d)), xy0=(%d, %d), doNormalize=%d, "
82 if (_imagePtrList[location]) {
83 return _imagePtrList[location];
87 _imagePtrList[location] = imagePtr;
88 _computeImage(location);
108 os <<
"Bug: unhandled location = " << location;
119 bool hasData = regionRow.
hasData();
122 startY = regionRow.
front()->getBBox().getMaxY() + 1;
124 startY = this->_bbox.
getMinY();
128 int remHeight = 1 + this->_bbox.
getMaxY() - startY;
129 int remYDiv = regionRow.
getNY() - yInd;
130 int height = _computeNextSubregionLength(remHeight, remYDiv);
135 for (
auto & rgnIter : regionRow) {
136 rgnIter->_moveUp(isFirst, height);
148 int remWidth = this->_bbox.
getWidth();
149 int remXDiv = regionRow.
getNX();
150 for (
auto & rgnIter : regionRow) {
151 int width = _computeNextSubregionLength(remWidth, remXDiv);
157 _doNormalize, blImagePtr, brImagePtr, tlImagePtr, trImageNullPtr));
166 tlImagePtr = regionPtr->getImage(
TOP_RIGHT);
172 void KernelImagesForRegion::_computeImage(Location location)
const {
173 ImagePtr imagePtr = _imagePtrList[location];
176 os <<
"Null imagePtr at location " << location;
185 std::vector<int> KernelImagesForRegion::_computeSubregionLengths(
int length,
int nDivisions) {
186 if ((nDivisions > length) || (nDivisions < 1)) {
188 os <<
"nDivisions = " << nDivisions <<
" not in range [1, " <<
length <<
" = length]";
193 for (
int remNDiv = nDivisions; remNDiv > 0; --remNDiv) {
194 int subLength = _computeNextSubregionLength(remLength, remNDiv);
197 os <<
"Bug! _computeSubregionLengths(length=" <<
length <<
", nDivisions=" << nDivisions
198 <<
") computed sublength = " << subLength <<
" < 0; remLength = " << remLength;
202 remLength -= subLength;
204 return regionLengths;
207 void KernelImagesForRegion::_moveUp(
bool isFirst,
int newHeight) {
223 int const KernelImagesForRegion::_MinInterpolationSize = 10;
226 : _nx(nx), _ny(ny), _yInd(-1), _regionList(nx) {
227 if ((nx < 1) || (ny < 1)) {
229 os <<
"nx = " << nx <<
" and/or ny = " << ny <<
" < 1";
#define LSST_EXCEPT(type,...)
#define LOGL_DEBUG(logger, message...)
lsst::geom::Extent2I const getDimensions() const
Return the Kernel's dimensions (width, height)
double computeImage(lsst::afw::image::Image< Pixel > &image, bool doNormalize, double x=0.0, double y=0.0) const
Compute an image (pixellized representation of the kernel) in place.
Location
locations of various points in the region
KernelImagesForRegion(KernelConstPtr kernelPtr, lsst::geom::Box2I const &bbox, lsst::geom::Point2I const &xy0, bool doNormalize)
Construct a KernelImagesForRegion.
bool computeNextRow(RowOfKernelImagesForRegion ®ionRow) const
Compute next row of subregions.
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...
ImagePtr getImage(Location location) const
Return the image and sum at the specified location.
std::shared_ptr< Image > ImagePtr
lsst::afw::image::Image< lsst::afw::math::Kernel::Pixel > Image
A row of KernelImagesForRegion.
RowOfKernelImagesForRegion(int nx, int ny)
Construct a RowOfKernelImagesForRegion.
std::shared_ptr< KernelImagesForRegion > front()
Return the first region in the list.
int getMinY() const noexcept
int getHeight() const noexcept
Point2I const getMin() const noexcept
int getMinX() const noexcept
int getWidth() const noexcept
int getMaxX() const noexcept
int getMaxY() const noexcept
double indexToPosition(double ind)
Convert image index to image position.
Extent< int, 2 > Extent2I
A base class for image defects.