28 #ifndef LSST_AFW_IMAGE_IMAGE_ALGORITHM_H 29 #define LSST_AFW_IMAGE_IMAGE_ALGORITHM_H 37 #include "boost/tr1/functional.hpp" 38 #include "boost/mpl/bool.hpp" 53 template <
typename ValT>
54 struct pixelOp0 :
public std::tr1::function<ValT()> {
62 template <
typename ValT>
63 struct pixelOp1 :
public std::tr1::function<ValT(ValT)> {
71 template <
typename ValT>
72 struct pixelOp1XY :
public std::tr1::function<ValT(int, int, ValT)> {
74 virtual ValT
operator()(
int x,
int y, ValT lhs)
const = 0;
80 template <
typename LhsT,
typename RhsT>
81 struct pixelOp2 :
public std::tr1::function<LhsT(LhsT, RhsT)> {
83 virtual LhsT
operator()(LhsT lhs, RhsT rhs)
const = 0;
89 template <
typename LhsT,
typename RhsT>
90 struct pixelOp2XY :
public std::tr1::function<LhsT(int, int, LhsT, RhsT)> {
92 virtual LhsT
operator()(
int x,
int y, LhsT lhs, RhsT rhs)
const = 0;
98 template <
typename LhsT>
102 for (
int y = 0; y != lhs.
getHeight(); ++y) {
104 lhsPtr != lhsEnd; ++lhsPtr) {
113 template <
typename LhsT>
117 for (
int y = 0; y != lhs.
getHeight(); ++y) {
119 lhsPtr != lhsEnd; ++lhsPtr) {
120 *lhsPtr = func(*lhsPtr);
130 template <
typename LhsT>
134 for (
int y = 0; y != lhs.
getHeight(); ++y) {
137 lhsPtr != lhsEnd; ++lhsPtr, ++
x) {
138 *lhsPtr = func(x, y + lhs.
getY0(), *lhsPtr);
146 template <
typename LhsT,
typename RhsT>
153 (boost::format(
"Images are of different size, %dx%d v %dx%d") % lhs.
getWidth() %
158 for (
int y = 0; y != lhs.
getHeight(); ++y) {
162 lhsPtr != lhsEnd; ++rhsPtr, ++lhsPtr) {
163 *lhsPtr = func(*rhsPtr);
171 template <
typename LhsT,
typename RhsT>
178 (boost::format(
"Images are of different size, %dx%d v %dx%d") % lhs.
getWidth() %
183 for (
int y = 0; y != lhs.
getHeight(); ++y) {
187 lhsPtr != lhsEnd; ++rhsPtr, ++lhsPtr) {
188 *lhsPtr = func(*lhsPtr, *rhsPtr);
197 template <
typename LhsT,
typename RhsT>
204 (boost::format(
"Images are of different size, %dx%d v %dx%d") % lhs.
getWidth() %
209 for (
int y = 0; y != lhs.
getHeight(); ++y) {
213 lhsPtr != lhsEnd; ++rhsPtr, ++lhsPtr, ++
x) {
214 *lhsPtr = func(x, y + lhs.
getY0(), *lhsPtr, *rhsPtr);
A functor class equivalent to tr1::function<LhsT (LhsT, RhsT)>, but with a virtual operator() ...
A functor class equivalent to tr1::function<ValT (int, int, ValT)>, but with a virtual operator() ...
int getHeight() const
Return the number of rows in the image.
_const_view_t::x_iterator const_x_iterator
A const iterator for traversing the pixels in a row.
_view_t::x_iterator x_iterator
An iterator for traversing the pixels in a row.
void for_each_pixel(Image< LhsT > &lhs, pixelOp0< LhsT > const &func)
Set each pixel in an Image<LhsT> to func()
int getX0() const
Return the image's column-origin.
x_iterator row_begin(int y) const
Return an x_iterator to the start of the y'th row.
geom::Extent2I getDimensions() const
Return the image's size; useful for passing to constructors.
A base class for image defects.
A functor class equivalent to tr1::function<LhsT (int, int, LhsT, RhsT)>, but with a virtual operator...
A functor class equivalent to tr1::function<ValT ()>, but with a virtual operator() ...
#define LSST_EXCEPT(type,...)
int getY0() const
Return the image's row-origin.
int getWidth() const
Return the number of columns in the image.
x_iterator row_end(int y) const
Return an x_iterator to the end of the y'th row.
A functor class equivalent to tr1::function<ValT (ValT)>, but with a virtual operator() ...
virtual ValT operator()() const =0
A class to represent a 2-dimensional array of pixels.