LSSTApplications  1.1.2+25,10.0+13,10.0+132,10.0+133,10.0+224,10.0+41,10.0+8,10.0-1-g0f53050+14,10.0-1-g4b7b172+19,10.0-1-g61a5bae+98,10.0-1-g7408a83+3,10.0-1-gc1e0f5a+19,10.0-1-gdb4482e+14,10.0-11-g3947115+2,10.0-12-g8719d8b+2,10.0-15-ga3f480f+1,10.0-2-g4f67435,10.0-2-gcb4bc6c+26,10.0-28-gf7f57a9+1,10.0-3-g1bbe32c+14,10.0-3-g5b46d21,10.0-4-g027f45f+5,10.0-4-g86f66b5+2,10.0-4-gc4fccf3+24,10.0-40-g4349866+2,10.0-5-g766159b,10.0-5-gca2295e+25,10.0-6-g462a451+1
LSSTDataManagementBasePackage
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | 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.daf.base::Citizen lsst.afw.math::BackgroundMI

Public Types

typedef float InternalPixelT
 type used for any internal images, and returned by getApproximate More...
 
- Public Types inherited from lsst.daf.base::Citizen
enum  { magicSentinel = 0xdeadbeef }
 
typedef unsigned long memId
 Type of the block's ID. More...
 
typedef memId(* memNewCallback )(const memId cid)
 A function used to register a callback. More...
 
typedef memId(* memCallback )(const Citizen *ptr)
 

Public Member Functions

virtual void operator+= (float const delta)=0
 Add a constant level to a background. More...
 
virtual void operator-= (float const delta)=0
 Subtract a constant level from a background. More...
 
template<typename PixelT >
boost::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 >
boost::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 >
boost::shared_ptr
< lsst::afw::image::Image
< PixelT > > 
getImage (lsst::afw::geom::Box2I const &bbox, Interpolate::Style const interpStyle, UndersampleStyle const undersampleStyle=THROW_EXCEPTION) const
 
template<typename PixelT >
boost::shared_ptr
< lsst::afw::image::Image
< PixelT > > 
getImage (lsst::afw::geom::Box2I const &bbox, std::string const &interpStyle, std::string const &undersampleStyle="THROW_EXCEPTION") const
 
template<typename PixelT >
boost::shared_ptr
< lsst::afw::image::Image
< PixelT > > 
getImage () const
 Method to interpolate and return the background for entire image. More...
 
Interpolate::Style getAsUsedInterpStyle () const
 
UndersampleStyle getAsUsedUndersampleStyle () const
 
boost::shared_ptr
< math::Approximate
< InternalPixelT > > 
getApproximate (ApproximateControl const &actrl, UndersampleStyle const undersampleStyle=THROW_EXCEPTION) const
 Method to return an approximation to the background. More...
 
geom::Box2I getImageBBox () const
 
- Public Member Functions inherited from lsst.daf.base::Citizen
 Citizen (const std::type_info &)
 
 Citizen (Citizen const &)
 
 ~Citizen ()
 
Citizenoperator= (Citizen const &)
 
std::string repr () const
 Return a string representation of a Citizen. More...
 
void markPersistent (void)
 Mark a Citizen as persistent and not destroyed until process end. More...
 
memId getId () const
 Return the Citizen's ID. More...
 

Protected Member Functions

template<typename ImageT >
 Background (ImageT const &img, BackgroundControl const &bgCtrl)
 Constructor for Background. More...
 
 Background (geom::Box2I const imageBBox, int const nx, int const ny)
 
virtual ~Background ()
 dtor More...
 

Protected Attributes

geom::Box2I _imgBBox
 size and origin of input image More...
 
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...
 

Private Member Functions

 Background (Background const &)
 
Backgroundoperator= (Background const &)
 
void _setCenOrigSize (int const width, int const height, int const nxSample, int const nySample)
 

Additional Inherited Members

- Static Public Member Functions inherited from lsst.daf.base::Citizen
static bool hasBeenCorrupted ()
 Check all allocated blocks for corruption. More...
 
static memId getNextMemId ()
 Return the memId of the next object to be allocated. More...
 
