25 #if !defined(LSST_AFW_MATH_BACKGROUND_H) 26 #define LSST_AFW_MATH_BACKGROUND_H 30 #include <boost/preprocessor/seq.hpp> 76 if (nxSample <= 0 || nySample <= 0) {
78 str(
boost::format(
"You must specify at least one point, not %dx%d") % nxSample %
102 if (nxSample <= 0 || nySample <= 0) {
104 str(
boost::format(
"You must specify at least one point, not %dx%d") % nxSample %
129 _undersampleStyle(undersampleStyle),
133 if (nxSample <= 0 || nySample <= 0) {
135 str(
boost::format(
"You must specify at least one point, not %dx%d") % nxSample %
154 std::string const& undersampleStyle =
"THROW_EXCEPTION",
161 _undersampleStyle(math::stringToUndersampleStyle(undersampleStyle)),
165 if (nxSample <= 0 || nySample <= 0) {
167 str(
boost::format(
"You must specify at least one point, not %dx%d") % nxSample %
183 _nxSample = nxSample;
190 _nySample = nySample;
198 _undersampleStyle = undersampleStyle;
254 template <
typename ImageT>
290 template <
typename PixelT>
294 return getImage<PixelT>(_imgBBox, interpStyle, undersampleStyle);
303 template <
typename PixelT>
314 template <
typename PixelT>
318 return _getImage(bbox, interpStyle, undersampleStyle, static_cast<PixelT>(0));
325 template <
typename PixelT>
328 std::string const& undersampleStyle =
"THROW_EXCEPTION")
const {
337 template <
typename PixelT>
339 return getImage<PixelT>(_bctrl->getInterpStyle(), _bctrl->getUndersampleStyle());
360 InternalPixelT disambiguate = 0;
361 return _getApproximate(actrl, undersampleStyle, disambiguate);
393 #define LSST_makeBackground_getImage_types (Background::InternalPixelT) 394 #define LSST_makeBackground_getApproximate_types (Background::InternalPixelT) 395 #define LSST_makeBackground_getImage(m, v, T) \ 396 virtual std::shared_ptr<lsst::afw::image::Image<T>> _getImage( \ 397 lsst::geom::Box2I const& bbox, \ 398 Interpolate::Style const interpStyle, \ 399 UndersampleStyle const undersampleStyle = \ 404 #define LSST_makeBackground_getApproximate(m, v, T) \ 405 virtual std::shared_ptr<Approximate<T>> _getApproximate( \ 406 ApproximateControl const& actrl, \ 407 UndersampleStyle const undersampleStyle = \ 419 void _setCenOrigSize(
int const width,
int const height,
int const nxSample,
int const nySample);
446 template <
typename ImageT>
536 #if defined(LSST_makeBackground_getImage) 540 #if 0 // keep for use in Background instantiations 541 #undef LSST_makeBackground_getImage_types 542 #undef LSST_makeBackground_getApproximate_types 544 #undef LSST_makeBackground_getImage 545 #undef LSST_makeBackground_getApproximate 551 template <
typename PixelT>
556 template <
typename PixelT>
565 template <
typename ImageT>
573 #endif // LSST_AFW_MATH_BACKGROUND_H float InternalPixelT
type used for any internal images, and returned by getApproximate
std::vector< int > _xsize
x size of sub images
UndersampleStyle stringToUndersampleStyle(std::string const &style)
Conversion function to switch a string to an UndersampleStyle.
Interpolate::Style getAsUsedInterpStyle() const
Return the Interpolate::Style that we actually used in the last call to getImage() ...
std::vector< double > _xcen
x center pix coords of sub images
Interpolate::Style stringToInterpStyle(std::string const &style)
Conversion function to switch a string to an Interpolate::Style.
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::vector< int > _yorig
y origin ...
void setNySample(int nySample)
Image< LhsPixelT > & operator+=(Image< LhsPixelT > &lhs, Image< RhsPixelT > const &rhs)
Add lhs to Image rhs (i.e. pixel-by-pixel addition) where types are different.
lsst::geom::Box2I _imgBBox
size and origin of input image
Property getStatisticsProperty() const
Reports attempts to exceed implementation-defined length limits for some classes. ...
Interpolate::Style getInterpStyle() const
std::shared_ptr< math::Approximate< InternalPixelT > > getApproximate(ApproximateControl const &actrl, UndersampleStyle const undersampleStyle=THROW_EXCEPTION) const
Method to return an approximation to the background.
virtual ~BackgroundControl()=default
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))
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
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< ApproximateControl > getApproximateControl()
lsst::afw::image::MaskedImage< InternalPixelT > getStatsImage() const
Return the image of statistical quantities extracted from the image.
void setInterpStyle(Interpolate::Style const style)
#define LSST_makeBackground_getApproximate_types
std::vector< double > _ycen
y center ...
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(std::string prop)
Pass parameters to a Background object.
UndersampleStyle getAsUsedUndersampleStyle() const
Return the UndersampleStyle that we actually used in the last call to getImage()
std::shared_ptr< lsst::afw::image::Image< PixelT > > getImage(lsst::geom::Box2I const &bbox, Interpolate::Style const interpStyle, UndersampleStyle const undersampleStyle=THROW_EXCEPTION) const
A virtual base class to evaluate image background levels.
Property stringToStatisticsProperty(std::string const property)
Conversion function to switch a string to a Property (see Statistics.h)
std::shared_ptr< lsst::afw::image::Image< PixelT > > getImage() const
Method to interpolate and return the background for entire image.
Control how to make an approximation.
void setUndersampleStyle(std::string const &undersampleStyle)
Pass parameters to a Statistics object.
estimate sample N-sigma clipped mean (N set in StatisticsControl, default=3)
Interpolate::Style _asUsedInterpStyle
the style we actually used
A base class for image defects.
std::shared_ptr< BackgroundControl > getBackgroundControl()
std::shared_ptr< StatisticsControl > getStatisticsControl()
std::shared_ptr< ApproximateControl const > getApproximateControl() const
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
void setUndersampleStyle(UndersampleStyle const undersampleStyle)
BackgroundControl & operator=(BackgroundControl const &)=default
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.
#define LSST_makeBackground_getImage_types
#define LSST_makeBackground_getImage(m, v, T)
UndersampleStyle getUndersampleStyle() const
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
lsst::geom::Box2I getImageBBox() const
Return the input image's (PARENT) bounding box.
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
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.
std::vector< int > _xorig
x origin pix coords of sub images
Image< LhsPixelT > & operator-=(Image< LhsPixelT > &lhs, Image< RhsPixelT > const &rhs)
Subtract lhs from Image rhs (i.e. pixel-by-pixel subtraction) where types are different.
std::shared_ptr< BackgroundControl > _bctrl
control info set by user.
std::vector< int > _ysize
y size ...
UndersampleStyle _asUsedUndersampleStyle
the undersampleStyle we actually used
Reports invalid arguments.
void setInterpStyle(std::string const &style)
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< StatisticsControl const > getStatisticsControl() const
#define LSST_makeBackground_getApproximate(m, v, T)
A class to evaluate image background levels.
Citizen is a class that should be among all LSST classes base classes, and handles basic memory manag...
Property
control what is calculated
void setStatisticsProperty(Property prop)
An integer coordinate rectangle.
std::shared_ptr< BackgroundControl const > getBackgroundControl() const
void setNxSample(int nxSample)
void setApproximateControl(std::shared_ptr< ApproximateControl > actrl)