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);
136 rgnIter != rgnEnd; ++rgnIter) {
137 (*rgnIter)->_moveUp(isFirst, height);
149 int remWidth = this->_bbox.
getWidth();
150 int remXDiv = regionRow.
getNX();
152 rgnIter != rgnEnd; ++rgnIter) {
153 int width = _computeNextSubregionLength(remWidth, remXDiv);
159 _doNormalize, blImagePtr, brImagePtr, tlImagePtr, trImageNullPtr));
160 *rgnIter = regionPtr;
168 tlImagePtr = regionPtr->getImage(
TOP_RIGHT);
174 void KernelImagesForRegion::_computeImage(Location location)
const {
175 ImagePtr imagePtr = _imagePtrList[location];
178 os <<
"Null imagePtr at location " << location;
187 std::vector<int> KernelImagesForRegion::_computeSubregionLengths(
int length,
int nDivisions) {
188 if ((nDivisions > length) || (nDivisions < 1)) {
190 os <<
"nDivisions = " << nDivisions <<
" not in range [1, " <<
length <<
" = length]";
195 for (
int remNDiv = nDivisions; remNDiv > 0; --remNDiv) {
196 int subLength = _computeNextSubregionLength(remLength, remNDiv);
199 os <<
"Bug! _computeSubregionLengths(length=" <<
length <<
", nDivisions=" << nDivisions
200 <<
") computed sublength = " << subLength <<
" < 0; remLength = " << remLength;
204 remLength -= subLength;
206 return regionLengths;
209 void KernelImagesForRegion::_moveUp(
bool isFirst,
int newHeight) {
225 int const KernelImagesForRegion::_MinInterpolationSize = 10;
228 : _nx(nx), _ny(ny), _yInd(-1), _regionList(nx) {
229 if ((nx < 1) || (ny < 1)) {
231 os <<
"nx = " << nx <<
" and/or ny = " << ny <<
" < 1";