25 #if !defined(LSST_AFW_MATH_BACKGROUND_H)
26 #define LSST_AFW_MATH_BACKGROUND_H
30 #include <boost/preprocessor/seq.hpp>
75 if (nxSample <= 0 || nySample <= 0) {
77 str(
boost::format(
"You must specify at least one point, not %dx%d") % nxSample %
101 if (nxSample <= 0 || nySample <= 0) {
103 str(
boost::format(
"You must specify at least one point, not %dx%d") % nxSample %
127 _undersampleStyle(undersampleStyle),
131 if (nxSample <= 0 || nySample <= 0) {
133 str(
boost::format(
"You must specify at least one point, not %dx%d") % nxSample %
150 std::string const& undersampleStyle =
"THROW_EXCEPTION",
161 if (nxSample <= 0 || nySample <= 0) {
163 str(
boost::format(
"You must specify at least one point, not %dx%d") % nxSample %
177 str(
boost::format(
"nxSample must be position, not %d") % nxSample));
179 _nxSample = nxSample;
184 str(
boost::format(
"nySample must be position, not %d") % nySample));
186 _nySample = nySample;
194 _undersampleStyle = undersampleStyle;
246 template <
typename ImageT>
282 template <
typename PixelT>
286 return getImage<PixelT>(
_imgBBox, interpStyle, undersampleStyle);
295 template <
typename PixelT>
306 template <
typename PixelT>
310 return _getImage(
bbox, interpStyle, undersampleStyle,
static_cast<PixelT>(0));
317 template <
typename PixelT>
320 std::string const& undersampleStyle =
"THROW_EXCEPTION")
const {
328 template <
typename PixelT>
330 return getImage<PixelT>(
_bctrl->getInterpStyle(),
_bctrl->getUndersampleStyle());
352 return _getApproximate(actrl, undersampleStyle, disambiguate);
384 #define LSST_makeBackground_getImage_types (Background::InternalPixelT)
385 #define LSST_makeBackground_getApproximate_types (Background::InternalPixelT)
386 #define LSST_makeBackground_getImage(m, v, T) \
387 virtual std::shared_ptr<lsst::afw::image::Image<T>> _getImage( \
388 lsst::geom::Box2I const& bbox, \
389 Interpolate::Style const interpStyle, \
390 UndersampleStyle const undersampleStyle = \
395 #define LSST_makeBackground_getApproximate(m, v, T) \
396 virtual std::shared_ptr<Approximate<T>> _getApproximate( \
397 ApproximateControl const& actrl, \
398 UndersampleStyle const undersampleStyle = \
410 void _setCenOrigSize(
int const width,
int const height,
int const nxSample,
int const nySample);
436 template <
typename ImageT>
500 #if defined(LSST_makeBackground_getImage)
504 #undef LSST_makeBackground_getImage
505 #undef LSST_makeBackground_getApproximate
511 template <
typename PixelT>
516 template <
typename PixelT>
525 template <
typename ImageT>
#define LSST_makeBackground_getImage(m, v, T)
#define LSST_makeBackground_getApproximate(m, v, T)
#define LSST_makeBackground_getApproximate_types
#define LSST_makeBackground_getImage_types
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Control how to make an approximation.
Pass parameters to a Background object.
std::shared_ptr< ApproximateControl > getApproximateControl()
void setNySample(int nySample)
void setNxSample(int nxSample)
void setApproximateControl(std::shared_ptr< ApproximateControl > actrl)
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))
Overload constructor to handle strings for both interp and undersample styles.
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))
Overload constructor to provide interp style.
BackgroundControl(BackgroundControl const &)=default
BackgroundControl(int const nxSample, int const nySample, StatisticsControl const sctrl=StatisticsControl(), Property const prop=MEANCLIP, ApproximateControl const actrl=ApproximateControl(ApproximateControl::UNKNOWN, 1))
std::shared_ptr< StatisticsControl const > getStatisticsControl() const
virtual ~BackgroundControl()=default
BackgroundControl & operator=(BackgroundControl const &)=default
BackgroundControl(BackgroundControl &&)=default
Interpolate::Style getInterpStyle() const
void setInterpStyle(Interpolate::Style const style)
BackgroundControl & operator=(BackgroundControl &&)=default
void setUndersampleStyle(UndersampleStyle const undersampleStyle)
BackgroundControl(int const nxSample, int const nySample, StatisticsControl const &sctrl, std::string const &prop, ApproximateControl const actrl=ApproximateControl(ApproximateControl::UNKNOWN, 1))
Overload constructor to handle string for statistical operator.
void setStatisticsProperty(Property prop)
void setStatisticsProperty(std::string prop)
std::shared_ptr< StatisticsControl > getStatisticsControl()
UndersampleStyle getUndersampleStyle() const
void setUndersampleStyle(std::string const &undersampleStyle)
Property getStatisticsProperty() const
void setInterpStyle(std::string const &style)
std::shared_ptr< ApproximateControl const > getApproximateControl() const
A virtual base class to evaluate image background levels.
std::vector< double > _ycen
y center ...
std::vector< double > _xcen
x center pix coords of sub images
UndersampleStyle getAsUsedUndersampleStyle() const
Return the UndersampleStyle that we actually used in the last call to getImage()
virtual Background & operator+=(float const delta)=0
Add a constant level to a background.
Interpolate::Style getAsUsedInterpStyle() const
Return the Interpolate::Style that we actually used in the last call to getImage()
Background(Background &&)=delete
Background(Background const &)=delete
lsst::geom::Box2I getImageBBox() const
Return the input image's (PARENT) bounding box.
Background(ImageT const &img, BackgroundControl const &bgCtrl)
Constructor for Background.
Background & operator=(Background const &)=delete
std::shared_ptr< BackgroundControl > getBackgroundControl()
std::shared_ptr< BackgroundControl const > getBackgroundControl() const
std::shared_ptr< lsst::afw::image::Image< PixelT > > getImage(lsst::geom::Box2I const &bbox, Interpolate::Style const interpStyle, UndersampleStyle const undersampleStyle=THROW_EXCEPTION) const
std::vector< int > _xsize
x size of sub images
lsst::geom::Box2I _imgBBox
size and origin of input image
std::vector< int > _xorig
x origin pix coords of sub images
virtual Background & operator-=(float const delta)=0
Subtract a constant level from a background.
std::shared_ptr< lsst::afw::image::Image< PixelT > > getImage(lsst::geom::Box2I const &bbox, std::string const &interpStyle, std::string const &undersampleStyle="THROW_EXCEPTION") const
UndersampleStyle _asUsedUndersampleStyle
the undersampleStyle we actually used
Background & operator=(Background &&)=delete
std::shared_ptr< math::Approximate< InternalPixelT > > getApproximate(ApproximateControl const &actrl, UndersampleStyle const undersampleStyle=THROW_EXCEPTION) const
Method to return an approximation to the background.
std::shared_ptr< lsst::afw::image::Image< PixelT > > getImage() const
Method to interpolate and return the background for entire image.
std::vector< int > _ysize
y size ...
std::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.
virtual ~Background()=default
dtor
float InternalPixelT
type used for any internal images, and returned by getApproximate
std::vector< int > _yorig
y origin ...
Interpolate::Style _asUsedInterpStyle
the style we actually used
std::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.
std::shared_ptr< BackgroundControl > _bctrl
control info set by user.
A class to evaluate image background levels.
BackgroundMI & operator=(BackgroundMI const &)=delete
lsst::afw::image::MaskedImage< InternalPixelT > getStatsImage() const
Return the image of statistical quantities extracted from the image.
BackgroundMI & operator=(BackgroundMI &&)=delete
BackgroundMI(BackgroundMI &&)=delete
~BackgroundMI() override=default
BackgroundMI & operator-=(float const delta) override
Subtract a scalar from the Background (equivalent to subtracting a constant from the original image)
BackgroundMI(BackgroundMI const &)=delete
BackgroundMI & operator+=(float const delta) override
Add a scalar to the Background (equivalent to adding a constant to the original image)
BackgroundMI(ImageT const &img, BackgroundControl const &bgCtrl)
Constructor for BackgroundMI.
Pass parameters to a Statistics object.
An integer coordinate rectangle.
Reports invalid arguments.
Reports attempts to exceed implementation-defined length limits for some classes.
Property
control what is calculated
@ MEANCLIP
estimate sample N-sigma clipped mean (N set in StatisticsControl, default=3)
Property stringToStatisticsProperty(std::string const property)
Conversion function to switch a string to a Property (see Statistics.h)
Interpolate::Style stringToInterpStyle(std::string const &style)
Conversion function to switch a string to an Interpolate::Style.
UndersampleStyle stringToUndersampleStyle(std::string const &style)
Conversion function to switch a string to an UndersampleStyle.
std::shared_ptr< Background > makeBackground(ImageT const &img, BackgroundControl const &bgCtrl)
A convenience function that uses function overloading to make the correct type of Background.
BOOST_PP_SEQ_FOR_EACH(INSTANTIATE_COLUMNVIEW_SCALAR, _, BOOST_PP_TUPLE_TO_SEQ(AFW_TABLE_SCALAR_FIELD_TYPE_N, AFW_TABLE_SCALAR_FIELD_TYPE_TUPLE)) BOOST_PP_SEQ_FOR_EACH(INSTANTIATE_COLUMNVIEW_ARRAY
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
A base class for image defects.