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 Types | Public Member Functions | Protected Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
lsst::afw::detection::Footprint Class Reference

A set of pixels in an Image. More...

#include <Footprint.h>

Inheritance diagram for lsst::afw::detection::Footprint:
lsst::daf::base::Citizen lsst::afw::table::io::PersistableFacade< lsst::afw::detection::Footprint > lsst::afw::table::io::Persistable lsst::afw::detection::HeavyFootprint< ImagePixelT, MaskPixelT, VariancePixelT >

Public Types

typedef boost::shared_ptr
< Footprint
Ptr
 
typedef boost::shared_ptr
< const Footprint
ConstPtr
 
typedef std::vector< Span::Ptr > SpanList
 The Footprint's Span list. More...
 
- Public Types inherited from lsst::daf::base::Citizen
enum  { magicSentinel = 0xdeadbeef }
 
typedef unsigned long memId
 Type of the block's ID. More...
 
typedef memId(* memNewCallback )(const memId cid)
 A function used to register a callback. More...
 
typedef memId(* memCallback )(const Citizen *ptr)
 

Public Member Functions

 Footprint (int nspan=0, geom::Box2I const &region=geom::Box2I())
 
 Footprint (afw::table::Schema const &peakSchema, int nspan=0, geom::Box2I const &region=geom::Box2I())
 
 Footprint (geom::Box2I const &bbox, geom::Box2I const &region=geom::Box2I())
 
 Footprint (geom::Point2I const &center, double const radius, geom::Box2I const &=geom::Box2I())
 
 Footprint (geom::ellipses::Ellipse const &ellipse, geom::Box2I const &region=geom::Box2I())
 
 Footprint (SpanList const &spans, geom::Box2I const &region=geom::Box2I())
 
 Footprint (Footprint const &other)
 
virtual ~Footprint ()
 
virtual bool isHeavy () const
 
int getId () const
 
SpanListgetSpans ()
 
const SpanListgetSpans () const
 
PeakCataloggetPeaks ()
 
const PeakCataloggetPeaks () const
 
