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"
40 #include "boost/shared_ptr.hpp"
49 namespace lsst {
namespace afw {
namespace image {
54 template<
typename ValT>
55 struct pixelOp0 :
public std::tr1::function<ValT ()> {
63 template<
typename ValT>
64 struct pixelOp1 :
public std::tr1::function<ValT (ValT)> {
72 template<
typename ValT>
73 struct pixelOp1XY :
public std::tr1::function<ValT (int, int, ValT)> {
75 virtual ValT
operator()(
int x,
int y, ValT lhs)
const = 0;
81 template<
typename LhsT,
typename RhsT>
82 struct pixelOp2 :
public std::tr1::function<LhsT (LhsT, RhsT)>
85 virtual LhsT
operator()(LhsT lhs, RhsT rhs)
const = 0;
91 template<
typename LhsT,
typename RhsT>
92 struct pixelOp2XY :
public std::tr1::function<LhsT (int, int, LhsT, RhsT)>
95 virtual LhsT
operator()(
int x,
int y, LhsT lhs, RhsT rhs)
const = 0;
102 template<
typename LhsT>
109 lhsPtr != lhsEnd; ++lhsPtr) {
118 template<
typename LhsT>
125 lhsPtr != lhsEnd; ++lhsPtr) {
126 *lhsPtr = func(*lhsPtr);
136 template<
typename LhsT>
144 lhsPtr != lhsEnd; ++lhsPtr, ++
x) {
145 *lhsPtr = func(x,
y + lhs.
getY0(), *lhsPtr);
153 template<
typename LhsT,
typename RhsT>
160 throw LSST_EXCEPT(lsst::pex::exceptions::LengthError,
161 (
boost::format(
"Images are of different size, %dx%d v %dx%d") %
169 lhsPtr != lhsEnd; ++rhsPtr, ++lhsPtr) {
170 *lhsPtr = func(*rhsPtr);
178 template<
typename LhsT,
typename RhsT>
185 throw LSST_EXCEPT(lsst::pex::exceptions::LengthError,
186 (
boost::format(
"Images are of different size, %dx%d v %dx%d") %
194 lhsPtr != lhsEnd; ++rhsPtr, ++lhsPtr) {
195 *lhsPtr = func(*lhsPtr, *rhsPtr);
204 template<
typename LhsT,
typename RhsT>
211 throw LSST_EXCEPT(lsst::pex::exceptions::LengthError,
212 (
boost::format(
"Images are of different size, %dx%d v %dx%d") %
220 lhsPtr != lhsEnd; ++rhsPtr, ++lhsPtr, ++
x) {
221 *lhsPtr = func(x,
y + lhs.
getY0(), *lhsPtr, *rhsPtr);
x_iterator row_begin(int y) const
x_iterator row_end(int y) const
Return an x_iterator to the end of the y'th row.
void for_each_pixel(Image< LhsT > &lhs, pixelOp0< LhsT > const &func)
virtual ValT operator()() const =0
table::Key< table::Array< Kernel::Pixel > > image
int getWidth() const
Return the number of columns in the image.
A set of classes of general utility in connection with images.
_const_view_t::x_iterator const_x_iterator
A const iterator for traversing the pixels in a row.
Types and classes to interface lsst::afw::image to boost::gil.
virtual ValT operator()(ValT lhs) const =0
#define LSST_EXCEPT(type,...)
virtual ValT operator()(int x, int y, ValT lhs) const =0
_view_t::x_iterator x_iterator
An iterator for traversing the pixels in a row.
virtual LhsT operator()(LhsT lhs, RhsT rhs) const =0
int getHeight() const
Return the number of rows in the image.
virtual LhsT operator()(int x, int y, LhsT lhs, RhsT rhs) const =0
geom::Extent2I getDimensions() const
Return the image's size; useful for passing to constructors.
A class to represent a 2-dimensional array of pixels.
Include files required for standard LSST Exception handling.