LSST Applications g02d81e74bb+86cf3d8bc9,g180d380827+7a4e862ed4,g2079a07aa2+86d27d4dc4,g2305ad1205+e1ca1c66fa,g29320951ab+012e1474a1,g295015adf3+341ea1ce94,g2bbee38e9b+0e5473021a,g337abbeb29+0e5473021a,g33d1c0ed96+0e5473021a,g3a166c0a6a+0e5473021a,g3ddfee87b4+c429d67c83,g48712c4677+f88676dd22,g487adcacf7+27e1e21933,g50ff169b8f+96c6868917,g52b1c1532d+585e252eca,g591dd9f2cf+b41db86c35,g5a732f18d5+53520f316c,g64a986408d+86cf3d8bc9,g858d7b2824+86cf3d8bc9,g8a8a8dda67+585e252eca,g99cad8db69+84912a7fdc,g9ddcbc5298+9a081db1e4,ga1e77700b3+15fc3df1f7,ga8c6da7877+a2b54eae19,gb0e22166c9+60f28cb32d,gba4ed39666+c2a2e4ac27,gbb8dafda3b+6681f309db,gc120e1dc64+f0fcc2f6d8,gc28159a63d+0e5473021a,gcf0d15dbbd+c429d67c83,gdaeeff99f8+f9a426f77a,ge6526c86ff+0433e6603d,ge79ae78c31+0e5473021a,gee10cc3b42+585e252eca,gff1a9f87cc+86cf3d8bc9,w.2024.17
LSST Data Management Base Package
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | List of all members
lsst::afw::math::detail::KernelImagesForRegion Class Reference

A collection of Kernel images for special locations on a rectangular region of an image. More...

#include <Convolve.h>

Public Types

enum  Location { BOTTOM_LEFT , BOTTOM_RIGHT , TOP_LEFT , TOP_RIGHT }
 locations of various points in the region More...
 
using KernelConstPtr = std::shared_ptr<const lsst::afw::math::Kernel>
 
using Image = lsst::afw::image::Image<lsst::afw::math::Kernel::Pixel>
 
using ImagePtr = std::shared_ptr<Image>
 
using ImageConstPtr = std::shared_ptr<const Image>
 

Public Member Functions

 KernelImagesForRegion (KernelConstPtr kernelPtr, lsst::geom::Box2I const &bbox, lsst::geom::Point2I const &xy0, bool doNormalize)
 Construct a KernelImagesForRegion.
 
 KernelImagesForRegion (KernelConstPtr kernelPtr, lsst::geom::Box2I const &bbox, lsst::geom::Point2I const &xy0, bool doNormalize, ImagePtr bottomLeftImagePtr, ImagePtr bottomRightImagePtr, ImagePtr topLeftImagePtr, ImagePtr topRightImagePtr)
 Construct a KernelImagesForRegion with some or all corner images.
 
lsst::geom::Box2I getBBox () const
 Get the bounding box for the region.
 
lsst::geom::Point2I getXY0 () const
 Get xy0 of the image.
 
bool getDoNormalize () const
 Get the doNormalize parameter.
 
ImagePtr getImage (Location location) const
 Return the image and sum at the specified location.
 
KernelConstPtr getKernel () const
 Get the kernel (as a shared pointer to const)
 
lsst::geom::Point2I getPixelIndex (Location location) const
 Compute pixel index of a given location, relative to the parent image (thus offset by bottom left corner of bounding box)
 
bool computeNextRow (RowOfKernelImagesForRegion &regionRow) const
 Compute next row of subregions.
 

Static Public Member Functions

static int getMinInterpolationSize ()
 Get the minInterpolationSize class constant.
 

Detailed Description

A collection of Kernel images for special locations on a rectangular region of an image.

See the Location enum for a list of those special locations.

Warning
The kernel images along the top and right edges are computed one row or column past the bounding box. This allows abutting KernelImagesForRegion to share corner and edge kernel images, which is useful when dividing a KernelImagesForRegion into subregions.
The bounding box for the region applies to the parent image.

