25 #if !defined(LSST_AFW_MATH_BACKGROUND_H)
26 #define LSST_AFW_MATH_BACKGROUND_H
32 #include <boost/preprocessor/seq.hpp>
33 #include "boost/shared_ptr.hpp"
43 class ApproximateControl;
44 template<
typename T>
class Approximate;
75 if (nxSample <= 0 || nySample <= 0) {
76 throw LSST_EXCEPT(lsst::pex::exceptions::LengthError,
77 str(
boost::format(
"You must specify at least one point, not %dx%d")
78 % nxSample % nySample)
90 std::string
const &prop
97 if (nxSample <= 0 || nySample <= 0) {
98 throw LSST_EXCEPT(lsst::pex::exceptions::LengthError,
99 str(
boost::format(
"You must specify at least one point, not %dx%d")
100 % nxSample % nySample)
110 int const nxSample = 10,
111 int const nySample = 10,
121 if (nxSample <= 0 || nySample <= 0) {
122 throw LSST_EXCEPT(lsst::pex::exceptions::LengthError,
123 str(
boost::format(
"You must specify at least one point, not %dx%d")
124 % nxSample % nySample)
135 std::string
const &style,
136 int const nxSample = 10,
137 int const nySample = 10,
138 std::string
const &undersampleStyle =
"THROW_EXCEPTION",
140 std::string
const &prop =
"MEANCLIP"
147 if (nxSample <= 0 || nySample <= 0) {
148 throw LSST_EXCEPT(lsst::pex::exceptions::LengthError,
149 str(
boost::format(
"You must specify at least one point, not %dx%d")
150 % nxSample % nySample)
158 throw LSST_EXCEPT(lsst::pex::exceptions::LengthError,
159 str(
boost::format(
"nxSample must be position, not %d") % nxSample));
165 throw LSST_EXCEPT(lsst::pex::exceptions::LengthError,
166 str(
boost::format(
"nySample must be position, not %d") % nySample));
187 throw LSST_EXCEPT(lsst::pex::exceptions::InvalidParameterError,
216 template<
typename ImageT>
226 virtual void operator+=(
float const delta) = 0;
228 virtual void operator-=(
float const delta) = 0;
234 template<
typename PixelT>
239 return getImage<PixelT>(_imgBBox, interpStyle, undersampleStyle);
246 template<
typename PixelT>
248 std::
string const &interpStyle,
254 template<
typename PixelT>
256 lsst::afw::geom::Box2I const& bbox,
260 return _getImage(bbox, interpStyle, undersampleStyle, static_cast<PixelT>(0));
262 template<
typename PixelT>
264 lsst::afw::geom::Box2I const& bbox,
265 std::
string const& interpStyle,
276 template<
typename PixelT>
278 return getImage<PixelT>(_bctrl.getInterpStyle(), _bctrl.getUndersampleStyle());
286 return _asUsedInterpStyle;
292 return _asUsedUndersampleStyle;
301 InternalPixelT disambiguate = 0;
302 return _getApproximate(actrl, undersampleStyle, disambiguate);
332 #define LSST_makeBackground_getImage_types (double)(float)(int)
333 #define LSST_makeBackground_getApproximate_types (Background::InternalPixelT)
334 #define LSST_makeBackground_getImage(m, v, T) \
335 virtual PTR(lsst::afw::image::Image<T>) _getImage( \
336 lsst::afw::geom::Box2I const& bbox, \
337 Interpolate::Style const interpStyle, \
338 UndersampleStyle const undersampleStyle=THROW_EXCEPTION, \
342 #define LSST_makeBackground_getApproximate(m, v, T) \
343 virtual PTR(Approximate<T>) _getApproximate( \
344 ApproximateControl const& actrl, \
345 UndersampleStyle const undersampleStyle=THROW_EXCEPTION, \
353 Background(Background
const&);
354 Background& operator=(Background
const&);
355 void _setCenOrigSize(
int const width,
int const height,
int const nxSample,
int const nySample);
384 template<
typename ImageT>
418 int const iX, std::vector<int>
const& ypix)
const;
420 #if !defined(SWIG) && defined(LSST_makeBackground_getImage)
423 #if 0 // keep for use in Background instantiations
424 #undef LSST_makeBackground_getImage_types
425 #undef LSST_makeBackground_getApproximate_types
427 #undef LSST_makeBackground_getImage
428 #undef LSST_makeBackground_getApproximate
431 template<
typename PixelT>
445 template<typename ImageT>
452 #endif // LSST_AFW_MATH_BACKGROUND_H
lsst::afw::image::MaskedImage< InternalPixelT > _statsImage
float InternalPixelT
type used for any internal images, and returned by getApproximate
std::vector< int > _xsize
x size of sub images
UndersampleStyle stringToUndersampleStyle(std::string const &style)
Conversion function to switch a string to an UndersampleStyle.
boost::shared_ptr< Background > makeBackground(ImageT const &img, BackgroundControl const &bgCtrl)
A convenience function that uses function overloading to make the correct type of Background...
BackgroundControl(Interpolate::Style const style, int const nxSample=10, int const nySample=10, UndersampleStyle const undersampleStyle=THROW_EXCEPTION, StatisticsControl const sctrl=StatisticsControl(), Property const prop=MEANCLIP)
std::vector< double > _xcen
x center pix coords of sub images
Interpolate::Style stringToInterpStyle(std::string const &style)
Conversion function to switch a string to an Interpolate::Style.
Interpolate values for a set of x,y vector<>s.
std::vector< int > _yorig
y origin ...
void setNySample(int nySample)
geom::Box2I getImageBBox() const
std::vector< std::vector< double > > _gridColumns
geom::Box2I _imgBBox
size and origin of input image
void setInterpStyle(Interpolate::Style const style)
#define LSST_makeBackground_getApproximate_types
std::vector< double > _ycen
y center ...
BackgroundControl(int const nxSample, int const nySample, StatisticsControl const sctrl=StatisticsControl(), Property const prop=MEANCLIP)
void setStatisticsProperty(std::string prop)
Pass parameters to a Background object.
Interpolate::Style getAsUsedInterpStyle() const
Approximate values for a MaskedImage.
A virtual base class to evaluate image background levels.
An integer coordinate rectangle.
Property getStatisticsProperty() const
Control how to make an approximation.
void setUndersampleStyle(std::string const &undersampleStyle)
Pass parameters to a Statistics objectA class to pass parameters which control how the stats are calc...
Include files required for standard LSST Exception handling.
estimate sample N-sigma clipped mean (N set in StatisticsControl, default=3)
Interpolate::Style _asUsedInterpStyle
the style we actually used
virtual ~BackgroundControl()
virtual ~Background()
dtor
Interpolate::Style getInterpStyle() const
UndersampleStyle getUndersampleStyle() const
void setUndersampleStyle(UndersampleStyle const undersampleStyle)
boost::shared_ptr< StatisticsControl > _sctrl
boost::shared_ptr< StatisticsControl > getStatisticsControl()
lsst::afw::image::MaskedImage< InternalPixelT > getStatsImage() const
Return the image of statistical quantities extracted from the image.
#define LSST_makeBackground_getImage_types
#define LSST_makeBackground_getImage(m, v, T)
#define LSST_EXCEPT(type,...)
std::vector< int > _xorig
x origin pix coords of sub images
Interpolate::Style _style
BackgroundControl(int const nxSample, int const nySample, StatisticsControl const &sctrl, std::string const &prop)
std::vector< int > _ysize
y size ...
BackgroundControl(std::string const &style, int const nxSample=10, int const nySample=10, std::string const &undersampleStyle="THROW_EXCEPTION", StatisticsControl const sctrl=StatisticsControl(), std::string const &prop="MEANCLIP")
UndersampleStyle _asUsedUndersampleStyle
the undersampleStyle we actually used
Compute Image Statistics.
void setInterpStyle(std::string const &style)
Property stringToStatisticsProperty(std::string const property)
Conversion function to switch a string to a Property (see Statistics.h)
void operator-=(Image< LhsPixelT > &lhs, Image< RhsPixelT > const &rhs)
UndersampleStyle _undersampleStyle
double getPixel(int const x, int const y) const
Return the background value at a point.
#define LSST_makeBackground_getApproximate(m, v, T)
A class to evaluate image background levels.
BackgroundControl _bctrl
control info set by user.
Property
control what is calculated
void setStatisticsProperty(Property prop)
A class to represent a 2-dimensional array of pixels.
UndersampleStyle getAsUsedUndersampleStyle() const
void setNxSample(int nxSample)
void operator+=(Image< LhsPixelT > &lhs, Image< RhsPixelT > const &rhs)