LSST Applications  21.0.0+04719a4bac,21.0.0-1-ga51b5d4+f5e6047307,21.0.0-11-g2b59f77+a9c1acf22d,21.0.0-11-ga42c5b2+86977b0b17,21.0.0-12-gf4ce030+76814010d2,21.0.0-13-g1721dae+760e7a6536,21.0.0-13-g3a573fe+768d78a30a,21.0.0-15-g5a7caf0+f21cbc5713,21.0.0-16-g0fb55c1+b60e2d390c,21.0.0-19-g4cded4ca+71a93a33c0,21.0.0-2-g103fe59+bb20972958,21.0.0-2-g45278ab+04719a4bac,21.0.0-2-g5242d73+3ad5d60fb1,21.0.0-2-g7f82c8f+8babb168e8,21.0.0-2-g8f08a60+06509c8b61,21.0.0-2-g8faa9b5+616205b9df,21.0.0-2-ga326454+8babb168e8,21.0.0-2-gde069b7+5e4aea9c2f,21.0.0-2-gecfae73+1d3a86e577,21.0.0-2-gfc62afb+3ad5d60fb1,21.0.0-25-g1d57be3cd+e73869a214,21.0.0-3-g357aad2+ed88757d29,21.0.0-3-g4a4ce7f+3ad5d60fb1,21.0.0-3-g4be5c26+3ad5d60fb1,21.0.0-3-g65f322c+e0b24896a3,21.0.0-3-g7d9da8d+616205b9df,21.0.0-3-ge02ed75+a9c1acf22d,21.0.0-4-g591bb35+a9c1acf22d,21.0.0-4-g65b4814+b60e2d390c,21.0.0-4-gccdca77+0de219a2bc,21.0.0-4-ge8a399c+6c55c39e83,21.0.0-5-gd00fb1e+05fce91b99,21.0.0-6-gc675373+3ad5d60fb1,21.0.0-64-g1122c245+4fb2b8f86e,21.0.0-7-g04766d7+cd19d05db2,21.0.0-7-gdf92d54+04719a4bac,21.0.0-8-g5674e7b+d1bd76f71f,master-gac4afde19b+a9c1acf22d,w.2021.13
LSST Data Management Base Package
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...
 
typedef std::shared_ptr< lsst::afw::math::Kernel const > KernelConstPtr
 
typedef lsst::afw::image::Image< lsst::afw::math::Kernel::PixelImage
 
typedef std::shared_ptr< ImageImagePtr
 
typedef std::shared_ptr< Image const > ImageConstPtr
 

Public Member Functions

 KernelImagesForRegion (KernelConstPtr kernelPtr, lsst::geom::Box2I const &bbox, lsst::geom::Point2I const &xy0, bool doNormalize)
 Construct a KernelImagesForRegion. More...
 
 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. More...
 
lsst::geom::Box2I getBBox () const
 Get the bounding box for the region. More...
 
lsst::geom::Point2I getXY0 () const
 Get xy0 of the image. More...
 
bool getDoNormalize () const
 Get the doNormalize parameter. More...
 
ImagePtr getImage (Location location) const
 Return the image and sum at the specified location. More...
 
KernelConstPtr getKernel () const
 Get the kernel (as a shared pointer to const) More...
 
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) More...
 
bool computeNextRow (RowOfKernelImagesForRegion &regionRow) const
 Compute next row of subregions. More...
 

Static Public Member Functions

static int getMinInterpolationSize ()
 Get the minInterpolationSize class constant. More...
 

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 49 of file KernelImagesForRegion.cc.

51  : _kernelPtr(kernelPtr), _bbox(bbox), _xy0(xy0), _doNormalize(doNormalize), _imagePtrList(4) {
52  if (!_kernelPtr) {
53  throw LSST_EXCEPT(pexExcept::InvalidParameterError, "kernelPtr is null");
54  }
55  LOGL_DEBUG("TRACE5.afw.math.convolve.KernelImagesForRegion",
56  "KernelImagesForRegion(bbox(minimum=(%d, %d), extent=(%d, %d)), xy0=(%d, %d), doNormalize=%d, "
57  "images...)",
58  _bbox.getMinX(), _bbox.getMinY(), _bbox.getWidth(), _bbox.getHeight(), _xy0[0], _xy0[1],
59  _doNormalize);
60 }
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:504
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 62 of file KernelImagesForRegion.cc.

