LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
Public Member Functions | Private Attributes | List of all members
lsst::afw::detection::FootprintFunctor< ImageT > Class Template Referenceabstract

A functor class to allow users to process all the pixels in a Footprint. More...

#include <FootprintFunctor.h>

Public Member Functions

 FootprintFunctor (ImageT const &image)
 
virtual ~FootprintFunctor ()=0
 
virtual void reset ()
 
virtual void reset (Footprint const &)
 
void apply (Footprint const &foot, int const margin=0)
 Apply operator() to each pixel in the Footprint. More...
 
ImageT const & getImage () const
 Return the image. More...
 
virtual void operator() (typename ImageT::xy_locator loc, int x, int y)=0
 

Private Attributes

ImageT const _image
 

Detailed Description

template<typename ImageT>
class lsst::afw::detection::FootprintFunctor< ImageT >

A functor class to allow users to process all the pixels in a Footprint.

There's an annotated example of a FootprintFunctor in action FootprintFunctors here

Examples:
footprintFunctor.cc.

Definition at line 40 of file FootprintFunctor.h.

Constructor & Destructor Documentation

template<typename ImageT >
lsst::afw::detection::FootprintFunctor< ImageT >::FootprintFunctor ( ImageT const &  image)
inline
Parameters
imageThe image that the Footprint lives in

Definition at line 42 of file FootprintFunctor.h.

43  : _image(image) {}
table::Key< table::Array< Kernel::Pixel > > image
Definition: FixedKernel.cc:117
template<typename ImageT >
lsst::afw::detection::FootprintFunctor< ImageT >::~FootprintFunctor ( )
pure virtual

Although FootprintFunctor is pure virtual, this is needed by subclasses

It wasn't defined in the class body as I want swig to know that the class is pure virtual

Definition at line 137 of file FootprintFunctor.h.

137 {}

Member Function Documentation

template<typename ImageT >
void lsst::afw::detection::FootprintFunctor< ImageT >::apply ( Footprint const &  foot,
int const  margin = 0 
)
inline

Apply operator() to each pixel in the Footprint.

Parameters
footThe Footprint in question
marginThe required margin from the edge of the image

Definition at line 57 of file FootprintFunctor.h.

59  {
60  reset();
61  reset(foot);
62 
63  if (foot.getSpans().empty()) {
64  return;
65  }
66 
67  geom::Box2I const bbox = foot.getBBox();
68  geom::Box2I region = foot.getRegion();
69  if (!region.isEmpty() &&
70  (!region.contains(bbox.getMin()) || !region.contains(bbox.getMax()))) {
71  throw LSST_EXCEPT(
72  lsst::pex::exceptions::LengthError,
73  (boost::format("Footprint with BBox (%d,%d) -- (%dx%d)"
74  "doesn't fit in image with BBox (%d,%d) -- (%dx%d)"
75  ) % bbox.getMinX() % bbox.getMinY()
76  % bbox.getMaxX() % bbox.getMaxY()
77  % region.getMinX() % region.getMinY()
78  % region.getMaxX() % region.getMaxY()
79  ).str()
80  );
81  }
82 
83  // Current position of the locator (in the SpanList loop)
84  int ox1 = 0, oy = 0;
85 
86  int const x0 = _image.getX0();
87  int const y0 = _image.getY0();
88 
89  typename ImageT::xy_locator loc = _image.xy_at(-x0, -y0); // Origin of the Image's pixels
90 
91  int const width = _image.getWidth();
92  int const height = _image.getHeight();
93  for (Footprint::SpanList::const_iterator siter = foot.getSpans().begin();
94  siter != foot.getSpans().end(); siter++) {
95  Span::Ptr const span = *siter;
96 
97  int const y = span->getY();
98  if (y - y0 < margin || y - y0 >= height - margin) {
99  continue;
100  }
101  int sx0 = span->getX0();
102  int sx1 = span->getX1();
103  if (sx0 - x0 < margin) {
104  sx0 = margin + x0;
105  }
106  if (sx1 - x0 >= width - margin) {
107  sx1 = width + x0 - margin - 1;
108  }
109 
110  loc += lsst::afw::image::pair2I(sx0 - ox1, y - oy);
111 
112  for (int x = sx0; x <= sx1; ++x, ++loc.x()) {
113  operator()(loc, x, y);
114  }
115 
116  ox1 = sx1 + 1; oy = y;
117  }
118  }
int y
int getMaxY() const
Definition: Box.h:129
bool contains(Point2I const &point) const
Return true if the box contains the point.
Point2I const getMax() const
Definition: Box.h:127
virtual void operator()(typename ImageT::xy_locator loc, int x, int y)=0
int const x0
Definition: saturated.cc:45
An integer coordinate rectangle.
Definition: Box.h:53
void ImageT ImageT int float saturatedPixelValue int const width
Definition: saturated.cc:44
int getMinY() const
Definition: Box.h:125
int getMinX() const
Definition: Box.h:124
double x
bool isEmpty() const
Return true if the box contains no points.
Definition: Box.h:166
void ImageT ImageT int float saturatedPixelValue int const height
Definition: saturated.cc:44
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
int getMaxX() const
Definition: Box.h:128
Point2I const getMin() const
Definition: Box.h:123
int const y0
Definition: saturated.cc:45
template<typename ImageT >
ImageT const& lsst::afw::detection::FootprintFunctor< ImageT >::getImage ( ) const
inline

Return the image.

Definition at line 120 of file FootprintFunctor.h.

120 { return _image; }
template<typename ImageT >
virtual void lsst::afw::detection::FootprintFunctor< ImageT >::operator() ( typename ImageT::xy_locator  loc,
int  x,
int  y 
)
pure virtual

The operator to be applied to each pixel in the Footprint.

N.b. the coordinates (x, y) are relative to the origin of the image's parent if it exists (i.e. they obey getX0/getY0)

template<typename ImageT >
virtual void lsst::afw::detection::FootprintFunctor< ImageT >::reset ( )
inlinevirtual

A function that's called at the beginning of apply; useful if apply calculates a per-footprint quantity

Definition at line 51 of file FootprintFunctor.h.

51 {}
template<typename ImageT >
virtual void lsst::afw::detection::FootprintFunctor< ImageT >::reset ( Footprint const &  )
inlinevirtual

Definition at line 52 of file FootprintFunctor.h.

52 {}

Member Data Documentation

template<typename ImageT >
ImageT const lsst::afw::detection::FootprintFunctor< ImageT >::_image
private

Definition at line 128 of file FootprintFunctor.h.


The documentation for this class was generated from the following file: