34 #include "boost/assign/list_of.hpp" 51 : daf::base::Citizen(typeid(this)),
52 _kernelPtr(kernelPtr),
55 _doNormalize(doNormalize),
60 LOGL_DEBUG(
"TRACE5.afw.math.convolve.KernelImagesForRegion",
61 "KernelImagesForRegion(bbox(minimum=(%d, %d), extent=(%d, %d)), xy0=(%d, %d), doNormalize=%d, " 71 : daf::base::
Citizen(typeid(this)),
72 _kernelPtr(kernelPtr),
75 _doNormalize(doNormalize),
82 _insertImage(
TOP_LEFT, topLeftImagePtr);
83 _insertImage(
TOP_RIGHT, topRightImagePtr);
84 LOGL_DEBUG(
"TRACE5.afw.math.convolve.KernelImagesForRegion",
85 "KernelImagesForRegion(bbox(minimum=(%d, %d), extent=(%d, %d)), xy0=(%d, %d), doNormalize=%d, " 92 if (_imagePtrList[location]) {
93 return _imagePtrList[location];
97 _imagePtrList[location] = imagePtr;
98 _computeImage(location);
118 os <<
"Bug: unhandled location = " << location;
129 bool hasData = regionRow.
hasData();
132 startY = regionRow.
front()->getBBox().getMaxY() + 1;
134 startY = this->_bbox.
getMinY();
138 int remHeight = 1 + this->_bbox.
getMaxY() - startY;
139 int remYDiv = regionRow.
getNY() - yInd;
140 int height = _computeNextSubregionLength(remHeight, remYDiv);
146 rgnIter != rgnEnd; ++rgnIter) {
147 (*rgnIter)->_moveUp(isFirst, height);
159 int remWidth = this->_bbox.
getWidth();
160 int remXDiv = regionRow.
getNX();
162 rgnIter != rgnEnd; ++rgnIter) {
163 int width = _computeNextSubregionLength(remWidth, remXDiv);
169 _doNormalize, blImagePtr, brImagePtr, tlImagePtr, trImageNullPtr));
170 *rgnIter = regionPtr;
178 tlImagePtr = regionPtr->getImage(
TOP_RIGHT);
184 void KernelImagesForRegion::_computeImage(
Location location)
const {
185 ImagePtr imagePtr = _imagePtrList[location];
188 os <<
"Null imagePtr at location " << location;
197 std::vector<int> KernelImagesForRegion::_computeSubregionLengths(
int length,
int nDivisions) {
198 if ((nDivisions > length) || (nDivisions < 1)) {
200 os <<
"nDivisions = " << nDivisions <<
" not in range [1, " << length <<
" = length]";
204 int remLength = length;
205 for (
int remNDiv = nDivisions; remNDiv > 0; --remNDiv) {
206 int subLength = _computeNextSubregionLength(remLength, remNDiv);
209 os <<
"Bug! _computeSubregionLengths(length=" << length <<
", nDivisions=" << nDivisions
210 <<
") computed sublength = " << subLength <<
" < 0; remLength = " << remLength;
213 regionLengths.push_back(subLength);
214 remLength -= subLength;
216 return regionLengths;
219 void KernelImagesForRegion::_moveUp(
bool isFirst,
int newHeight) {
229 _computeImage(TOP_RIGHT);
231 _computeImage(TOP_LEFT);
235 int const KernelImagesForRegion::_MinInterpolationSize = 10;
238 : _nx(nx), _ny(ny), _yInd(-1), _regionList(nx) {
239 if ((nx < 1) || (ny < 1)) {
241 os <<
"nx = " << nx <<
" and/or ny = " << ny <<
" < 1";
double indexToPosition(double ind)
Convert image index to image position.
Point2I const getMin() const
ImagePtr getImage(Location location) const
Return the image and sum at the specified location.
Location
locations of various points in the region
RegionList::iterator Iterator
std::shared_ptr< KernelImagesForRegion > front()
Return the first region in the list.
#define LOGL_DEBUG(logger, message...)
A base class for image defects.
bool computeNextRow(RowOfKernelImagesForRegion ®ionRow) const
Compute next row of subregions.
A row of KernelImagesForRegion.
#define LSST_EXCEPT(type,...)
Extent< int, 2 > Extent2I
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...
Citizen(const std::type_info &)
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.
RegionList::const_iterator begin() const
Return the begin iterator for the list.
RowOfKernelImagesForRegion(int nx, int ny)
Construct a RowOfKernelImagesForRegion.
lsst::afw::image::Image< lsst::afw::math::Kernel::Pixel > Image