29 #ifndef LSST_AFW_IMAGE_IMAGE_ALGORITHM_H
30 #define LSST_AFW_IMAGE_IMAGE_ALGORITHM_H
38 #include "boost/tr1/functional.hpp"
39 #include "boost/mpl/bool.hpp"
48 namespace lsst {
namespace afw {
namespace image {
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)>
84 virtual LhsT
operator()(LhsT lhs, RhsT rhs)
const = 0;
90 template<
typename LhsT,
typename RhsT>
91 struct pixelOp2XY :
public std::tr1::function<LhsT (int, int, LhsT, RhsT)>
94 virtual LhsT
operator()(
int x,
int y, LhsT lhs, RhsT rhs)
const = 0;
101 template<
typename LhsT>
108 lhsPtr != lhsEnd; ++lhsPtr) {
117 template<
typename LhsT>
124 lhsPtr != lhsEnd; ++lhsPtr) {
125 *lhsPtr = func(*lhsPtr);
135 template<
typename LhsT>
143 lhsPtr != lhsEnd; ++lhsPtr, ++
x) {
144 *lhsPtr = func(x,
y + lhs.
getY0(), *lhsPtr);
152 template<
typename LhsT,
typename RhsT>
159 throw LSST_EXCEPT(lsst::pex::exceptions::LengthError,
160 (
boost::format(
"Images are of different size, %dx%d v %dx%d") %
168 lhsPtr != lhsEnd; ++rhsPtr, ++lhsPtr) {
169 *lhsPtr = func(*rhsPtr);
177 template<
typename LhsT,
typename RhsT>
184 throw LSST_EXCEPT(lsst::pex::exceptions::LengthError,
185 (
boost::format(
"Images are of different size, %dx%d v %dx%d") %
193 lhsPtr != lhsEnd; ++rhsPtr, ++lhsPtr) {
194 *lhsPtr = func(*lhsPtr, *rhsPtr);
203 template<
typename LhsT,
typename RhsT>
210 throw LSST_EXCEPT(lsst::pex::exceptions::LengthError,
211 (
boost::format(
"Images are of different size, %dx%d v %dx%d") %
219 lhsPtr != lhsEnd; ++rhsPtr, ++lhsPtr, ++
x) {
220 *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() ...
virtual LhsT operator()(int x, int y, LhsT lhs, RhsT rhs) const =0
Include files required for standard LSST Exception handling.
_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.
table::Key< table::Array< Kernel::Pixel > > image
A functor class equivalent to tr1::function<LhsT (int, int, LhsT, RhsT)>, but with a virtual operator...
geom::Extent2I getDimensions() const
Return the image's size; useful for passing to constructors.
x_iterator row_end(int y) const
Return an x_iterator to the end of the y'th row.
Types and classes to interface lsst::afw::image to boost::gil.
int getHeight() const
Return the number of rows in the image.
A functor class equivalent to tr1::function<ValT ()>, but with a virtual operator() ...
#define LSST_EXCEPT(type,...)
Create an exception with a given type and message and optionally other arguments (dependent on the ty...
A functor class equivalent to tr1::function<ValT (ValT)>, but with a virtual operator() ...
virtual ValT operator()(ValT lhs) const =0
x_iterator row_begin(int y) const
Return an x_iterator to the start of the y'th row.
virtual ValT operator()(int x, int y, ValT lhs) const =0
int getWidth() const
Return the number of columns in the image.
virtual ValT operator()() const =0
A class to represent a 2-dimensional array of pixels.
virtual LhsT operator()(LhsT lhs, RhsT rhs) const =0
int getY0() const
Return the image's row-origin.