28 namespace lsst {
namespace afw {
namespace math {
35 for (
int i = 0, n = x.
getSize<0>(); i < n; ++i) {
52 void operator()(T & out,
double a)
const { out = a; }
58 explicit ScaledAdd(
double s) :
scaleBy(s) {}
61 void operator()(T & out,
double a)
const { out +=
scaleBy * a; }
69 void operator()(T & out,
double a)
const { out *= a; }
76 void operator()(T & out,
double a)
const { out /= a; }
80 template <
typename T,
typename F>
81 void applyToImage(BoundedField
const &
field,
image::Image<T> & img, F functor,
bool overlapOnly) {
87 pex::exceptions::RuntimeError,
88 "Image bounding box does not match field bounding box"
91 for (
int y = region.getBeginY(), yEnd = region.getEndY();
y < yEnd; ++
y) {
95 for (
int x = region.getBeginX(), xEnd = region.getEndX();
x < xEnd; ++
x, ++rowIter) {
96 functor(*rowIter, field.evaluate(
x,
y));
107 template <
typename T>
109 applyToImage(*
this, img, Assign(), overlapOnly);
112 template <
typename T>
114 applyToImage(*
this, img, ScaledAdd(scaleBy), overlapOnly);
117 template <
typename T>
119 applyToImage(*
this, img, Multiply(), overlapOnly);
122 template <
typename T>
124 applyToImage(*
this, img, Divide(), overlapOnly);
127 #define INSTANTIATE(T) \
128 template void BoundedField::fillImage(image::Image<T> &, bool) const; \
129 template void BoundedField::addToImage(image::Image<T> &, double, bool) const; \
130 template void BoundedField::multiplyImage(image::Image<T> &, bool) const; \
131 template void BoundedField::divideImage(image::Image<T> &, bool) const
void clip(Box2I const &other)
Shrink this to ensure that other.contains(*this).
void fillImage(image::Image< T > &image, bool overlapOnly=false) const
void multiplyImage(image::Image< T > &image, bool overlapOnly=false) const
void addToImage(image::Image< T > &image, double scaleBy=1.0, bool overlapOnly=false) const
int getSize() const
Return the size of a specific dimension.
An integer coordinate rectangle.
virtual double evaluate(geom::Point2D const &position) const =0
x_iterator x_at(int x, int y) const
Return an x_iterator to the point (x, y) in the image.
detail::SimpleInitializer< N > allocate(Vector< int, N > const &shape)
Create an expression that allocates uninitialized memory for an array.
#define LSST_EXCEPT(type,...)
geom::Box2I getBBox(ImageOrigin origin=PARENT) const
An abstract base class for 2-d functions defined on an integer bounding boxes.
A class to represent a 2-dimensional array of pixels.
void divideImage(image::Image< T > &image, bool overlapOnly=false) const
Include files required for standard LSST Exception handling.