47 : _kernelPtr(kernelPtr), _bbox(bbox), _xy0(xy0), _doNormalize(doNormalize), _imagePtrList(4) {
51 LOGL_DEBUG(
"TRACE5.lsst.afw.math.convolve.KernelImagesForRegion",
52 "KernelImagesForRegion(bbox(minimum=(%d, %d), extent=(%d, %d)), xy0=(%d, %d), doNormalize=%d, "
54 _bbox.getMinX(), _bbox.getMinY(), _bbox.getWidth(), _bbox.getHeight(), _xy0[0], _xy0[1],
62 : _kernelPtr(kernelPtr), _bbox(bbox), _xy0(xy0), _doNormalize(doNormalize), _imagePtrList(4) {
68 _insertImage(
TOP_LEFT, topLeftImagePtr);
69 _insertImage(
TOP_RIGHT, topRightImagePtr);
70 LOGL_DEBUG(
"TRACE5.lsst.afw.math.convolve.KernelImagesForRegion",
71 "KernelImagesForRegion(bbox(minimum=(%d, %d), extent=(%d, %d)), xy0=(%d, %d), doNormalize=%d, "
73 _bbox.getMinX(), _bbox.getMinY(), _bbox.getWidth(), _bbox.getHeight(), _xy0[0], _xy0[1],
78 if (_imagePtrList[location]) {
79 return _imagePtrList[location];
83 _imagePtrList[location] = imagePtr;
84 _computeImage(location);
91 return _bbox.getMin();
104 os <<
"Bug: unhandled location = " << location;
115 bool hasData = regionRow.
hasData();
118 startY = regionRow.
front()->getBBox().getMaxY() + 1;
120 startY = this->_bbox.getMinY();
124 int remHeight = 1 + this->_bbox.getMaxY() - startY;
125 int remYDiv = regionRow.
getNY() - yInd;
126 int height = _computeNextSubregionLength(remHeight, remYDiv);
131 for (
auto & rgnIter : regionRow) {
132 rgnIter->_moveUp(isFirst, height);
144 int remWidth = this->_bbox.getWidth();
145 int remXDiv = regionRow.
getNX();
146 for (
auto & rgnIter : regionRow) {
147 int width = _computeNextSubregionLength(remWidth, remXDiv);
153 _doNormalize, blImagePtr, brImagePtr, tlImagePtr, trImageNullPtr));
162 tlImagePtr = regionPtr->getImage(
TOP_RIGHT);
168void KernelImagesForRegion::_computeImage(Location location)
const {
169 ImagePtr imagePtr = _imagePtrList[location];
172 os <<
"Null imagePtr at location " << location;
181std::vector<int> KernelImagesForRegion::_computeSubregionLengths(
int length,
int nDivisions) {
182 if ((nDivisions > length) || (nDivisions < 1)) {
184 os <<
"nDivisions = " << nDivisions <<
" not in range [1, " << length <<
" = length]";
188 int remLength = length;
189 for (
int remNDiv = nDivisions; remNDiv > 0; --remNDiv) {
190 int subLength = _computeNextSubregionLength(remLength, remNDiv);
193 os <<
"Bug! _computeSubregionLengths(length=" << length <<
", nDivisions=" << nDivisions
194 <<
") computed sublength = " << subLength <<
" < 0; remLength = " << remLength;
198 remLength -= subLength;
200 return regionLengths;
203void KernelImagesForRegion::_moveUp(
bool isFirst,
int newHeight) {
219int const KernelImagesForRegion::_MinInterpolationSize = 10;
222 : _nx(nx), _ny(ny), _yInd(-1), _regionList(nx) {
223 if ((nx < 1) || (ny < 1)) {
225 os <<
"nx = " << nx <<
" and/or ny = " << ny <<
" < 1";
#define LSST_EXCEPT(type,...)
#define LOGL_DEBUG(logger, message...)
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
std::shared_ptr< const lsst::afw::math::Kernel > KernelConstPtr
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.
double indexToPosition(double ind)
Convert image index to image position.
Extent< int, 2 > Extent2I