boost::shared_ptr< PeakRecordaddPeak (float fx, float fy, float value)
 Convenience function to add a peak (since that'd now be multiple lines without this function) More...
 
void sortPeaks (afw::table::Key< float > const &key=afw::table::Key< float >())
 
void setPeakSchema (afw::table::Schema const &peakSchema)
 Set the Schema used by the PeakCatalog (will throw if PeakCatalog is not empty). More...
 
int getNpix () const
 
int getArea () const
 
geom::Point2D getCentroid () const
 
geom::ellipses::Quadrupole getShape () const
 
const Span & addSpan (const int y, const int x0, const int x1)
 
const Span & addSpan (Span const &span)
 
const Span & addSpan (Span const &span, int dx, int dy)
 
const Span & addSpanInSeries (const int y, const int x0, const int x1)
 
void shift (int dx, int dy)
 
void shift (geom::ExtentI d)
 
geom::Box2I getBBox () const
 Return the Footprint's bounding box. More...
 
geom::Box2I const & getRegion () const
 Return the corners of the MaskedImage the footprints live in. More...
 
void setRegion (geom::Box2I const &region)
 Set the corners of the MaskedImage wherein the footprints dwell. More...
 
void clipTo (geom::Box2I const &bbox)
 
template<typename PixelT >
void clipToNonzero (lsst::afw::image::Image< PixelT > const &img)
 
bool contains (geom::Point2I const &pix) const
 
void normalize ()
 
bool isNormalized () const
 
template<typename PixelT >
void insertIntoImage (typename lsst::afw::image::Image< PixelT > &idImage, boost::uint64_t const id, geom::Box2I const &region=geom::Box2I()) const
 
template<typename PixelT >
void insertIntoImage (typename lsst::afw::image::Image< PixelT > &idImage, boost::uint64_t const id, bool const overwriteId, long const idMask, typename std::set< boost::uint64_t > *oldIds, geom::Box2I const &region=geom::Box2I()) const
 
Footprintoperator= (Footprint &other)
 
template<typename MaskPixelT >
void intersectMask (image::Mask< MaskPixelT > const &mask, MaskPixelT bitmask=~0x0)
 Intersect the Footprint with a Mask. More...
 
boost::shared_ptr< Footprinttransform (image::Wcs const &source, image::Wcs const &target, geom::Box2I const &region, bool doClip=true) const
 Transform the footprint from one WCS to another. More...
 
boost::shared_ptr< FootprintfindEdgePixels () const
 Find edge pixels on the footprint. More...
 
void include (std::vector< boost::shared_ptr< Footprint >> const &children, bool ignoreSelf=false)
 Update the Footprint in-place to be the union of itself and all others provided. More...
 
bool isPersistable () const
 Return true if this particular object can be persisted using afw::table::io. More...
 
- Public Member Functions inherited from lsst::daf::base::Citizen
 Citizen (const std::type_info &)
 
 Citizen (Citizen const &)
 
 ~Citizen ()
 
Citizenoperator= (Citizen const &)
 
std::string repr () const
 Return a string representation of a Citizen. More...
 
void markPersistent (void)
 Mark a Citizen as persistent and not destroyed until process end. More...
 
memId getId () const
 Return the Citizen's ID. More...
 
- Public Member Functions inherited from lsst::afw::table::io::Persistable
void writeFits (std::string const &fileName, std::string const &mode="w") const
 Write the object to a regular FITS file. More...
 
void writeFits (fits::MemFileManager &manager, std::string const &mode="w") const
 Write the object to a FITS image in memory. More...
 
void writeFits (fits::Fits &fitsfile) const
 Write the object to an already-open FITS object. More...
 
virtual ~Persistable ()
 

Protected Member Functions

virtual std::string getPersistenceName () const
 Return the unique name used to persist this object and look up its factory. More...
 
virtual std::string getPythonModule () const
 Return the fully-qualified Python module that should be imported to guarantee that its factory is registered. More...
 
virtual void write (OutputArchiveHandle &handle) const
 Write the object to one or more catalogs. More...
 
void readSpans (afw::table::BaseCatalog const &spanCat)
 Persistence implementation functions made available for derived classes. More...
 
void readPeaks (afw::table::BaseCatalog const &peakCat)
 Persistence implementation functions made available for derived classes. More...
 
- Protected Member Functions inherited from lsst::afw::table::io::Persistable
 Persistable ()
 
 Persistable (Persistable const &other)
 
void operator= (Persistable const &other)
 

Private Attributes

int _fid
 unique ID More...
 
int _area
 number of pixels in this Footprint (not the area of the bbox) More...
 
SpanList _spans
 the Spans contained in this Footprint More...
 
geom::Box2I _bbox
 the Footprint's bounding box More...
 
PeakCatalog _peaks
 the Peaks lying in this footprint More...
 
geom::Box2I _region
 The corners of the MaskedImage the footprints live in. More...
 
bool _normalized
 Are the spans sorted? More...
 

Static Private Attributes

static int id
 

Friends

class FootprintFactory
 
class FootprintMerge
 

Additional Inherited Members

- Static Public Member Functions inherited from lsst::daf::base::Citizen
static bool hasBeenCorrupted ()
 Check all allocated blocks for corruption. More...
 
static memId getNextMemId ()
 Return the memId of the next object to be allocated. More...
 
static int init ()
 Called once when the memory system is being initialised. More...
 
static int census (int, memId startingMemId=0)
 How many active Citizens are there? More...
 
static void census (std::ostream &stream, memId startingMemId=0)
 Print a list of all active Citizens to stream, sorted by ID. More...
 
static const std::vector
< const Citizen * > * 
census ()
 Return a (newly allocated) std::vector of active Citizens sorted by ID. More...
 
static memId setNewCallbackId (memId id)
 Call the NewCallback when block is allocated. More...
 
static memId setDeleteCallbackId (memId id)
 Call the current DeleteCallback when block is deleted. More...
 
static memNewCallback setNewCallback (memNewCallback func)
 Set the NewCallback function. More...
 
static memCallback setDeleteCallback (memCallback func)
 Set the DeleteCallback function. More...
 
static memCallback setCorruptionCallback (memCallback func)
 Set the CorruptionCallback function. More...
 
- Static Public Member Functions inherited from lsst::afw::table::io::PersistableFacade< lsst::afw::detection::Footprint >
static boost::shared_ptr
< lsst::afw::detection::Footprint
readFits (fits::Fits &fitsfile)
 Read an object from an already open FITS object. More...
 
static boost::shared_ptr
< lsst::afw::detection::Footprint
readFits (std::string const &fileName, int hdu=0)
 Read an object from a regular FITS file. More...
 
static boost::shared_ptr
< lsst::afw::detection::Footprint
readFits (fits::MemFileManager &manager, int hdu=0)
 Read an object from a FITS file in memory. More...
 
- Protected Types inherited from lsst::afw::table::io::Persistable
typedef io::OutputArchiveHandle OutputArchiveHandle
 

Detailed Description

A set of pixels in an Image.

A Footprint is a set of pixels, usually but not necessarily contiguous. There are constructors to find Footprints above some threshold in an Image (see FootprintSet), or to create Footprints in the shape of various geometrical figures

Examples:
footprintFunctor.cc.

Definition at line 62 of file Footprint.h.

Member Typedef Documentation

typedef boost::shared_ptr<const Footprint> lsst::afw::detection::Footprint::ConstPtr

Definition at line 68 of file Footprint.h.

typedef boost::shared_ptr<Footprint> lsst::afw::detection::Footprint::Ptr

Definition at line 67 of file Footprint.h.

typedef std::vector<Span::Ptr> lsst::afw::detection::Footprint::SpanList

The Footprint's Span list.

Definition at line 71 of file Footprint.h.

Constructor & Destructor Documentation

lsst::afw::detection::Footprint::Footprint ( int  nspan = 0,
geom::Box2I const &  region = geom::Box2I() 
)
explicit

Create a Footprint

Exceptions
lsst::pex::exceptions::InvalidParameterExceptionin nspan is < 0

nspan: initial number of Spans in this Footprint region: Bounding box of MaskedImage footprint

lsst::afw::detection::Footprint::Footprint ( afw::table::Schema const &  peakSchema,
int  nspan = 0,
geom::Box2I const &  region = geom::Box2I() 
)
explicit

Create a rectangular Footprint

lsst::afw::detection::Footprint::Footprint ( geom::Box2I const &  bbox,
geom::Box2I const &  region = geom::Box2I() 
)
explicit
lsst::afw::detection::Footprint::Footprint ( geom::Point2I const &  center,
double const  radius,
geom::Box2I const &  = geom::Box2I() 
)
lsst::afw::detection::Footprint::Footprint ( geom::ellipses::Ellipse const &  ellipse,
geom::Box2I const &  region = geom::Box2I() 
)
explicit
lsst::afw::detection::Footprint::Footprint ( SpanList const &  spans,
geom::Box2I const &  region = geom::Box2I() 
)
explicit
lsst::afw::detection::Footprint::Footprint ( Footprint const &  other)

Construct a footprint from a list of spans. Resulting Footprint is not normalized.

virtual lsst::afw::detection::Footprint::~Footprint ( )
virtual

Member Function Documentation

boost::shared_ptr< PeakRecord > lsst::afw::detection::Footprint::addPeak ( float  fx,
float  fy,
float  value 
)

Convenience function to add a peak (since that'd now be multiple lines without this function)

const Span& lsst::afw::detection::Footprint::addSpan ( const int  y,
const int  x0,
const int  x1 
)

Add a Span to a footprint, returning a reference to the new Span.

const Span& lsst::afw::detection::Footprint::addSpan ( Span const &  span)

Add a Span to a Footprint returning a reference to the new Span

const Span& lsst::afw::detection::Footprint::addSpan ( Span const &  span,
int  dx,
int  dy 
)

Add a Span to a Footprint returning a reference to the new Span

const Span& lsst::afw::detection::Footprint::addSpanInSeries ( const int  y,
const int  x0,
const int  x1 
)

Add a Span to a Footprint, where the Spans MUST be added in order (first in increasing y, then increasing x), and MUST NOT be overlapping. This method does NOT reset the _normalized boolean.

This method is useful when a Footprint is being constructed in such a way that Spans are guaranteed to be produced in order. In that case, it is not necessary to normalize() the Footprint after all the Spans have been added. This can save some computation.

void lsst::afw::detection::Footprint::clipTo ( geom::Box2I const &  bbox)
template<typename PixelT >
void lsst::afw::detection::Footprint::clipToNonzero ( lsst::afw::image::Image< PixelT > const &  img)

Clips the given Footprint to the region in the Image containing non-zero values. The clipping drops spans that are totally zero, and moves endpoints to non-zero; it does not split spans that have internal zeros.

bool lsst::afw::detection::Footprint::contains ( geom::Point2I const &  pix) const

Does this Footprint contain this pixel?

boost::shared_ptr< Footprint > lsst::afw::detection::Footprint::findEdgePixels ( ) const

Find edge pixels on the footprint.

Note that the resultant Footprint of edge pixels may not be contiguous.

int lsst::afw::detection::Footprint::getArea ( ) const
inline

Definition at line 153 of file Footprint.h.

153 { return _area; }
int _area
number of pixels in this Footprint (not the area of the bbox)
Definition: Footprint.h:346
geom::Box2I lsst::afw::detection::Footprint::getBBox ( ) const
inline

Return the Footprint's bounding box.

Definition at line 206 of file Footprint.h.

206 { return _bbox; }
geom::Box2I _bbox
the Footprint&#39;s bounding box
Definition: Footprint.h:349
geom::Point2D lsst::afw::detection::Footprint::getCentroid ( ) const

Return the Footprint's centroid

The centroid is calculated as the mean of the pixel centers

int lsst::afw::detection::Footprint::getId ( ) const
inline

Return the Footprint's unique ID.

Definition at line 109 of file Footprint.h.

109 { return _fid; }
int lsst::afw::detection::Footprint::getNpix ( ) const
inline

Return the number of pixels in this Footprint (the real number of pixels, not the area of the bbox).

Definition at line 152 of file Footprint.h.

152 { return _area; }
int _area
number of pixels in this Footprint (not the area of the bbox)
Definition: Footprint.h:346
PeakCatalog& lsst::afw::detection::Footprint::getPeaks ( )
inline

Return the Peaks contained in this Footprint

The peaks should be ordered by decreasing pixel intensity at the peak position (so the most negative peak appears last). Users that add new Peaks manually are responsible for maintaining this sorting.

Definition at line 123 of file Footprint.h.

123 { return _peaks; }
PeakCatalog _peaks
the Peaks lying in this footprint
Definition: Footprint.h:350
const PeakCatalog& lsst::afw::detection::Footprint::getPeaks ( ) const
inline

Definition at line 124 of file Footprint.h.

124 { return _peaks; }
PeakCatalog _peaks
the Peaks lying in this footprint
Definition: Footprint.h:350
virtual std::string lsst::afw::detection::Footprint::getPersistenceName ( ) const
protectedvirtual

Return the unique name used to persist this object and look up its factory.

Must be less than ArchiveIndexSchema::MAX_NAME_LENGTH characters.

Reimplemented from lsst::afw::table::io::Persistable.

Reimplemented in lsst::afw::detection::HeavyFootprint< ImagePixelT, MaskPixelT, VariancePixelT >.

virtual std::string lsst::afw::detection::Footprint::getPythonModule ( ) const
protectedvirtual

Return the fully-qualified Python module that should be imported to guarantee that its factory is registered.

Must be less than ArchiveIndexSchema::MAX_MODULE_LENGTH characters.

Will be ignored if empty.

Reimplemented from lsst::afw::table::io::Persistable.

geom::Box2I const& lsst::afw::detection::Footprint::getRegion ( ) const
inline

Return the corners of the MaskedImage the footprints live in.

Definition at line 209 of file Footprint.h.

209 { return _region; }
geom::Box2I _region
The corners of the MaskedImage the footprints live in.
Definition: Footprint.h:351
geom::ellipses::Quadrupole lsst::afw::detection::Footprint::getShape ( ) const

Return the Footprint's shape (interpreted as an ellipse)

The shape is determined by measuring the moments of the pixel centers about its centroid (cf. getCentroid)

SpanList& lsst::afw::detection::Footprint::getSpans ( )
inline

Return the Spans contained in this Footprint.

Definition at line 112 of file Footprint.h.

112 { return _spans; }
SpanList _spans
the Spans contained in this Footprint
Definition: Footprint.h:348
const SpanList& lsst::afw::detection::Footprint::getSpans ( ) const
inline

Return the Spans contained in this Footprint.

Definition at line 115 of file Footprint.h.

115 { return _spans; }
SpanList _spans
the Spans contained in this Footprint
Definition: Footprint.h:348
void lsst::afw::detection::Footprint::include ( std::vector< boost::shared_ptr< Footprint >> const &  children,
bool  ignoreSelf = false 
)

Update the Footprint in-place to be the union of itself and all others provided.

Only spans will be modified; peaks will be left unchanged. If ignoreSelf is true it will only be the union of all its children.

template<typename PixelT >
void lsst::afw::detection::Footprint::insertIntoImage ( typename lsst::afw::image::Image< PixelT > &  idImage,
boost::uint64_t const  id,
geom::Box2I const &  region = geom::Box2I() 
) const

Set the pixels in idImage that are in Footprint by adding the specified value to the Image.

idImage: Image to contain the footprint id: Add id to idImage for pixels in the Footprint region: Footprint's region (default: getRegion())

template<typename PixelT >
void lsst::afw::detection::Footprint::insertIntoImage ( typename lsst::afw::image::Image< PixelT > &  idImage,
boost::uint64_t const  id,
bool const  overwriteId,
long const  idMask,
typename std::set< boost::uint64_t > *  oldIds,
geom::Box2I const &  region = geom::Box2I() 
) const

Set the pixels in idImage which are in Footprint by adding the specified value to the Image.

The list of ids found under the new Footprint are returned.

idImage: Image to contain the footprint id: Add id to idImage for pixels in the Footprint overwriteId: should id replace any value already in idImage? idMask: Don't overwrite ID bits in this mask oldIds: if non-NULL, set the IDs that were overwritten region: Footprint's region (default: getRegion())

template<typename MaskPixelT >
void lsst::afw::detection::Footprint::intersectMask ( image::Mask< MaskPixelT > const &  mask,
MaskPixelT  bitmask = ~0x0 
)

Intersect the Footprint with a Mask.

The resulting Footprint contains only pixels for which (mask & bitMask) == 0; it may have disjoint pieces. Any part of the footprint that falls outside the bounds of the mask will be clipped.

virtual bool lsst::afw::detection::Footprint::isHeavy ( ) const
inlinevirtual

Is this a HeavyFootprint?

Reimplemented in lsst::afw::detection::HeavyFootprint< ImagePixelT, MaskPixelT, VariancePixelT >.

Definition at line 106 of file Footprint.h.

106 { return false; }
bool lsst::afw::detection::Footprint::isNormalized ( ) const
inline

Definition at line 234 of file Footprint.h.

234 {return _normalized;}
bool _normalized
Are the spans sorted?
Definition: Footprint.h:352
bool lsst::afw::detection::Footprint::isPersistable ( ) const
inlinevirtual

Return true if this particular object can be persisted using afw::table::io.

Reimplemented from lsst::afw::table::io::Persistable.

Definition at line 322 of file Footprint.h.

322 { return true; }
void lsst::afw::detection::Footprint::normalize ( )

Normalise a Footprint, sorting spans and setting the BBox

Footprint& lsst::afw::detection::Footprint::operator= ( Footprint other)

Assignment operator. Will not change the id

void lsst::afw::detection::Footprint::readPeaks ( afw::table::BaseCatalog const &  peakCat)
protected

Persistence implementation functions made available for derived classes.

void lsst::afw::detection::Footprint::readSpans ( afw::table::BaseCatalog const &  spanCat)
protected

Persistence implementation functions made available for derived classes.

void lsst::afw::detection::Footprint::setPeakSchema ( afw::table::Schema const &  peakSchema)
inline

Set the Schema used by the PeakCatalog (will throw if PeakCatalog is not empty).

Definition at line 137 of file Footprint.h.

137  {
138  if (!getPeaks().empty()) {
139  throw LSST_EXCEPT(
140  pex::exceptions::LogicError,
141  "Cannot change the PeakCatalog schema unless it is empty"
142  );
143  }
144  // this syntax doesn't work in Python, which is why this method has to exist
145  getPeaks() = PeakCatalog(peakSchema);
146  }
afw::table::CatalogT< PeakRecord > PeakCatalog
Definition: Peak.h:225
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
void lsst::afw::detection::Footprint::setRegion ( geom::Box2I const &  region)
inline

Set the corners of the MaskedImage wherein the footprints dwell.

Definition at line 212 of file Footprint.h.

212 { _region = region; }
geom::Box2I _region
The corners of the MaskedImage the footprints live in.
Definition: Footprint.h:351
void lsst::afw::detection::Footprint::shift ( int  dx,
int  dy 
)

Shift a Footprint by (dx, dy)

dx: How much to move footprint in column direction dy: How much to move in row direction

void lsst::afw::detection::Footprint::shift ( geom::ExtentI  d)
inline

Definition at line 203 of file Footprint.h.

203 {shift(d.getX(), d.getY());}
void shift(int dx, int dy)
void lsst::afw::detection::Footprint::sortPeaks ( afw::table::Key< float > const &  key = afw::table::Key< float >())

Sort Peaks from most positive value to most negative.

If the key passed is invalid (the default) PeakTable::getPeakValueKey() will be used.

boost::shared_ptr< Footprint > lsst::afw::detection::Footprint::transform ( image::Wcs const &  source,
image::Wcs const &  target,
geom::Box2I const &  region,
bool  doClip = true 
) const

Transform the footprint from one WCS to another.

Parameters
[in]sourceWcs that defines the coordinate system of the input footprint.
[in]targetWcs that defines that desired coordinate system of the returned footprint.
[in]regionUsed to set the "region" box of the returned footprint; note that this is NOT the same as the footprint's bounding box.
[in]doClipIf true, clip the new footprint to the region bbox before returning it.
virtual void lsst::afw::detection::Footprint::write ( OutputArchiveHandle handle) const
protectedvirtual

Write the object to one or more catalogs.

The handle object passed to this function provides an interface for adding new catalogs and adding nested objects to the same archive (while checking for duplicates). See OutputArchiveHandle for more information.

Reimplemented from lsst::afw::table::io::Persistable.

Reimplemented in lsst::afw::detection::HeavyFootprint< ImagePixelT, MaskPixelT, VariancePixelT >.

Friends And Related Function Documentation

friend class FootprintFactory
friend

Definition at line 338 of file Footprint.h.

friend class FootprintMerge
friend

Definition at line 342 of file Footprint.h.

Member Data Documentation

int lsst::afw::detection::Footprint::_area
private

number of pixels in this Footprint (not the area of the bbox)

Definition at line 346 of file Footprint.h.

geom::Box2I lsst::afw::detection::Footprint::_bbox
private

the Footprint's bounding box

Definition at line 349 of file Footprint.h.

int lsst::afw::detection::Footprint::_fid
mutableprivate

unique ID

Definition at line 345 of file Footprint.h.

bool lsst::afw::detection::Footprint::_normalized
private

Are the spans sorted?

Definition at line 352 of file Footprint.h.

PeakCatalog lsst::afw::detection::Footprint::_peaks
private

the Peaks lying in this footprint

Definition at line 350 of file Footprint.h.

geom::Box2I lsst::afw::detection::Footprint::_region
mutableprivate

The corners of the MaskedImage the footprints live in.

Definition at line 351 of file Footprint.h.

SpanList lsst::afw::detection::Footprint::_spans
private

the Spans contained in this Footprint

Definition at line 348 of file Footprint.h.

int lsst::afw::detection::Footprint::id
staticprivate

Definition at line 344 of file Footprint.h.


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