lsst.afw
tickets.DM-23835-g31c64b24f1
|
Go to the documentation of this file.
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 %
120 "Omit `style` parameter, and pass it to `Background::getImage` instead. To be removed after "
132 _undersampleStyle(undersampleStyle),
136 if (nxSample <= 0 || nySample <= 0) {
138 str(boost::format(
"You must specify at least one point, not %dx%d") % nxSample %
157 "Omit `style` parameter, and pass it to `Background::getImage` instead. To be removed after "
160 std::string const& undersampleStyle =
"THROW_EXCEPTION",
172 if (nxSample <= 0 || nySample <= 0) {
174 str(boost::format(
"You must specify at least one point, not %dx%d") % nxSample %
188 str(boost::format(
"nxSample must be position, not %d") % nxSample));
190 _nxSample = nxSample;
195 str(boost::format(
"nySample must be position, not %d") % nySample));
197 _nySample = nySample;
201 "Replaced by passing style to `Background::getImage`. To be removed after 20.0.0.")]]
208 "Replaced by passing style to `Background::getImage`. To be removed after 20.0.0.")]]
215 _undersampleStyle = undersampleStyle;
225 "Replaced by passing style to `Background::getImage`. To be removed after 20.0.0.")]]
230 str(boost::format(
"Style %d is invalid") % _style));
275 template <
typename ImageT>
311 template <
typename PixelT>
315 return getImage<PixelT>(
_imgBBox, interpStyle, undersampleStyle);
324 template <
typename PixelT>
335 template <
typename PixelT>
339 return _getImage(
bbox, interpStyle, undersampleStyle, static_cast<PixelT>(0));
346 template <
typename PixelT>
349 std::string const& undersampleStyle =
"THROW_EXCEPTION")
const {
358 template <
typename PixelT>
360 "Call an overload with an `interpStyle` parameter. To be removed after 20.0.0.")]]
363 return getImage<PixelT>(
_bctrl->getInterpStyle(),
_bctrl->getUndersampleStyle());
385 return _getApproximate(actrl, undersampleStyle, disambiguate);
417 #define LSST_makeBackground_getImage_types (Background::InternalPixelT)
418 #define LSST_makeBackground_getApproximate_types (Background::InternalPixelT)
419 #define LSST_makeBackground_getImage(m, v, T) \
420 virtual std::shared_ptr<lsst::afw::image::Image<T>> _getImage( \
421 lsst::geom::Box2I const& bbox, \
422 Interpolate::Style const interpStyle, \
423 UndersampleStyle const undersampleStyle = \
428 #define LSST_makeBackground_getApproximate(m, v, T) \
429 virtual std::shared_ptr<Approximate<T>> _getApproximate( \
430 ApproximateControl const& actrl, \
431 UndersampleStyle const undersampleStyle = \
443 void _setCenOrigSize(
int const width,
int const height,
int const nxSample,
int const nySample);
470 template <
typename ImageT>
538 [[deprecated(
"Use `getImage` instead. To be removed after 20.0.0.")]]
548 [[deprecated(
"Use `getImage` instead. To be removed after 20.0.0.")]]
552 return getImage<float>(
_bctrl->getInterpStyle(),
_bctrl->getUndersampleStyle())
568 #if defined(LSST_makeBackground_getImage)
572 #undef LSST_makeBackground_getImage
573 #undef LSST_makeBackground_getApproximate
579 template <
typename PixelT>
584 template <
typename PixelT>
593 template <
typename ImageT>
601 #endif // LSST_AFW_MATH_BACKGROUND_H
Interpolate::Style stringToInterpStyle(std::string const &style)
Conversion function to switch a string to an Interpolate::Style.
void setInterpStyle(std::string const &style)
BackgroundMI(ImageT const &img, BackgroundControl const &bgCtrl)
Constructor for BackgroundMI.
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.
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::vector< int > _ysize
y size ...
void setStatisticsProperty(Property prop)
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::shared_ptr< ApproximateControl > getApproximateControl()
void setNySample(int nySample)
lsst::geom::Box2I getImageBBox() const
Return the input image's (PARENT) bounding box.
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.
std::shared_ptr< BackgroundControl > getBackgroundControl()
std::shared_ptr< lsst::afw::image::Image< PixelT > > getImage() const
Method to interpolate and return the background for entire image.
Background(ImageT const &img, BackgroundControl const &bgCtrl)
Constructor for 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
BackgroundControl(int const nxSample, int const nySample, StatisticsControl const sctrl=StatisticsControl(), Property const prop=MEANCLIP, ApproximateControl const actrl=ApproximateControl(ApproximateControl::UNKNOWN, 1))
float InternalPixelT
type used for any internal images, and returned by getApproximate
void setUndersampleStyle(std::string const &undersampleStyle)
Property stringToStatisticsProperty(std::string const property)
Conversion function to switch a string to a Property (see Statistics.h)
A class to evaluate image background levels.
#define LSST_makeBackground_getApproximate(m, v, T)
std::shared_ptr< StatisticsControl > getStatisticsControl()
#define LSST_makeBackground_getImage_types
~BackgroundMI() override=default
std::vector< int > _yorig
y origin ...
#define LSST_makeBackground_getImage(m, v, T)
void setUndersampleStyle(UndersampleStyle const undersampleStyle)
estimate sample N-sigma clipped mean (N set in StatisticsControl, default=3)
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.
UndersampleStyle getAsUsedUndersampleStyle() const
Return the UndersampleStyle that we actually used in the last call to getImage()
A virtual base class to evaluate image background levels.
std::vector< double > _xcen
x center pix coords of sub images
std::shared_ptr< BackgroundControl > _bctrl
control info set by user.
lsst::afw::image::MaskedImage< InternalPixelT > getStatsImage() const
Return the image of statistical quantities extracted from the image.
double getPixel(int const x, int const y) const
Return the background value at a point.
Background & operator=(Background const &)=delete
UndersampleStyle _asUsedUndersampleStyle
the undersampleStyle we actually used
BackgroundControl & operator=(BackgroundControl const &)=default
double getPixel(Interpolate::Style const style, int const x, int const y) const
Method to retrieve the background level at a pixel coord.
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.
std::shared_ptr< ApproximateControl const > getApproximateControl() const
Pass parameters to a Background object.
void setNxSample(int nxSample)
std::vector< int > _xsize
x size of sub images
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
A base class for image defects.
#define LSST_EXCEPT(type,...)
BackgroundMI & operator+=(float const delta) override
Add a scalar to the Background (equivalent to adding a constant to the original image)
std::vector< int > _xorig
x origin pix coords of sub images
Interpolate::Style getInterpStyle() const
UndersampleStyle getUndersampleStyle() const
Pass parameters to a Statistics object.
virtual ~BackgroundControl()=default
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.
#define LSST_makeBackground_getApproximate_types
Control how to make an approximation.
Interpolate::Style _asUsedInterpStyle
the style we actually used
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))
lsst::geom::Box2I _imgBBox
size and origin of input image
void setInterpStyle(Interpolate::Style const style)
std::shared_ptr< StatisticsControl const > getStatisticsControl() const
virtual Background & operator+=(float const delta)=0
Add a constant level to a background.
virtual Background & operator-=(float const delta)=0
Subtract a constant level from a background.
void setStatisticsProperty(std::string prop)
Interpolate::Style getAsUsedInterpStyle() const
Return the Interpolate::Style that we actually used in the last call to getImage()
Property
control what is calculated
std::shared_ptr< BackgroundControl const > getBackgroundControl() const
UndersampleStyle stringToUndersampleStyle(std::string const &style)
Conversion function to switch a string to an UndersampleStyle.
virtual ~Background()=default
dtor
BackgroundMI & operator-=(float const delta) override
Subtract a scalar from the Background (equivalent to subtracting a constant from the original image)
std::vector< double > _ycen
y center ...
void setApproximateControl(std::shared_ptr< ApproximateControl > actrl)
BackgroundMI & operator=(BackgroundMI const &)=delete
Property getStatisticsProperty() const