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
lsst::afw::image::MaskedImage< InternalPixelT > _statsImage
float InternalPixelT
type used for any internal images, and returned by getApproximate
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.
Interpolate values for a set of x,y vector<>s.
void setNySample(int nySample)
geom::Box2I getImageBBox() const
std::vector< std::vector< double > > _gridColumns
Include files required for standard LSST Exception handling.
geom::Box2I _imgBBox
size and origin of input image
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))
void setInterpStyle(Interpolate::Style const style)
#define LSST_makeBackground_getApproximate_types
Extent< double, N > & operator+=(Extent< double, N > &lhs, Extent< int, N > const &rhs)
Extent< double, N > & operator-=(Extent< double, N > &lhs, Extent< int, N > const &rhs)
BackgroundControl(int const nxSample, int const nySample, StatisticsControl const &sctrl, std::string const &prop, ApproximateControl const actrl=ApproximateControl(ApproximateControl::UNKNOWN, 1))
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
void setApproximateControl(boost::shared_ptr< ApproximateControl > actrl)
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...
estimate sample N-sigma clipped mean (N set in StatisticsControl, default=3)
void ImageT ImageT int float saturatedPixelValue int const width
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.
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_types
void ImageT ImageT int float saturatedPixelValue int const height
#define LSST_makeBackground_getImage(m, v, T)
boost::shared_ptr< ApproximateControl > getApproximateControl()
#define LSST_EXCEPT(type,...)
BackgroundControl(int const nxSample, int const nySample, StatisticsControl const sctrl=StatisticsControl(), Property const prop=MEANCLIP, ApproximateControl const actrl=ApproximateControl(ApproximateControl::UNKNOWN, 1))
Interpolate::Style _style
boost::shared_ptr< ApproximateControl > _actrl
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)
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.
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)