static int init ()
 Called once when the memory system is being initialised. More...
 
static int census (int, memId startingMemId=0)
 How many active Citizens are there? More...
 
static void census (std::ostream &stream, memId startingMemId=0)
 Print a list of all active Citizens to stream, sorted by ID. More...
 
static const std::vector
< const Citizen * > * 
census ()
 Return a (newly allocated) std::vector of active Citizens sorted by ID. More...
 
static memId setNewCallbackId (memId id)
 Call the NewCallback when block is allocated. More...
 
static memId setDeleteCallbackId (memId id)
 Call the current DeleteCallback when block is deleted. More...
 
static memNewCallback setNewCallback (memNewCallback func)
 Set the NewCallback function. More...
 
static memCallback setDeleteCallback (memCallback func)
 Set the DeleteCallback function. More...
 
static memCallback setCorruptionCallback (memCallback func)
 Set the CorruptionCallback function. More...
 

Detailed Description

A virtual base class to evaluate image background levels.

Definition at line 214 of file Background.h.

Member Typedef Documentation

type used for any internal images, and returned by getApproximate

Definition at line 223 of file Background.h.

Constructor & Destructor Documentation

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 59 of file Background.cc.

61  :
62  lsst::daf::base::Citizen(typeid(this)),
63  _imgBBox(img.getBBox()),
64  _bctrl(bgCtrl),
67  _xcen(0), _ycen(0), _xorig(0), _yorig(0), _xsize(0), _ysize(0)
68 {
69  if (_imgBBox.isEmpty()) {
70  throw LSST_EXCEPT(ex::InvalidParameterError, "Image contains no pixels");
71  }
72 
73  // Check that an int's large enough to hold the number of pixels
74  if (_imgBBox.getWidth()*static_cast<double>(_imgBBox.getHeight()) > std::numeric_limits<int>::max()) {
75  throw LSST_EXCEPT(lsst::pex::exceptions::OverflowError,
76  str(boost::format("Image %dx%d has more pixels than fit in an int (%d)")
78  }
79 
80  _setCenOrigSize(_imgBBox.getWidth(), _imgBBox.getHeight(), bgCtrl.getNxSample(), bgCtrl.getNySample());
81 }
std::vector< int > _ysize
y size ...
Definition: Background.h:320
std::vector< int > _xorig
x origin pix coords of sub images
Definition: Background.h:317
std::vector< double > _ycen
y center ...
Definition: Background.h:316
double max
Definition: attributes.cc:218
int getHeight() const
Definition: Box.h:155
BackgroundControl _bctrl
control info set by user.
Definition: Background.h:311
std::vector< int > _xsize
x size of sub images
Definition: Background.h:319
UndersampleStyle _asUsedUndersampleStyle
the undersampleStyle we actually used
Definition: Background.h:313
geom::Box2I _imgBBox
size and origin of input image
Definition: Background.h:310
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
std::vector< double > _xcen
x center pix coords of sub images
Definition: Background.h:315
bool isEmpty() const
Return true if the box contains no points.
Definition: Box.h:166
void _setCenOrigSize(int const width, int const height, int const nxSample, int const nySample)
Definition: Background.cc:121
Citizen is a class that should be among all LSST classes base classes, and handles basic memory manag...
Definition: Citizen.h:56
std::vector< int > _yorig
y origin ...
Definition: Background.h:318
Interpolate::Style _asUsedInterpStyle
the style we actually used
Definition: Background.h:312
int getWidth() const
Definition: Box.h:154
lsst.afw.math::Background::Background ( geom::Box2I const  imageBBox,
int const  nx,
int const  ny 
)
explicitprotected

Create a Background without any values in it

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

Definition at line 90 of file Background.cc.

93  :
94  lsst::daf::base::Citizen(typeid(this)),
95  _imgBBox(imageBBox),
96  _bctrl(nx, ny),
99  _xcen(0), _ycen(0), _xorig(0), _yorig(0), _xsize(0), _ysize(0)
100 {
101  if (_imgBBox.isEmpty()) {
102  throw LSST_EXCEPT(ex::InvalidParameterError, "Image contains no pixels");
103  }
104 
105  // Check that an int's large enough to hold the number of pixels
106  if (_imgBBox.getWidth()*static_cast<double>(_imgBBox.getHeight()) > std::numeric_limits<int>::max()) {
107  throw LSST_EXCEPT(lsst::pex::exceptions::OverflowError,
108  str(boost::format("Image %dx%d has more pixels than fit in an int (%d)")
110  }
111 
113 }
std::vector< int > _ysize
y size ...
Definition: Background.h:320
std::vector< int > _xorig
x origin pix coords of sub images
Definition: Background.h:317
std::vector< double > _ycen
y center ...
Definition: Background.h:316
double max
Definition: attributes.cc:218
int getHeight() const
Definition: Box.h:155
BackgroundControl _bctrl
control info set by user.
Definition: Background.h:311
std::vector< int > _xsize
x size of sub images
Definition: Background.h:319
UndersampleStyle _asUsedUndersampleStyle
the undersampleStyle we actually used
Definition: Background.h:313
geom::Box2I _imgBBox
size and origin of input image
Definition: Background.h:310
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
std::vector< double > _xcen
x center pix coords of sub images
Definition: Background.h:315
bool isEmpty() const
Return true if the box contains no points.
Definition: Box.h:166
void _setCenOrigSize(int const width, int const height, int const nxSample, int const nySample)
Definition: Background.cc:121
Citizen is a class that should be among all LSST classes base classes, and handles basic memory manag...
Definition: Citizen.h:56
std::vector< int > _yorig
y origin ...
Definition: Background.h:318
Interpolate::Style _asUsedInterpStyle
the style we actually used
Definition: Background.h:312
int getWidth() const
Definition: Box.h:154
virtual lsst.afw.math::Background::~Background ( )
inlineprotectedvirtual

dtor

Definition at line 221 of file Background.h.

221 { }
lsst.afw.math::Background::Background ( Background const &  )
private

Member Function Documentation

void lsst.afw.math::Background::_setCenOrigSize ( int const  width,
int const  height,
int const  nxSample,
int const  nySample 
)
private

Compute the centers, origins, and sizes of the patches used to compute image statistics when estimating the Background

Definition at line 121 of file Background.cc.

123 {
124  _xcen.resize( nxSample); _ycen.resize(nySample);
125  _xorig.resize(nxSample); _yorig.resize(nySample);
126  _xsize.resize(nxSample), _ysize.resize(nySample);
127 
128  // Compute the centers and origins for the cells
129  for (int iX = 0; iX < nxSample; ++iX) {
130  const int endx = std::min(((iX+1)*width + nxSample/2)/nxSample, width);
131  _xorig[iX] = (iX == 0) ? 0 : _xorig[iX-1] + _xsize[iX-1];
132  _xsize[iX] = endx - _xorig[iX];
133  _xcen [iX] = _xorig[iX] + (0.5 * _xsize[iX]) - 0.5;
134  }
135 
136  for (int iY = 0; iY < nySample; ++iY) {
137  const int endy = std::min(((iY+1)*height + nySample/2)/nySample, height);
138  _yorig[iY] = (iY == 0) ? 0 : _yorig[iY-1] + _ysize[iY-1];
139  _ysize[iY] = endy - _yorig[iY];
140  _ycen [iY] = _yorig[iY] + (0.5 * _ysize[iY]) - 0.5;
141  }
142 }
std::vector< int > _ysize
y size ...
Definition: Background.h:320
std::vector< int > _xorig
x origin pix coords of sub images
Definition: Background.h:317
std::vector< double > _ycen
y center ...
Definition: Background.h:316
double min
Definition: attributes.cc:216
std::vector< int > _xsize
x size of sub images
Definition: Background.h:319
std::vector< double > _xcen
x center pix coords of sub images
Definition: Background.h:315
std::vector< int > _yorig
y origin ...
Definition: Background.h:318
boost::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 297 of file Background.h.

300  {
301  InternalPixelT disambiguate = 0;
302  return _getApproximate(actrl, undersampleStyle, disambiguate);
303  }
float InternalPixelT
type used for any internal images, and returned by getApproximate
Definition: Background.h:223
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 285 of file Background.h.

285  {
286  return _asUsedInterpStyle;
287  }
Interpolate::Style _asUsedInterpStyle
the style we actually used
Definition: Background.h:312
UndersampleStyle lsst.afw.math::Background::getAsUsedUndersampleStyle ( ) const
inline

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

Definition at line 291 of file Background.h.

291  {
293  }
UndersampleStyle _asUsedUndersampleStyle
the undersampleStyle we actually used
Definition: Background.h:313
template<typename PixelT >
boost::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.

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

Definition at line 235 of file Background.h.

238  {
239  return getImage<PixelT>(_imgBBox, interpStyle, undersampleStyle);
240  }
geom::Box2I _imgBBox
size and origin of input image
Definition: Background.h:310
template<typename PixelT >
boost::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.

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

Definition at line 247 of file Background.h.

250  {
251  return getImage<PixelT>(math::stringToInterpStyle(interpStyle),
252  stringToUndersampleStyle(undersampleStyle));
253  }
UndersampleStyle stringToUndersampleStyle(std::string const &style)
Conversion function to switch a string to an UndersampleStyle.
Definition: Background.cc:148
Interpolate::Style stringToInterpStyle(std::string const &style)
Conversion function to switch a string to an Interpolate::Style.
Definition: Interpolate.cc:264
template<typename PixelT >
boost::shared_ptr< lsst::afw::image::Image<PixelT> > lsst.afw.math::Background::getImage ( lsst::afw::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 255 of file Background.h.

259  {
260  return _getImage(bbox, interpStyle, undersampleStyle, static_cast<PixelT>(0));
261  }
template<typename PixelT >
boost::shared_ptr< lsst::afw::image::Image<PixelT> > lsst.afw.math::Background::getImage ( lsst::afw::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 263 of file Background.h.

267  {
268  return _getImage(bbox, math::stringToInterpStyle(interpStyle),
269  stringToUndersampleStyle(undersampleStyle), static_cast<PixelT>(0));
270  }
UndersampleStyle stringToUndersampleStyle(std::string const &style)
Conversion function to switch a string to an UndersampleStyle.
Definition: Background.cc:148
Interpolate::Style stringToInterpStyle(std::string const &style)
Conversion function to switch a string to an Interpolate::Style.
Definition: Interpolate.cc:264
template<typename PixelT >
boost::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 277 of file Background.h.

277  {
278  return getImage<PixelT>(_bctrl.getInterpStyle(), _bctrl.getUndersampleStyle());
279  }
Interpolate::Style getInterpStyle() const
Definition: Background.h:185
UndersampleStyle getUndersampleStyle() const
Definition: Background.h:193
BackgroundControl _bctrl
control info set by user.
Definition: Background.h:311
geom::Box2I lsst.afw.math::Background::getImageBBox ( ) const
inline

Return the input image's (PARENT) bounding box

Definition at line 307 of file Background.h.

307 { return _imgBBox; }
geom::Box2I _imgBBox
size and origin of input image
Definition: Background.h:310
virtual void lsst.afw.math::Background::operator+= ( float const  delta)
pure virtual

Add a constant level to a background.

Implemented in lsst.afw.math::BackgroundMI.

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

Subtract a constant level from a background.

Implemented in lsst.afw.math::BackgroundMI.

Background& lsst.afw.math::Background::operator= ( Background const &  )
private

Member Data Documentation

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

the style we actually used

Definition at line 312 of file Background.h.

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

the undersampleStyle we actually used

Definition at line 313 of file Background.h.

BackgroundControl lsst.afw.math::Background::_bctrl
protected

control info set by user.

Definition at line 311 of file Background.h.

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

size and origin of input image

Definition at line 310 of file Background.h.

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

x center pix coords of sub images

Definition at line 315 of file Background.h.

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

x origin pix coords of sub images

Definition at line 317 of file Background.h.

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

x size of sub images

Definition at line 319 of file Background.h.

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

y center ...

Definition at line 316 of file Background.h.

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

y origin ...

Definition at line 318 of file Background.h.

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

y size ...

Definition at line 320 of file Background.h.


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