LSSTApplications  18.0.0+106,18.0.0+50,19.0.0,19.0.0+1,19.0.0+10,19.0.0+11,19.0.0+13,19.0.0+17,19.0.0+2,19.0.0-1-g20d9b18+6,19.0.0-1-g425ff20,19.0.0-1-g5549ca4,19.0.0-1-g580fafe+6,19.0.0-1-g6fe20d0+1,19.0.0-1-g7011481+9,19.0.0-1-g8c57eb9+6,19.0.0-1-gb5175dc+11,19.0.0-1-gdc0e4a7+9,19.0.0-1-ge272bc4+6,19.0.0-1-ge3aa853,19.0.0-10-g448f008b,19.0.0-12-g6990b2c,19.0.0-2-g0d9f9cd+11,19.0.0-2-g3d9e4fb2+11,19.0.0-2-g5037de4,19.0.0-2-gb96a1c4+3,19.0.0-2-gd955cfd+15,19.0.0-3-g2d13df8,19.0.0-3-g6f3c7dc,19.0.0-4-g725f80e+11,19.0.0-4-ga671dab3b+1,19.0.0-4-gad373c5+3,19.0.0-5-ga2acb9c+2,19.0.0-5-gfe96e6c+2,w.2020.01
LSSTDataManagementBasePackage
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
lsst::afw::math::Background Class Referenceabstract

A virtual base class to evaluate image background levels. More...

#include <Background.h>

Inheritance diagram for lsst::afw::math::Background:
lsst::afw::math::BackgroundMI

Public Types

typedef float InternalPixelT
 type used for any internal images, and returned by getApproximate More...
 

Public Member Functions

 Background (Background const &)=delete
 
 Background (Background &&)=delete
 
Backgroundoperator= (Background const &)=delete
 
Backgroundoperator= (Background &&)=delete
 
virtual Backgroundoperator+= (float const delta)=0
 Add a constant level to a background. More...
 
virtual Backgroundoperator-= (float const delta)=0
 Subtract a constant level from a background. More...
 
template<typename PixelT >
std::shared_ptr< lsst::afw::image::Image< PixelT > > getImage (Interpolate::Style const interpStyle, UndersampleStyle const undersampleStyle=THROW_EXCEPTION) const
 Method to interpolate and return the background for entire image. More...
 
template<typename PixelT >
std::shared_ptr< lsst::afw::image::Image< PixelT > > getImage (std::string const &interpStyle, std::string const &undersampleStyle="THROW_EXCEPTION") const
 Method to interpolate and return the background for entire image. More...
 
template<typename PixelT >
std::shared_ptr< lsst::afw::image::Image< PixelT > > getImage (lsst::geom::Box2I const &bbox, Interpolate::Style const interpStyle, UndersampleStyle const undersampleStyle=THROW_EXCEPTION) const
 
template<typename PixelT >
std::shared_ptr< lsst::afw::image::Image< PixelT > > getImage (lsst::geom::Box2I const &bbox, std::string const &interpStyle, std::string const &undersampleStyle="THROW_EXCEPTION") const
 
template<typename PixelT >
std::shared_ptr< lsst::afw::image::Image< PixelT > > getImage () const
 Method to interpolate and return the background for entire image. More...
 
Interpolate::Style getAsUsedInterpStyle () const
 Return the Interpolate::Style that we actually used in the last call to getImage() More...
 
UndersampleStyle getAsUsedUndersampleStyle () const
 Return the UndersampleStyle that we actually used in the last call to getImage() More...
 
std::shared_ptr< math::Approximate< InternalPixelT > > getApproximate (ApproximateControl const &actrl, UndersampleStyle const undersampleStyle=THROW_EXCEPTION) const
 Method to return an approximation to the background. More...
 
lsst::geom::Box2I getImageBBox () const
 Return the input image's (PARENT) bounding box. More...
 
std::shared_ptr< BackgroundControlgetBackgroundControl ()
 
std::shared_ptr< BackgroundControl const > getBackgroundControl () const
 

Protected Member Functions