66  : _kernelPtr(kernelPtr), _bbox(bbox), _xy0(xy0), _doNormalize(doNormalize), _imagePtrList(4) {
67  if (!_kernelPtr) {
68  throw LSST_EXCEPT(pexExcept::InvalidParameterError, "kernelPtr is null");
69  }
70  _insertImage(BOTTOM_LEFT, bottomLeftImagePtr);
71  _insertImage(BOTTOM_RIGHT, bottomRightImagePtr);
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, "
76  "images...)",
77  _bbox.getMinX(), _bbox.getMinY(), _bbox.getWidth(), _bbox.getHeight(), _xy0[0], _xy0[1],
78  _doNormalize);
79 }

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 114 of file KernelImagesForRegion.cc.

114  {
115  if (regionRow.isLastRow()) {
116  return false;
117  }
118 
119  bool hasData = regionRow.hasData();
120  int startY;
121  if (hasData) {
122  startY = regionRow.front()->getBBox().getMaxY() + 1;
123  } else {
124  startY = this->_bbox.getMinY();
125  }
126 
127  int yInd = regionRow.incrYInd();
128  int remHeight = 1 + this->_bbox.getMaxY() - startY;
129  int remYDiv = regionRow.getNY() - yInd;
130  int height = _computeNextSubregionLength(remHeight, remYDiv);
131 
132  if (hasData) {
133  // Move each region up one segment
134  bool isFirst = true;
135  for (RowOfKernelImagesForRegion::Iterator rgnIter = regionRow.begin(), rgnEnd = regionRow.end();
136  rgnIter != rgnEnd; ++rgnIter) {
137  (*rgnIter)->_moveUp(isFirst, height);
138  isFirst = false;
139  }
140 
141  } else {
142  ImagePtr blImagePtr = getImage(BOTTOM_LEFT);
143  ImagePtr brImagePtr;
144  ImagePtr tlImagePtr;
145  ImagePtr const trImageNullPtr;
146 
147  lsst::geom::Point2I blCorner = lsst::geom::Point2I(this->_bbox.getMinX(), startY);
148 
149  int remWidth = this->_bbox.getWidth();
150  int remXDiv = regionRow.getNX();
151  for (RowOfKernelImagesForRegion::Iterator rgnIter = regionRow.begin(), rgnEnd = regionRow.end();
152  rgnIter != rgnEnd; ++rgnIter) {
153  int width = _computeNextSubregionLength(remWidth, remXDiv);
154  --remXDiv;
155  remWidth -= width;
156 
158  _kernelPtr, lsst::geom::Box2I(blCorner, lsst::geom::Extent2I(width, height)), _xy0,
159  _doNormalize, blImagePtr, brImagePtr, tlImagePtr, trImageNullPtr));
160  *rgnIter = regionPtr;
161 
162  if (!tlImagePtr) {
163  regionPtr->getImage(TOP_LEFT);
164  }
165 
166  blCorner += lsst::geom::Extent2I(width, 0);
167  blImagePtr = regionPtr->getImage(BOTTOM_RIGHT);
168  tlImagePtr = regionPtr->getImage(TOP_RIGHT);
169  }
170  }
171  return true;
172 }
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 81 of file KernelImagesForRegion.cc.

81  {
82  if (_imagePtrList[location]) {
83  return _imagePtrList[location];
84  }
85 
86  ImagePtr imagePtr(new Image(_kernelPtr->getDimensions()));
87  _imagePtrList[location] = imagePtr;
88  _computeImage(location);
89  return imagePtr;
90 }
lsst::geom::Extent2I const getDimensions() const
Return the Kernel's dimensions (width, height)
Definition: Kernel.h:213
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 92 of file KernelImagesForRegion.cc.

92  {
93  switch (location) {
94  case BOTTOM_LEFT:
95  return _bbox.getMin();
96  break; // paranoia
97  case BOTTOM_RIGHT:
98  return lsst::geom::Point2I(_bbox.getMaxX() + 1, _bbox.getMinY());
99  break; // paranoia
100  case TOP_LEFT:
101  return lsst::geom::Point2I(_bbox.getMinX(), _bbox.getMaxY() + 1);
102  break; // paranoia
103  case TOP_RIGHT:
104  return lsst::geom::Point2I(_bbox.getMaxX() + 1, _bbox.getMaxY() + 1);
105  break; // paranoia
106  default: {
108  os << "Bug: unhandled location = " << location;
110  }
111  }
112 }
std::ostream * os
Definition: Schema.cc:746
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: