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
Interpolate::Style getInterpStyle() const
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...
std::vector< int > _ysize
y size ...
Interpolate::Style stringToInterpStyle(std::string const &style)
Conversion function to switch a string to an Interpolate::Style.
virtual ~BackgroundControl()
Interpolate values for a set of x,y vector<>s.
void setInterpStyle(Interpolate::Style const style)
std::vector< int > _xorig
x origin pix coords of sub images
estimate sample N-sigma clipped mean (N set in StatisticsControl, default=3)
void setUndersampleStyle(std::string const &undersampleStyle)
void setNxSample(int nxSample)
double getPixel(int const x, int const y) const
Return the background value at a point.
UndersampleStyle getUndersampleStyle() const
#define LSST_makeBackground_getApproximate_types
boost::shared_ptr< StatisticsControl > getStatisticsControl()
Extent< double, N > & operator+=(Extent< double, N > &lhs, Extent< int, N > const &rhs)
void setStatisticsProperty(Property prop)
std::vector< double > _ycen
y center ...
Extent< double, N > & operator-=(Extent< double, N > &lhs, Extent< int, N > const &rhs)
UndersampleStyle _undersampleStyle
Pass parameters to a Background object.
Approximate values for a MaskedImage.
A virtual base class to evaluate image background levels.
An integer coordinate rectangle.
float InternalPixelT
type used for any internal images, and returned by getApproximate
Control how to make an approximation.
Pass parameters to a Statistics objectA class to pass parameters which control how the stats are calc...
BackgroundControl(int const nxSample, int const nySample, StatisticsControl const &sctrl, std::string const &prop)
BackgroundControl _bctrl
control info set by user.
void setUndersampleStyle(UndersampleStyle const undersampleStyle)
std::vector< int > _xsize
x size of sub images
void setStatisticsProperty(std::string prop)
Property getStatisticsProperty() const
UndersampleStyle _asUsedUndersampleStyle
the undersampleStyle we actually used
geom::Box2I _imgBBox
size and origin of input image
lsst::afw::image::MaskedImage< InternalPixelT > _statsImage
void setNySample(int nySample)
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")
#define LSST_makeBackground_getImage_types
UndersampleStyle getAsUsedUndersampleStyle() const
#define LSST_makeBackground_getImage(m, v, T)
lsst::afw::image::MaskedImage< InternalPixelT > getStatsImage() const
Return the image of statistical quantities extracted from the image.
virtual ~Background()
dtor
#define LSST_EXCEPT(type,...)
std::vector< double > _xcen
x center pix coords of sub images
Compute Image Statistics.
Property stringToStatisticsProperty(std::string const property)
Conversion function to switch a string to a Property (see Statistics.h)
#define LSST_makeBackground_getApproximate(m, v, T)
A class to evaluate image background levels.
void setInterpStyle(std::string const &style)
std::vector< std::vector< double > > _gridColumns
Property
control what is calculated
std::vector< int > _yorig
y origin ...
geom::Box2I getImageBBox() const
boost::shared_ptr< StatisticsControl > _sctrl
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)
Interpolate::Style _style
Interpolate::Style _asUsedInterpStyle
the style we actually used
Include files required for standard LSST Exception handling.
BackgroundControl(int const nxSample, int const nySample, StatisticsControl const sctrl=StatisticsControl(), Property const prop=MEANCLIP)
Interpolate::Style getAsUsedInterpStyle() const