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"
77 if (nxSample <= 0 || nySample <= 0) {
78 throw LSST_EXCEPT(lsst::pex::exceptions::LengthError,
79 str(
boost::format(
"You must specify at least one point, not %dx%d")
80 % nxSample % nySample)
92 std::string
const &prop,
102 if (nxSample <= 0 || nySample <= 0) {
103 throw LSST_EXCEPT(lsst::pex::exceptions::LengthError,
104 str(
boost::format(
"You must specify at least one point, not %dx%d")
105 % nxSample % nySample)
115 int const nxSample = 10,
116 int const nySample = 10,
130 if (nxSample <= 0 || nySample <= 0) {
131 throw LSST_EXCEPT(lsst::pex::exceptions::LengthError,
132 str(
boost::format(
"You must specify at least one point, not %dx%d")
133 % nxSample % nySample)
144 std::string
const &style,
145 int const nxSample = 10,
146 int const nySample = 10,
147 std::string
const &undersampleStyle =
"THROW_EXCEPTION",
149 std::string
const &prop =
"MEANCLIP",
159 if (nxSample <= 0 || nySample <= 0) {
160 throw LSST_EXCEPT(lsst::pex::exceptions::LengthError,
161 str(
boost::format(
"You must specify at least one point, not %dx%d")
162 % nxSample % nySample)
170 throw LSST_EXCEPT(lsst::pex::exceptions::LengthError,
171 str(
boost::format(
"nxSample must be position, not %d") % nxSample));
177 throw LSST_EXCEPT(lsst::pex::exceptions::LengthError,
178 str(
boost::format(
"nySample must be position, not %d") % nySample));
199 throw LSST_EXCEPT(lsst::pex::exceptions::InvalidParameterError,
233 template<
typename ImageT>
243 virtual void operator+=(
float const delta) = 0;
245 virtual void operator-=(
float const delta) = 0;
251 template<
typename PixelT>
256 return getImage<PixelT>(_imgBBox, interpStyle, undersampleStyle);
263 template<
typename PixelT>
265 std::
string const &interpStyle,
271 template<
typename PixelT>
273 lsst::afw::geom::Box2I const& bbox,
277 return _getImage(bbox, interpStyle, undersampleStyle, static_cast<PixelT>(0));
279 template<
typename PixelT>
281 lsst::afw::geom::Box2I const& bbox,
282 std::
string const& interpStyle,
293 template<
typename PixelT>
295 return getImage<PixelT>(_bctrl->getInterpStyle(), _bctrl->getUndersampleStyle());
303 return _asUsedInterpStyle;
309 return _asUsedUndersampleStyle;
318 InternalPixelT disambiguate = 0;
319 return _getApproximate(actrl, undersampleStyle, disambiguate);
335 std::vector<
double> _xcen;
336 std::vector<
double> _ycen;
337 std::vector<
int> _xorig;
338 std::vector<
int> _yorig;
339 std::vector<
int> _xsize;
340 std::vector<
int> _ysize;
352 #define LSST_makeBackground_getImage_types (Background::InternalPixelT)
353 #define LSST_makeBackground_getApproximate_types (Background::InternalPixelT)
354 #define LSST_makeBackground_getImage(m, v, T) \
355 virtual PTR(lsst::afw::image::Image<T>) _getImage( \
356 lsst::afw::geom::Box2I const& bbox, \
357 Interpolate::Style const interpStyle, \
358 UndersampleStyle const undersampleStyle=THROW_EXCEPTION, \
362 #define LSST_makeBackground_getApproximate(m, v, T) \
363 virtual PTR(Approximate<T>) _getApproximate( \
364 ApproximateControl const& actrl, \
365 UndersampleStyle const undersampleStyle=THROW_EXCEPTION, \
373 Background(Background
const&);
374 Background& operator=(Background
const&);
375 void _setCenOrigSize(
int const width,
int const height,
int const nxSample,
int const nySample);
405 template<
typename ImageT>
439 int const iX, std::vector<int>
const& ypix)
const;
441 #if !defined(SWIG) && defined(LSST_makeBackground_getImage)
444 #if 0 // keep for use in Background instantiations
445 #undef LSST_makeBackground_getImage_types
446 #undef LSST_makeBackground_getApproximate_types
448 #undef LSST_makeBackground_getImage
449 #undef LSST_makeBackground_getApproximate
452 template<
typename PixelT>
466 template<typename ImageT>
473 #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...
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)
estimate sample N-sigma clipped mean (N set in StatisticsControl, default=3)
void setUndersampleStyle(std::string const &undersampleStyle)
void setNxSample(int nxSample)
BackgroundControl(int const nxSample, int const nySample, StatisticsControl const sctrl=StatisticsControl(), Property const prop=MEANCLIP, ApproximateControl const actrl=ApproximateControl(ApproximateControl::UNKNOWN, 1))
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)
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...
boost::shared_ptr< ApproximateControl > getApproximateControl()
boost::shared_ptr< ApproximateControl > _actrl
void setUndersampleStyle(UndersampleStyle const undersampleStyle)
void setApproximateControl(boost::shared_ptr< ApproximateControl > actrl)
void setStatisticsProperty(std::string prop)
Property getStatisticsProperty() const
geom::Box2I _imgBBox
size and origin of input image
lsst::afw::image::MaskedImage< InternalPixelT > _statsImage
void setNySample(int nySample)
#define LSST_makeBackground_getImage_types
UndersampleStyle getAsUsedUndersampleStyle() const
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", ApproximateControl const actrl=ApproximateControl(ApproximateControl::UNKNOWN, 1))
#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,...)
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, ApproximateControl const actrl=ApproximateControl(ApproximateControl::UNKNOWN, 1))
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
geom::Box2I getImageBBox() const
boost::shared_ptr< StatisticsControl > _sctrl
Interpolate::Style _style
Include files required for standard LSST Exception handling.
BackgroundControl(int const nxSample, int const nySample, StatisticsControl const &sctrl, std::string const &prop, ApproximateControl const actrl=ApproximateControl(ApproximateControl::UNKNOWN, 1))
Interpolate::Style getAsUsedInterpStyle() const