template<typename ImageT >
 Background (ImageT const &img, BackgroundControl const &bgCtrl)
 Constructor for Background. More...
 
 Background (lsst::geom::Box2I const imageBBox, int const nx, int const ny)
 Create a Background without any values in it. More...
 
virtual ~Background ()=default
 dtor More...
 

Protected Attributes

lsst::geom::Box2I _imgBBox
 size and origin of input image More...
 
std::shared_ptr< BackgroundControl_bctrl
 control info set by user. More...
 
Interpolate::Style _asUsedInterpStyle
 the style we actually used More...
 
UndersampleStyle _asUsedUndersampleStyle
 the undersampleStyle we actually used More...
 
std::vector< double > _xcen
 x center pix coords of sub images More...
 
std::vector< double > _ycen
 y center ... More...
 
std::vector< int > _xorig
 x origin pix coords of sub images More...
 
std::vector< int > _yorig
 y origin ... More...
 
std::vector< int > _xsize
 x size of sub images More...
 
std::vector< int > _ysize
 y size ... More...
 

Detailed Description

A virtual base class to evaluate image background levels.

Definition at line 260 of file Background.h.

Member Typedef Documentation

◆ InternalPixelT

type used for any internal images, and returned by getApproximate

Definition at line 293 of file Background.h.

Constructor & Destructor Documentation

◆ Background() [1/4]

template<typename ImageT >
lsst::afw::math::Background::Background ( ImageT const &  img,
BackgroundControl const &  bgCtrl 
)
explicitprotected

Constructor for Background.

Estimate the statistical properties of the Image in a grid of cells; we'll later call getImage() to interpolate those values, creating an image the same size as the original

Note
The old and deprecated API specified the interpolation style as part of the BackgroundControl object passed to this ctor. This is still supported, but the work isn't done until the getImage() method is called
Parameters
imgImageT (or MaskedImage) whose properties we want
bgCtrlControl how the Background is estimated

Definition at line 44 of file Background.cc.