This is a low-level helper class for recursive convolving with interpolation. Many of these objects may be created during a convolution, and many will share kernel images. It uses shared pointers to kernels and kernel images for increased speed and decreased memory usage (at the expense of safety). Note that null pointers are NOT acceptable for the constructors!

Also note that it uses lazy evaluation: images are computed when they are wanted.

Definition at line 172 of file Convolve.h.

Member Typedef Documentation

◆ Image

Definition at line 175 of file Convolve.h.

◆ ImageConstPtr

Definition at line 177 of file Convolve.h.

◆ ImagePtr

Definition at line 176 of file Convolve.h.

◆ KernelConstPtr

Definition at line 174 of file Convolve.h.

Member Enumeration Documentation

◆ Location

locations of various points in the region

RIGHT and TOP are one column/row beyond the region's bounding box. Thus adjacent regions share corner images.

The posiitions are: BOTTOM_LEFT, BOTTOM_RIGHT, TOP_LEFT, TOP_RIGHT

These locations always refer to the center of a pixel. Thus if the region has an odd size along an axis (so that the span to the top and right, which are one beyond, is even), the middle pixel will be 1/2 pixel off from the true center along that axis (in an unspecified direction).

Enumerator
BOTTOM_LEFT 
BOTTOM_RIGHT 
TOP_LEFT 
TOP_RIGHT 

Definition at line 192 of file Convolve.h.

Constructor & Destructor Documentation

◆ KernelImagesForRegion() [1/2]

lsst::afw::math::detail::KernelImagesForRegion::KernelImagesForRegion ( KernelConstPtr kernelPtr,
lsst::geom::Box2I const & bbox,
lsst::geom::Point2I const & xy0,
bool doNormalize )

Construct a KernelImagesForRegion.

Parameters
kernelPtrkernel
bboxbounding box of region of an image for which we want to compute kernel images (inclusive and relative to parent image)
xy0xy0 of image for which we want to compute kernel images
doNormalizenormalize the kernel images?
Exceptions
lsst::pex::exceptions::InvalidParameterErrorif kernelPtr is null

Definition at line 45 of file KernelImagesForRegion.cc.

47 : _kernelPtr(kernelPtr), _bbox(bbox), _xy0(xy0), _doNormalize(doNormalize), _imagePtrList(4) {
48 if (!_kernelPtr) {
49 throw LSST_EXCEPT(pexExcept::InvalidParameterError, "kernelPtr is null");
50 }
51 LOGL_DEBUG("TRACE5.lsst.afw.math.convolve.KernelImagesForRegion",
52 "KernelImagesForRegion(bbox(minimum=(%d, %d), extent=(%d, %d)), xy0=(%d, %d), doNormalize=%d, "
53 "images...)",
54 _bbox.getMinX(), _bbox.getMinY(), _bbox.getWidth(), _bbox.getHeight(), _xy0[0], _xy0[1],
55 _doNormalize);
56}
AmpInfoBoxKey bbox
Definition Amplifier.cc:117
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition Exception.h:48
#define LOGL_DEBUG(logger, message...)
Log a debug-level message using a varargs/printf style interface.
Definition Log.h:515
int getMinY() const noexcept
Definition Box.h:158
int getHeight() const noexcept
Definition Box.h:188
int getMinX() const noexcept
Definition Box.h:157
int getWidth() const noexcept
Definition Box.h:187
Reports invalid arguments.
Definition Runtime.h:66

◆ KernelImagesForRegion() [2/2]

lsst::afw::math::detail::KernelImagesForRegion::KernelImagesForRegion ( KernelConstPtr kernelPtr,
lsst::geom::Box2I const & bbox,
lsst::geom::Point2I const & xy0,
bool doNormalize,
ImagePtr bottomLeftImagePtr,
ImagePtr bottomRightImagePtr,
ImagePtr topLeftImagePtr,
ImagePtr topRightImagePtr )

Construct a KernelImagesForRegion with some or all corner images.

Null corner image pointers are ignored.

