40 #include "boost/assign/list_of.hpp"
48 namespace pexExcept = lsst::pex::exceptions;
49 namespace pexLog = lsst::pex::logging;
50 namespace afwGeom = lsst::afw::geom;
52 namespace mathDetail = lsst::afw::math::detail;
67 lsst::daf::base::Citizen(typeid(this)),
68 _kernelPtr(kernelPtr),
71 _doNormalize(doNormalize),
75 throw LSST_EXCEPT(pexExcept::InvalidParameterError,
"kernelPtr is null");
77 pexLog::TTrace<6>(
"lsst.afw.math.convolve",
78 "KernelImagesForRegion(bbox(minimum=(%d, %d), extent=(%d, %d)), xy0=(%d, %d), doNormalize=%d, images...)",
104 lsst::daf::base::Citizen(typeid(this)),
105 _kernelPtr(kernelPtr),
108 _doNormalize(doNormalize),
112 throw LSST_EXCEPT(pexExcept::InvalidParameterError,
"kernelPtr is null");
118 pexLog::TTrace<6>(
"lsst.afw.math.convolve",
119 "KernelImagesForRegion(bbox(minimum=(%d, %d), extent=(%d, %d)), xy0=(%d, %d), doNormalize=%d, images...)",
131 if (_imagePtrList[location]) {
132 return _imagePtrList[location];
136 _imagePtrList[location] = imagePtr;
137 _computeImage(location);
162 std::ostringstream os;
163 os <<
"Bug: unhandled location = " << location;
164 throw LSST_EXCEPT(pexExcept::InvalidParameterError, os.str());
184 bool hasData = regionRow.
hasData();
187 startY = regionRow.
front()->getBBox().getMaxY() + 1;
194 int remYDiv = regionRow.
getNY() - yInd;
195 int height = _computeNextSubregionLength(remHeight, remYDiv);
201 rgnIter != rgnEnd; ++rgnIter) {
202 (*rgnIter)->_moveUp(isFirst, height);
207 ImagePtr blImagePtr = getImage(BOTTOM_LEFT);
215 int remXDiv = regionRow.
getNX();
217 rgnIter != rgnEnd; ++rgnIter) {
218 int width = _computeNextSubregionLength(remWidth, remXDiv);
231 *rgnIter = regionPtr;
234 regionPtr->getImage(TOP_LEFT);
238 blImagePtr = regionPtr->getImage(BOTTOM_RIGHT);
239 tlImagePtr = regionPtr->getImage(TOP_RIGHT);
251 ImagePtr imagePtr = _imagePtrList[location];
253 std::ostringstream os;
254 os <<
"Null imagePtr at location " << location;
255 throw LSST_EXCEPT(pexExcept::NotFoundError, os.str());
259 _kernelPtr->computeImage(
278 if ((nDivisions > length) || (nDivisions < 1)) {
279 std::ostringstream os;
280 os <<
"nDivisions = " << nDivisions <<
" not in range [1, " << length <<
" = length]";
281 throw LSST_EXCEPT(pexExcept::InvalidParameterError, os.str());
283 std::vector<int> regionLengths;
284 int remLength = length;
285 for (
int remNDiv = nDivisions; remNDiv > 0; --remNDiv) {
286 int subLength = _computeNextSubregionLength(remLength, remNDiv);
288 std::ostringstream os;
289 os <<
"Bug! _computeSubregionLengths(length=" << length <<
", nDivisions=" << nDivisions <<
290 ") computed sublength = " << subLength <<
" < 0; remLength = " << remLength;
291 throw LSST_EXCEPT(pexExcept::RuntimeError, os.str());
293 regionLengths.push_back(subLength);
294 remLength -= subLength;
296 return regionLengths;
319 _imagePtrList[BOTTOM_RIGHT].swap(_imagePtrList[TOP_RIGHT]);
320 _imagePtrList[BOTTOM_LEFT].swap(_imagePtrList[TOP_LEFT]);
323 _computeImage(TOP_RIGHT);
325 _computeImage(TOP_LEFT);
344 if ((nx < 1) || (ny < 1)) {
345 std::ostringstream os;
346 os <<
"nx = " << nx <<
" and/or ny = " << ny <<
" < 1";
347 throw LSST_EXCEPT(pexExcept::InvalidParameterError, os.str());
An include file to include the header files for lsst::afw::geom.
KernelConstPtr _kernelPtr
double indexToPosition(double ind)
Convert image index to image position.
static int const _MinInterpolationSize
boost::shared_ptr< Image > ImagePtr
boost::shared_ptr< lsst::afw::math::Kernel const > KernelConstPtr
definition of the Trace messaging facilities
ImagePtr getImage(Location location) const
boost::shared_ptr< KernelImagesForRegion > front()
Return the first region in the list.
An integer coordinate rectangle.
table::Key< table::Array< Kernel::Pixel > > image
RegionList::iterator Iterator
RegionList::const_iterator end() const
Return the end iterator for the list.
lsst::afw::geom::Box2I _bbox
void _computeImage(Location location) const
geom::Box2I const & _bbox
void _moveUp(bool isFirst, int newHeight)
Move the region up one segment.
static std::vector< int > _computeSubregionLengths(int length, int nDivisions)
A row of KernelImagesForRegion.
bool computeNextRow(RowOfKernelImagesForRegion ®ionRow) const
Compute next row of subregions.
#define LSST_EXCEPT(type,...)
RegionList::const_iterator begin() const
Return the begin iterator for the list.
boost::shared_ptr< KernelImagesForRegion > Ptr
lsst::afw::geom::Point2I getPixelIndex(Location location) const
Point2I const getMin() const
void _insertImage(Location location, ImagePtr imagePtr) const
KernelImagesForRegion(KernelConstPtr kernelPtr, lsst::afw::geom::Box2I const &bbox, lsst::afw::geom::Point2I const &xy0, bool doNormalize)
RowOfKernelImagesForRegion(int nx, int ny)
Construct a RowOfKernelImagesForRegion.
Extent< int, 2 > Extent2I
Include files required for standard LSST Exception handling.
lsst::afw::geom::Point2I _xy0