45  : _imgBBox(img.getBBox()),
46  _bctrl(new BackgroundControl(bgCtrl)),
49  _xcen(0),
50  _ycen(0),
51  _xorig(0),
52  _yorig(0),
53  _xsize(0),
54  _ysize(0) {
55  if (_imgBBox.isEmpty()) {
56  throw LSST_EXCEPT(ex::InvalidParameterError, "Image contains no pixels");
57  }
58 
59  // Check that an int's large enough to hold the number of pixels
60  if (_imgBBox.getWidth() * static_cast<double>(_imgBBox.getHeight()) > std::numeric_limits<int>::max()) {
62  str(boost::format("Image %dx%d has more pixels than fit in an int (%d)") %
64  }
65 
66  _setCenOrigSize(_imgBBox.getWidth(), _imgBBox.getHeight(), bgCtrl.getNxSample(), bgCtrl.getNySample());
67 }
std::vector< int > _xsize
x size of sub images
Definition: Background.h:405
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:174
std::vector< double > _xcen
x center pix coords of sub images
Definition: Background.h:401
std::vector< int > _yorig
y origin ...
Definition: Background.h:404
int getHeight() const noexcept
Definition: Box.h:188
lsst::geom::Box2I _imgBBox
size and origin of input image
Definition: Background.h:396
bool isEmpty() const noexcept
Return true if the box contains no points.
Definition: Box.h:213
std::vector< double > _ycen
y center ...
Definition: Background.h:402
Interpolate::Style _asUsedInterpStyle
the style we actually used
Definition: Background.h:398
Reports when the result of an arithmetic operation is too large for the destination type...
Definition: Runtime.h:124
int getWidth() const noexcept
Definition: Box.h:187
T max(T... args)
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
std::vector< int > _xorig
x origin pix coords of sub images
Definition: Background.h:403
std::shared_ptr< BackgroundControl > _bctrl
control info set by user.
Definition: Background.h:397
std::vector< int > _ysize
y size ...
Definition: Background.h:406
UndersampleStyle _asUsedUndersampleStyle
the undersampleStyle we actually used
Definition: Background.h:399
Reports invalid arguments.
Definition: Runtime.h:66

◆ Background() [2/4]

lsst::afw::math::Background::Background ( lsst::geom::Box2I const  imageBBox,
int const  nx,
int const  ny 
)
explicitprotected

Create a Background without any values in it.

Parameters
imageBBoxBounding box for image to be created by getImage()
nxNumber of samples in x-direction
nyNumber of samples in y-direction
Note
This ctor is mostly used to create a Background given its sample values, and that (in turn) is mostly used to implement persistence.

Definition at line 69 of file Background.cc.

70  : _imgBBox(imageBBox),
71  _bctrl(new BackgroundControl(nx, ny)),
74  _xcen(0),
75  _ycen(0),
76  _xorig(0),
77  _yorig(0),
78  _xsize(0),
79  _ysize(0) {
80  if (_imgBBox.isEmpty()) {
81  throw LSST_EXCEPT(ex::InvalidParameterError, "Image contains no pixels");
82  }
83 
84  // Check that an int's large enough to hold the number of pixels
85  if (_imgBBox.getWidth() * static_cast<double>(_imgBBox.getHeight()) > std::numeric_limits<int>::max()) {
87  str(boost::format("Image %dx%d has more pixels than fit in an int (%d)") %
89  }
90 
91  _setCenOrigSize(_imgBBox.getWidth(), _imgBBox.getHeight(), nx, ny);
92 }
std::vector< int > _xsize
x size of sub images
Definition: Background.h:405
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:174
std::vector< double > _xcen
x center pix coords of sub images
Definition: Background.h:401
std::vector< int > _yorig
y origin ...
Definition: Background.h:404
int getHeight() const noexcept
Definition: Box.h:188
lsst::geom::Box2I _imgBBox
size and origin of input image
Definition: Background.h:396
bool isEmpty() const noexcept
Return true if the box contains no points.
Definition: Box.h:213
std::vector< double > _ycen
y center ...
Definition: Background.h:402
Interpolate::Style _asUsedInterpStyle
the style we actually used
Definition: Background.h:398
Reports when the result of an arithmetic operation is too large for the destination type...
Definition: Runtime.h:124
int getWidth() const noexcept
Definition: Box.h:187
T max(T... args)
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
std::vector< int > _xorig
x origin pix coords of sub images
Definition: Background.h:403
std::shared_ptr< BackgroundControl > _bctrl
control info set by user.
Definition: Background.h:397
std::vector< int > _ysize
y size ...
Definition: Background.h:406
UndersampleStyle _asUsedUndersampleStyle
the undersampleStyle we actually used
Definition: Background.h:399
Reports invalid arguments.
Definition: Runtime.h:66

◆ ~Background()

virtual lsst::afw::math::Background::~Background ( )
protectedvirtualdefault

dtor

◆ Background() [3/4]

lsst::afw::math::Background::Background ( Background const &  )
delete

◆ Background() [4/4]

lsst::afw::math::Background::Background ( Background &&  )
delete

Member Function Documentation

◆ getApproximate()

std::shared_ptr<math::Approximate<InternalPixelT> > lsst::afw::math::Background::getApproximate ( ApproximateControl const &  actrl,
UndersampleStyle const  undersampleStyle = THROW_EXCEPTION 
) const
inline

Method to return an approximation to the background.

Parameters
actrlApproximation style
undersampleStyleBehaviour if there are too few points

Definition at line 381 of file Background.h.

383  {
384  InternalPixelT disambiguate = 0;
385  return _getApproximate(actrl, undersampleStyle, disambiguate);
386  }
float InternalPixelT
type used for any internal images, and returned by getApproximate
Definition: Background.h:293

◆ getAsUsedInterpStyle()

Interpolate::Style lsst::afw::math::Background::getAsUsedInterpStyle ( ) const
inline

Return the Interpolate::Style that we actually used in the last call to getImage()

N.b. Interpolate can fallback to a lower order if there aren't enough samples

Definition at line 370 of file Background.h.

370 { return _asUsedInterpStyle; }
Interpolate::Style _asUsedInterpStyle
the style we actually used
Definition: Background.h:398

◆ getAsUsedUndersampleStyle()

UndersampleStyle lsst::afw::math::Background::getAsUsedUndersampleStyle ( ) const
inline

Return the UndersampleStyle that we actually used in the last call to getImage()

Definition at line 374 of file Background.h.

374 { return _asUsedUndersampleStyle; }
UndersampleStyle _asUsedUndersampleStyle
the undersampleStyle we actually used
Definition: Background.h:399

◆ getBackgroundControl() [1/2]

std::shared_ptr<BackgroundControl> lsst::afw::math::Background::getBackgroundControl ( )
inline

Definition at line 392 of file Background.h.

392 { return _bctrl; }
std::shared_ptr< BackgroundControl > _bctrl
control info set by user.
Definition: Background.h:397

◆ getBackgroundControl() [2/2]

std::shared_ptr<BackgroundControl const> lsst::afw::math::Background::getBackgroundControl ( ) const
inline

Definition at line 393 of file Background.h.

393 { return _bctrl; }
std::shared_ptr< BackgroundControl > _bctrl
control info set by user.
Definition: Background.h:397

◆ getImage() [1/5]

template<typename PixelT >
std::shared_ptr<lsst::afw::image::Image<PixelT> > lsst::afw::math::Background::getImage ( Interpolate::Style const  interpStyle,
UndersampleStyle const  undersampleStyle = THROW_EXCEPTION 
) const
inline

Method to interpolate and return the background for entire image.

Parameters
interpStyleStyle of the interpolation
undersampleStyleBehaviour if there are too few points
Returns
A boost shared-pointer to an image containing the estimated background

Definition at line 312 of file Background.h.

314  {
315  return getImage<PixelT>(_imgBBox, interpStyle, undersampleStyle);
316  }
lsst::geom::Box2I _imgBBox
size and origin of input image
Definition: Background.h:396

◆ getImage() [2/5]

template<typename PixelT >
std::shared_ptr<lsst::afw::image::Image<PixelT> > lsst::afw::math::Background::getImage ( std::string const &  interpStyle,
std::string const &  undersampleStyle = "THROW_EXCEPTION" 
) const
inline

Method to interpolate and return the background for entire image.

Parameters
interpStyleStyle of the interpolation
undersampleStyleBehaviour if there are too few points
Returns
A boost shared-pointer to an image containing the estimated background

Definition at line 325 of file Background.h.

326  {
327  return getImage<PixelT>(math::stringToInterpStyle(interpStyle),
328  stringToUndersampleStyle(undersampleStyle));
329  }
UndersampleStyle stringToUndersampleStyle(std::string const &style)
Conversion function to switch a string to an UndersampleStyle.
Definition: Background.cc:117
Interpolate::Style stringToInterpStyle(std::string const &style)
Conversion function to switch a string to an Interpolate::Style.
Definition: Interpolate.cc:257

◆ getImage() [3/5]

template<typename PixelT >
std::shared_ptr<lsst::afw::image::Image<PixelT> > lsst::afw::math::Background::getImage ( lsst::geom::Box2I const &  bbox,
Interpolate::Style const  interpStyle,
UndersampleStyle const  undersampleStyle = THROW_EXCEPTION 
) const
inline
Parameters
bboxBounding box for sub-image
interpStyleStyle of the interpolation
undersampleStyleBehaviour if there are too few points

Definition at line 336 of file Background.h.

338  {
339  return _getImage(bbox, interpStyle, undersampleStyle, static_cast<PixelT>(0));
340  }
AmpInfoBoxKey bbox
Definition: Amplifier.cc:117

◆ getImage() [4/5]

template<typename PixelT >
std::shared_ptr<lsst::afw::image::Image<PixelT> > lsst::afw::math::Background::getImage ( lsst::geom::Box2I const &  bbox,
std::string const &  interpStyle,
std::string const &  undersampleStyle = "THROW_EXCEPTION" 
) const
inline
Parameters
bboxBounding box for sub-image
interpStyleStyle of the interpolation
undersampleStyleBehaviour if there are too few points

Definition at line 347 of file Background.h.

349  {
350  return _getImage(bbox, math::stringToInterpStyle(interpStyle),
351  stringToUndersampleStyle(undersampleStyle), static_cast<PixelT>(0));
352  }
AmpInfoBoxKey bbox
Definition: Amplifier.cc:117
UndersampleStyle stringToUndersampleStyle(std::string const &style)
Conversion function to switch a string to an UndersampleStyle.
Definition: Background.cc:117
Interpolate::Style stringToInterpStyle(std::string const &style)
Conversion function to switch a string to an Interpolate::Style.
Definition: Interpolate.cc:257

◆ getImage() [5/5]

template<typename PixelT >
std::shared_ptr<lsst::afw::image::Image<PixelT> > lsst::afw::math::Background::getImage ( ) const
inline

Method to interpolate and return the background for entire image.

Deprecated:
New code should specify the interpolation style in getImage, not the ctor

Definition at line 362 of file Background.h.

362  {
363  return getImage<PixelT>(_bctrl->getInterpStyle(), _bctrl->getUndersampleStyle());
364  }
std::shared_ptr< BackgroundControl > _bctrl
control info set by user.
Definition: Background.h:397

◆ getImageBBox()

lsst::geom::Box2I lsst::afw::math::Background::getImageBBox ( ) const
inline

Return the input image's (PARENT) bounding box.

Definition at line 390 of file Background.h.

390 { return _imgBBox; }
lsst::geom::Box2I _imgBBox
size and origin of input image
Definition: Background.h:396

◆ operator+=()

virtual Background& lsst::afw::math::Background::operator+= ( float const  delta)
pure virtual

Add a constant level to a background.

Implemented in lsst::afw::math::BackgroundMI.

◆ operator-=()

virtual Background& lsst::afw::math::Background::operator-= ( float const  delta)
pure virtual

Subtract a constant level from a background.

Implemented in lsst::afw::math::BackgroundMI.

◆ operator=() [1/2]

Background& lsst::afw::math::Background::operator= ( Background const &  )
delete

◆ operator=() [2/2]

Background& lsst::afw::math::Background::operator= ( Background &&  )
delete

Member Data Documentation

◆ _asUsedInterpStyle

Interpolate::Style lsst::afw::math::Background::_asUsedInterpStyle
mutableprotected

the style we actually used

Definition at line 398 of file Background.h.

◆ _asUsedUndersampleStyle

UndersampleStyle lsst::afw::math::Background::_asUsedUndersampleStyle
mutableprotected

the undersampleStyle we actually used

Definition at line 399 of file Background.h.

◆ _bctrl

std::shared_ptr<BackgroundControl> lsst::afw::math::Background::_bctrl
protected

control info set by user.

Definition at line 397 of file Background.h.

◆ _imgBBox

lsst::geom::Box2I lsst::afw::math::Background::_imgBBox
protected

size and origin of input image

Definition at line 396 of file Background.h.

◆ _xcen

std::vector<double> lsst::afw::math::Background::_xcen
protected

x center pix coords of sub images

Definition at line 401 of file Background.h.

◆ _xorig

std::vector<int> lsst::afw::math::Background::_xorig
protected

x origin pix coords of sub images

Definition at line 403 of file Background.h.

◆ _xsize

std::vector<int> lsst::afw::math::Background::_xsize
protected

x size of sub images

Definition at line 405 of file Background.h.

◆ _ycen

std::vector<double> lsst::afw::math::Background::_ycen
protected

y center ...

Definition at line 402 of file Background.h.

◆ _yorig

std::vector<int> lsst::afw::math::Background::_yorig
protected

y origin ...

Definition at line 404 of file Background.h.

◆ _ysize

std::vector<int> lsst::afw::math::Background::_ysize
protected

y size ...

Definition at line 406 of file Background.h.


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