Parameters
kernelPtrkernel
bboxbounding box of region of an image for which we want to compute kernel images (inclusive and relative to parent image)
xy0xy0 of image
doNormalizenormalize the kernel images?
bottomLeftImagePtrkernel image and sum at bottom left of region
bottomRightImagePtrkernel image and sum at bottom right of region
topLeftImagePtrkernel image and sum at top left of region
topRightImagePtrkernel image and sum at top right of region
Exceptions
lsst::pex::exceptions::InvalidParameterErrorif kernelPtr is null
lsst::pex::exceptions::InvalidParameterErrorif an image has the wrong dimensions
Warning
: if any images are incorrect you will get a mess.

Definition at line 58 of file KernelImagesForRegion.cc.

62 : _kernelPtr(kernelPtr), _bbox(bbox), _xy0(xy0), _doNormalize(doNormalize), _imagePtrList(4) {
63 if (!_kernelPtr) {
64 throw LSST_EXCEPT(pexExcept::InvalidParameterError, "kernelPtr is null");
65 }
66 _insertImage(BOTTOM_LEFT, bottomLeftImagePtr);
67 _insertImage(BOTTOM_RIGHT, bottomRightImagePtr);
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, "
72 "images...)",
73 _bbox.getMinX(), _bbox.getMinY(), _bbox.getWidth(), _bbox.getHeight(), _xy0[0], _xy0[1],
74 _doNormalize);
75}

Member Function Documentation

◆ computeNextRow()

bool lsst::afw::math::detail::KernelImagesForRegion::computeNextRow ( RowOfKernelImagesForRegion & regionRow) const

Compute next row of subregions.

For the first row call with a new RowOfKernelImagesForRegion (with the desired number of columns and rows). Every subequent call updates the data in the RowOfKernelImagesForRegion.

Parameters
[in,out]regionRowRowOfKernelImagesForRegion object
Returns
true if a new row was computed, false if supplied RowOfKernelImagesForRegion is for the last row.

Definition at line 110 of file KernelImagesForRegion.cc.

110 {
111 if (regionRow.isLastRow()) {
112 return false;
113 }
114
115 bool hasData = regionRow.hasData();
116 int startY;
117 if (hasData) {
118 startY = regionRow.front()->getBBox().getMaxY() + 1;
119 } else {
120 startY = this->_bbox.getMinY();
121 }
122
123 int yInd = regionRow.incrYInd();
124 int remHeight = 1 + this->_bbox.getMaxY() - startY;
125 int remYDiv = regionRow.getNY() - yInd;
126 int height = _computeNextSubregionLength(remHeight, remYDiv);
127
128 if (hasData) {
129 // Move each region up one segment
130 bool isFirst = true;
131 for (auto & rgnIter : regionRow) {
132 rgnIter->_moveUp(isFirst, height);
133 isFirst = false;
134 }
135
136 } else {
137 ImagePtr blImagePtr = getImage(BOTTOM_LEFT);
138 ImagePtr brImagePtr;
139 ImagePtr tlImagePtr;
140 ImagePtr const trImageNullPtr;
141
142 lsst::geom::Point2I blCorner = lsst::geom::Point2I(this->_bbox.getMinX(), startY);
143
144 int remWidth = this->_bbox.getWidth();
145 int remXDiv = regionRow.getNX();
146 for (auto & rgnIter : regionRow) {
147 int width = _computeNextSubregionLength(remWidth, remXDiv);
148 --remXDiv;
149 remWidth -= width;
150
152 _kernelPtr, lsst::geom::Box2I(blCorner, lsst::geom::Extent2I(width, height)), _xy0,
153 _doNormalize, blImagePtr, brImagePtr, tlImagePtr, trImageNullPtr));
154 rgnIter = regionPtr;
155
156 if (!tlImagePtr) {
157 regionPtr->getImage(TOP_LEFT);
158 }
159
160 blCorner += lsst::geom::Extent2I(width, 0);
161 blImagePtr = regionPtr->getImage(BOTTOM_RIGHT);
162 tlImagePtr = regionPtr->getImage(TOP_RIGHT);
163 }
164 }
165 return true;
166}
KernelImagesForRegion(KernelConstPtr kernelPtr, lsst::geom::Box2I const &bbox, lsst::geom::Point2I const &xy0, bool doNormalize)
Construct a KernelImagesForRegion.
ImagePtr getImage(Location location) const
Return the image and sum at the specified location.
An integer coordinate rectangle.
Definition Box.h:55
int getMaxY() const noexcept
Definition Box.h:162
Extent< int, 2 > Extent2I
Definition Extent.h:397
Point< int, 2 > Point2I
Definition Point.h:321

◆ getBBox()

lsst::geom::Box2I lsst::afw::math::detail::KernelImagesForRegion::getBBox ( ) const
inline

Get the bounding box for the region.

Definition at line 234 of file Convolve.h.

234{ return _bbox; };

◆ getDoNormalize()

bool lsst::afw::math::detail::KernelImagesForRegion::getDoNormalize ( ) const
inline

Get the doNormalize parameter.

Definition at line 242 of file Convolve.h.

242{ return _doNormalize; };

◆ getImage()

KernelImagesForRegion::ImagePtr lsst::afw::math::detail::KernelImagesForRegion::getImage ( Location location) const

Return the image and sum at the specified location.

If the image has not yet been computed, it is computed at this time.

Parameters
locationlocation of image

Definition at line 77 of file KernelImagesForRegion.cc.

77 {
78 if (_imagePtrList[location]) {
79 return _imagePtrList[location];
80 }
81
82 ImagePtr imagePtr(new Image(_kernelPtr->getDimensions()));
83 _imagePtrList[location] = imagePtr;
84 _computeImage(location);
85 return imagePtr;
86}
lsst::geom::Extent2I const getDimensions() const
Return the Kernel's dimensions (width, height)
Definition Kernel.h:212
lsst::afw::image::Image< lsst::afw::math::Kernel::Pixel > Image
Definition Convolve.h:175

◆ getKernel()

KernelConstPtr lsst::afw::math::detail::KernelImagesForRegion::getKernel ( ) const
inline

Get the kernel (as a shared pointer to const)

Definition at line 254 of file Convolve.h.

254{ return _kernelPtr; };

◆ getMinInterpolationSize()

static int lsst::afw::math::detail::KernelImagesForRegion::getMinInterpolationSize ( )
inlinestatic

Get the minInterpolationSize class constant.

Definition at line 278 of file Convolve.h.

278{ return _MinInterpolationSize; };

◆ getPixelIndex()

lsst::geom::Point2I lsst::afw::math::detail::KernelImagesForRegion::getPixelIndex ( Location location) const

Compute pixel index of a given location, relative to the parent image (thus offset by bottom left corner of bounding box)

Parameters
locationlocation for which to return pixel index

Definition at line 88 of file KernelImagesForRegion.cc.

88 {
89 switch (location) {
90 case BOTTOM_LEFT:
91 return _bbox.getMin();
92 break; // paranoia
93 case BOTTOM_RIGHT:
94 return lsst::geom::Point2I(_bbox.getMaxX() + 1, _bbox.getMinY());
95 break; // paranoia
96 case TOP_LEFT:
97 return lsst::geom::Point2I(_bbox.getMinX(), _bbox.getMaxY() + 1);
98 break; // paranoia
99 case TOP_RIGHT:
100 return lsst::geom::Point2I(_bbox.getMaxX() + 1, _bbox.getMaxY() + 1);
101 break; // paranoia
102 default: {
104 os << "Bug: unhandled location = " << location;
106 }
107 }
108}
std::ostream * os
Definition Schema.cc:557
Point2I const getMin() const noexcept
Definition Box.h:156
int getMaxX() const noexcept
Definition Box.h:161

◆ getXY0()

lsst::geom::Point2I lsst::afw::math::detail::KernelImagesForRegion::getXY0 ( ) const
inline

Get xy0 of the image.

Definition at line 238 of file Convolve.h.

238{ return _xy0; };

The documentation for this class was generated from the following files: