28 namespace lsst {
namespace afw {
namespace math {
31 ndarray::Array<double const,1>
const &
x,
32 ndarray::Array<double const,1>
const &
y
34 ndarray::Array<double,1,1> out = ndarray::allocate(x.getSize<0>());
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
x_iterator x_at(int x, int y) const
Return an x_iterator to the point (x, y) in the image.
void multiplyImage(image::Image< T > &image, bool overlapOnly=false) const
Multiply an image by the field in-place.
virtual double evaluate(geom::Point2D const &position) const =0
Evaluate the field at the given point.
Include files required for standard LSST Exception handling.
geom::Box2I getBBox(ImageOrigin origin=PARENT) const
int getX0() const
Return the image's column-origin.
An integer coordinate rectangle.
metadata import lsst afw display as afwDisplay n
void divideImage(image::Image< T > &image, bool overlapOnly=false) const
Divide an image by the field in-place.
void fillImage(image::Image< T > &image, bool overlapOnly=false) const
Assign the field to an image, overwriting values already present.
#define LSST_EXCEPT(type,...)
Create an exception with a given type and message and optionally other arguments (dependent on the ty...
void clip(Box2I const &other)
Shrink this to ensure that other.contains(*this).
An abstract base class for 2-d functions defined on an integer bounding boxes.
#define CONST_PTR(...)
A shared pointer to a const object.
A class to represent a 2-dimensional array of pixels.
void addToImage(image::Image< T > &image, double scaleBy=1.0, bool overlapOnly=false) const
Add the field or a constant multiple of it to an image in-place.
int getY0() const
Return the image's row-origin.