LSSTApplications  19.0.0-11-g2ce9f25+4,20.0.0+1,20.0.0+10,20.0.0+11,20.0.0+13,20.0.0+2,20.0.0+3,20.0.0+4,20.0.0+6,20.0.0-1-g10df615+10,20.0.0-1-g253301a+5,20.0.0-1-g596936a+11,20.0.0-1-g8a53f90+1,20.0.0-1-gc96f8cb+12,20.0.0-1-gd1c87d7+1,20.0.0-17-g41c5faf,20.0.0-2-g04cfba9+4,20.0.0-2-gd11eeda,20.0.0-2-gec03fae+3,20.0.0-3-g082faa5+1,20.0.0-3-gbdbfa727+3,20.0.0-3-gc53c7b6,20.0.0-4-gde602ef96+4,20.0.0-4-ge48a6ca+6,20.0.0-4-ge987224+1,20.0.0-8-g7eef53f7+7,20.0.0-9-g8e1b333,w.2020.28
LSSTDataManagementBasePackage
Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Friends | List of all members
lsst::afw::geom::SpanSet Class Reference

A compact representation of a collection of pixels. More...

#include <SpanSet.h>

Inheritance diagram for lsst::afw::geom::SpanSet:
lsst::afw::table::io::PersistableFacade< lsst::afw::geom::SpanSet > lsst::afw::table::io::Persistable

Public Types

typedef std::vector< Span >::const_iterator const_iterator
 
typedef std::vector< Span >::size_type size_type
 
typedef Span value_type
 
typedef value_type const & const_reference
 

Public Member Functions

const_iterator begin () const
 
const_iterator end () const
 
const_iterator cbegin () const
 
const_iterator cend () const
 
const_reference front () const
 
const_reference back () const
 
size_type size () const
 
bool empty () const
 
 SpanSet ()
 Default constructor. More...
 
 SpanSet (lsst::geom::Box2I const &box)
 Construct a SpanSet from a box. More...
 
template<typename iter >
 SpanSet (iter begin, iter end, bool normalize=true)
 Construct a SpanSet from an iterator. More...
 
 SpanSet (std::vector< Span > const &vec, bool normalize=true)
 Construct a SpanSet from a std vector by copying. More...
 
 SpanSet (std::vector< Span > &&vec, bool normalize=true)
 Construct a SpanSet from a std vector from a move. More...
 
 SpanSet (SpanSet const &other)=delete
 
 SpanSet (SpanSet &&other)=delete
 
 ~SpanSet () override=default
 
SpanSetoperator= (SpanSet const &)=default
 
SpanSetoperator= (SpanSet &&other)
 
size_type getArea () const
 Return the number of pixels in the SpanSet. More...
 
lsst::geom::Box2I getBBox () const
 Return a new integer box which is the minimum size to contain the pixels. More...
 
bool isContiguous () const
 Defines if the SpanSet is simply contiguous. More...
 
std::shared_ptr< SpanSetshiftedBy (int x, int y) const
 Return a new SpanSet shifted by specified amount. More...
 
std::shared_ptr< SpanSetshiftedBy (lsst::geom::Extent2I const &offset) const
 Return a new SpanSet shifted by specified amount. More...
 
std::shared_ptr< SpanSetclippedTo (lsst::geom::Box2I const &box) const
 Return a new SpanSet which has all pixel values inside specified box. More...
 
std::shared_ptr< SpanSettransformedBy (lsst::geom::LinearTransform const &t) const
 Return a new SpanSet who's pixels are the product of applying the specified transformation. More...
 
std::shared_ptr< SpanSettransformedBy (lsst::geom::AffineTransform const &t) const
 Return a new SpanSet who's pixels are the product of applying the specified transformation. More...
 
std::shared_ptr< SpanSettransformedBy (TransformPoint2ToPoint2 const &t) const
 Return a new SpanSet who's pixels are the product of applying the specified transformation. More...
 
bool overlaps (SpanSet const &other) const
 Specifies if this SpanSet overlaps with another SpanSet. More...
 
bool contains (SpanSet const &other) const
 Check if a SpanSet instance entirely contains another SpanSet. More...
 
bool contains (lsst::geom::Point2I const &point) const
 Check if a point is contained within the SpanSet instance. More...
 
lsst::geom::Point2D computeCentroid () const
 Compute the point about which the SpanSet's first moment is zero. More...
 
ellipses::Quadrupole computeShape () const
 Compute the shape parameters for the distribution of points in the SpanSet. More...
 
std::shared_ptr< SpanSetdilated (int r, Stencil s=Stencil::CIRCLE) const
 Perform a set dilation operation, and return a new object. More...
 
std::shared_ptr< SpanSetdilated (SpanSet const &other) const
 Perform a set dilation operation, and return a new object. More...
 
std::shared_ptr< SpanSeteroded (int r, Stencil s=Stencil::CIRCLE) const
 Perform a set erosion, and return a new object. More...
 
std::shared_ptr< SpanSeteroded (SpanSet const &other) const
 Perform a set erosion operation, and return a new object. More...
 
template<typename Pixel , int inN, int inC>
ndarray::Array< typename std::remove_const< Pixel >::type, inN - 1, inN - 1 > flatten (ndarray::Array< Pixel, inN, inC > const &input, lsst::geom::Point2I const &xy0=lsst::geom::Point2I()) const
 Reduce the pixel dimensionality from 2 to 1 of an array at points given by SpanSet. More...
 
template<typename PixelIn , typename PixelOut , int inA, int outC, int inC>
void flatten (ndarray::Array< PixelOut, inA - 1, outC > const &output, ndarray::Array< PixelIn, inA, inC > const &input, lsst::geom::Point2I const &xy0=lsst::geom::Point2I()) const
 Reduce the pixel dimensionality from 2 to 1 of an array at points given by SpanSet. More...
 
template<typename Pixel , int inA, int inC>
ndarray::Array< typename std::remove_const< Pixel >::type, inA+1, inA+1 > unflatten (ndarray::Array< Pixel, inA, inC > const &input) const
 Expand an array by one spatial dimension at points given by SpanSet. More...
 
template<typename PixelIn , typename PixelOut , int inA, int outC, int inC>
void unflatten (ndarray::Array< PixelOut, inA+1, outC > const &output, ndarray::Array< PixelIn, inA, inC > const &input, lsst::geom::Point2I const &xy0=lsst::geom::Point2I()) const
 Expand an array by one spatial dimension at points given by SpanSet. More...
 
template<typename ImageT >
void copyImage (image::Image< ImageT > const &src, image::Image< ImageT > &dest)
 Copy contents of source Image into destination image at the positions defined in the SpanSet. More...
 
template<typename ImageT , typename MaskT , typename VarT >
void copyMaskedImage (image::MaskedImage< ImageT, MaskT, VarT > const &src, image::MaskedImage< ImageT, MaskT, VarT > &dest)
 Copy contents of source MaskedImage into destination image at the positions defined in the SpanSet. More...
 
template<typename ImageT >
void setImage (image::Image< ImageT > &image, ImageT val, lsst::geom::Box2I const &region=lsst::geom::Box2I(), bool doClip=false) const
 Set the values of an Image at points defined by the SpanSet. More...
 
template<typename Functor , typename... Args>
void applyFunctor (Functor &&func, Args &&... args) const
 Apply functor on individual elements from the supplied parameters. More...
 
template<typename T >
void setMask (lsst::afw::image::Mask< T > &target, T bitmask) const
 Set a Mask at pixels defined by the SpanSet. More...
 
template<typename T >
void clearMask (lsst::afw::image::Mask< T > &target, T bitmask) const
 Unset a Mask at pixels defined by the SpanSet. More...
 
std::shared_ptr< SpanSetintersect (SpanSet const &other) const
 Determine the common points between two SpanSets, and create a new SpanSet. More...
 
template<typename T >
std::shared_ptr< SpanSetintersect (image::Mask< T > const &other, T bitmask) const
 Determine the common points between a SpanSet and a Mask with a given bit pattern. More...
 
std::shared_ptr< SpanSetintersectNot (SpanSet const &other) const
 Determine the common points between a SpanSet and the logical inverse of a second SpanSet and return them in a new SpanSet. More...
 
template<typename T >
std::shared_ptr< SpanSetintersectNot (image::Mask< T > const &other, T bitmask) const
 Determine the common points between a SpanSet and the logical inverse of a Mask for a given bit pattern. More...
 
std::shared_ptr< SpanSetunion_ (SpanSet const &other) const
 Create a new SpanSet that contains all points from two SpanSets. More...
 
template<typename T >
std::shared_ptr< SpanSetunion_ (image::Mask< T > const &other, T bitmask) const
 Determine the union between a SpanSet and a Mask for a given bit pattern. More...
 
bool operator== (SpanSet const &other) const
 Compute equality between two SpanSets. More...
 
bool operator!= (SpanSet const &other) const
 
std::vector< std::shared_ptr< geom::SpanSet > > split () const
 Split a discontinuous SpanSet into multiple SpanSets which are contiguous. More...
 
bool isPersistable () const noexcept override
 Return true if this particular object can be persisted using afw::table::io. More...
 
std::shared_ptr< geom::SpanSet > findEdgePixels () const
 Select pixels within the SpanSet which touch its edge. More...
 
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...
 

Static Public Member Functions

static std::shared_ptr< geom::SpanSet > fromShape (int r, Stencil s=Stencil::CIRCLE, lsst::geom::Point2I offset=lsst::geom::Point2I())
 Factory function for creating SpanSets from a Stencil. More...
 
static std::shared_ptr< geom::SpanSet > fromShape (geom::ellipses::Ellipse const &ellipse)
 Factory function for creating SpanSets from an ellipse object. More...
 
template<typename T , typename UnaryPredicate = details::AnyBitSetFunctor<T>>
static std::shared_ptr< geom::SpanSet > fromMask (image::Mask< T > const &mask, UnaryPredicate comparator=details::AnyBitSetFunctor< T >())
 Create a SpanSet from a mask. More...
 
template<typename T >
static std::shared_ptr< geom::SpanSet > fromMask (image::Mask< T > const &mask, T bitmask)
 Create a SpanSet from a mask. More...
 
static std::shared_ptr< lsst::afw::geom::SpanSetreadFits (fits::Fits &fitsfile)
 Read an object from an already open FITS object. More...
 
static std::shared_ptr< lsst::afw::geom::SpanSetreadFits (std::string const &fileName, int hdu=fits::DEFAULT_HDU)
 Read an object from a regular FITS file. More...
 
static std::shared_ptr< lsst::afw::geom::SpanSetreadFits (fits::MemFileManager &manager, int hdu=fits::DEFAULT_HDU)
 Read an object from a FITS file in memory. More...
 
static std::shared_ptr< lsst::afw::geom::SpanSetdynamicCast (std::shared_ptr< Persistable > const &ptr)
 Dynamically cast a shared_ptr. More...
 

Protected Types

typedef io::OutputArchiveHandle OutputArchiveHandle
 

Friends

class SpansSetFactory
 

Detailed Description

A compact representation of a collection of pixels.

A SpanSet is a collection of Span classes. As each Span encodes a range of pixels on a given row, a SpanSet represents an arbitrary collection of pixels on an image. The SpanSet class also contains mathematical set style operators, for working with the collection of pixels, and helper functions which make use of the area defined to perform localized actions

Definition at line 77 of file SpanSet.h.

Member Typedef Documentation

◆ const_iterator

Definition at line 80 of file SpanSet.h.

◆ const_reference

Definition at line 83 of file SpanSet.h.

◆ OutputArchiveHandle

typedef io::OutputArchiveHandle lsst::afw::table::io::Persistable::OutputArchiveHandle
protectedinherited

Definition at line 108 of file Persistable.h.

◆ size_type

Definition at line 81 of file SpanSet.h.

◆ value_type

Definition at line 82 of file SpanSet.h.

Constructor & Destructor Documentation

◆ SpanSet() [1/7]

lsst::afw::geom::SpanSet::SpanSet ( )

Default constructor.

Construct a null SpanSet, with zero size. This is useful as a placeholder

Definition at line 178 of file SpanSet.cc.

178 : _spanVector(), _bbox(), _area(0) {}

◆ SpanSet() [2/7]

lsst::afw::geom::SpanSet::SpanSet ( lsst::geom::Box2I const &  box)
explicit

Construct a SpanSet from a box.

Parameters
boxA integer box that defines the shape for which a span set should be created

Definition at line 181 of file SpanSet.cc.

181  : _bbox(box), _area(box.getArea()) {
182  int beginY = box.getMinY();
183 
184  int beginX = box.getMinX();
185  int maxX = box.getMaxX();
186 
187  for (int i = beginY; i < _bbox.getEndY(); ++i) {
188  _spanVector.push_back(Span(i, beginX, maxX));
189  }
190 }

◆ SpanSet() [3/7]

template<typename iter >
lsst::afw::geom::SpanSet::SpanSet ( iter  begin,
iter  end,
bool  normalize = true 
)
inline

Construct a SpanSet from an iterator.

This constructor accepts the begin and end points of an arbitrary iterator of a container which contains previously created Spans. These Spans are used to construct the SpanSet.

Parameters
beginBeginning iterator of a container of Spans
endEnd iterator of a container of Spans
normalizeControls if the constructor attempts to merge connected or overlapping spans. Defaults to true. Set to false to save computational time when the container is sure to already be normalized.

Definition at line 123 of file SpanSet.h.

123  : _spanVector(begin, end) {
124  // Return a null SpanSet if spanVector is 0
125  if (_spanVector.size() == 0) {
126  _bbox = lsst::geom::Box2I();
127  _area = 0;
128  } else {
129  if (normalize) {
130  _runNormalize();
131  }
132  _initialize();
133  }
134  }

◆ SpanSet() [4/7]

lsst::afw::geom::SpanSet::SpanSet ( std::vector< Span > const &  vec,
bool  normalize = true 
)
explicit

Construct a SpanSet from a std vector by copying.

This constructor accepts a standard vector which contains already created Spans. These Spans are copied into the internal container of spans.

Parameters
vecStandard vector containing Spans
normalizeControls if the constructor attempts to merge connected or overlapping spans. Defaults to true. Set to false to save computational time when the container is sure to already be normalized.

Definition at line 193 of file SpanSet.cc.

193  : _spanVector(vec) {
194  // If the incoming vector is zero, should create an empty spanSet
195  if (_spanVector.empty()) {
196  _bbox = lsst::geom::Box2I();
197  _area = 0;
198  } else {
199  if (normalize) {
200  _runNormalize();
201  }
202  _initialize();
203  }
204 }

◆ SpanSet() [5/7]

lsst::afw::geom::SpanSet::SpanSet ( std::vector< Span > &&  vec,
bool  normalize = true 
)
explicit

Construct a SpanSet from a std vector from a move.

This constructor accepts a standard vector r-reference which contains already created Spans. These Spans become the internal container of spans.

Parameters
vecStandard vector containing Spans
normalizeControls if the constructor attempts to merge connected or overlapping spans. Defaults to true. Set to false to save computational time when the container is sure to already be normalized.

Definition at line 207 of file SpanSet.cc.

207  : _spanVector(std::move(vec)) {
208  // If the incoming vector is zero, should create an empty SpanSet
209  if (_spanVector.size() == 0) {
210  _bbox = lsst::geom::Box2I();
211  _area = 0;
212  } else {
213  if (normalize) {
214  _runNormalize();
215  }
216  _initialize();
217  }
218 }

◆ SpanSet() [6/7]

lsst::afw::geom::SpanSet::SpanSet ( SpanSet const &  other)
delete

◆ SpanSet() [7/7]

lsst::afw::geom::SpanSet::SpanSet ( SpanSet &&  other)
delete

◆ ~SpanSet()

lsst::afw::geom::SpanSet::~SpanSet ( )
overridedefault

Member Function Documentation

◆ applyFunctor()

template<typename Functor , typename... Args>
void lsst::afw::geom::SpanSet::applyFunctor ( Functor &&  func,
Args &&...  args 
) const
inline

Apply functor on individual elements from the supplied parameters.

Use a variadic template to take a functor object, and an arbitrary number of parameters. Parameters may be of type(s) Image, MakedImage, ndarray, numeric value and generic iterators. For most of these types bound checking is done to ensure execution safety, but because a generic iterator can have any behavior, bounds checking is not possible. As such the iterator must be valid for at least the number of pixels contained in the SpanSet. Numeric values are also different in that they will not be iterated but the value will be passed to the functor for each point in the SpanSet.

Because a ndarray can either be interpreted as either a two dimensional image, or a one dimensional vector a user must break the ambiguity by using the functions ndarray::ndImage, or ndarray::ndFlat respectively.

The functor object must operate in-place on any data, no return values are captured. No exceptions are handled, if a functor throws one it will propagate back out of the applyFunctor call, possibly leaving the output array in an incomplete state. The first argument of the functor must be a lsst::geom::Point2I which will be the point in the SpanSet where the operation is occurring. All the remaining arguments to the functor will be individual values generated from the input arguments. For two dimensional types (Image, MaskedImage, ndarray) arguments will be the value taken from the input type at the location given by the SpanSet. I.e. if the SpanSet has the point (2,3) in it, then a 2 dimensional ndarray will have ndarray[2][3] passed to the functor. Thus all SpanSet coordinates must be addressable in two dimensional types. For one dimensional types (ndarray, iterator) arguments will correspond to the value at the location defined by number of pixels which have been iterated over. I.e. if there are 3 pixels defined in the SpanSet a one dimensional ndarray will have the value ndarray[0] passed to the functor on on the first functor call, ndarray[1] passed on the second call, and ndarray[2] passed on the last functor call. The total length of a one dimensional type will be equal to the area of the SpanSet, and therefore the data-type must be at least that length. The order of the parameters supplied to the functor will be the same order as they are passed to the applyFunctor method.

Template Parameters
...ArgsVariadic type specification
Parameters
funcFunctor that is to be applied on each of the values taken from ...args.
...argsVariadic arguments, may be of type Image, MaskedImage, ndarrays, numeric values and iterators. ndarrays must be specified as either image or vector with the ndarray::ndImage or ndarray::ndFlat functions

Definition at line 512 of file SpanSet.h.

512  {
513  /* Use a variadic template to take a functor object, and an arbitrary number
514  of parameters. For each of the arguments, construct a Getter class using
515  a function (makeGetter) which is overloaded to all the types applyFunctorImpl
516  supports: Images, MaskedImages, Exposures, ndarrays, numeric values, and
517  iterators. The functor and the getters are then passed to the implementation of
518  applyFunctor where the values of the input arguments are intelligently
519  generated at each point in SpanSet, and passed to the functor object for evaluation.
520  */
521  applyFunctorImpl(func, details::makeGetter(args)...);
522  }

◆ back()

const_reference lsst::afw::geom::SpanSet::back ( ) const
inline

Definition at line 93 of file SpanSet.h.

93 { return const_cast<geom::Span &>(_spanVector.back()); }

◆ begin()

const_iterator lsst::afw::geom::SpanSet::begin ( ) const
inline

Definition at line 88 of file SpanSet.h.

88 { return _spanVector.cbegin(); }

◆ cbegin()

const_iterator lsst::afw::geom::SpanSet::cbegin ( ) const
inline

Definition at line 90 of file SpanSet.h.

90 { return _spanVector.cbegin(); }

◆ cend()

const_iterator lsst::afw::geom::SpanSet::cend ( ) const
inline

Definition at line 91 of file SpanSet.h.

91 { return _spanVector.cend(); }

◆ clearMask()

template<typename T >
void lsst::afw::geom::SpanSet::clearMask ( lsst::afw::image::Mask< T > &  target,
bitmask 
) const

Unset a Mask at pixels defined by the SpanSet.

Template Parameters
Tdata-type of a pixel in the Mask plane
Parameters
[in,out]targetMask in which a bit pattern will be unset
[in]bitmaskThe bit pattern to clear in the mask

Definition at line 940 of file SpanSet.cc.

940  {
941  // Use a lambda to clear bits in a mask at the locations given by SpanSet
942  auto targetArray = target.getArray();
943  auto xy0 = target.getBBox().getMin();
944  auto clearMaskFunctor = [](lsst::geom::Point2I const& point,
946  T bitmask) { maskVal &= ~bitmask; };
947  applyFunctor(clearMaskFunctor, ndarray::ndImage(targetArray, xy0), bitmask);
948 }

◆ clippedTo()

std::shared_ptr< SpanSet > lsst::afw::geom::SpanSet::clippedTo ( lsst::geom::Box2I const &  box) const

Return a new SpanSet which has all pixel values inside specified box.

Parameters
boxInteger box specifying the bounds for which all pixels must be within

Definition at line 440 of file SpanSet.cc.

440  {
441  /* Return a copy of the current SpanSet but only with values which are contained within
442  * the supplied box
443  */
444  std::vector<Span> tempVec;
445  for (auto const& spn : _spanVector) {
446  if (spn.getY() >= box.getMinY() && spn.getY() <= box.getMaxY() &&
447  spansOverlap(spn, Span(spn.getY(), box.getMinX(), box.getMaxX()))) {
448  tempVec.push_back(Span(spn.getY(), std::max(box.getMinX(), spn.getMinX()),
449  std::min(box.getMaxX(), spn.getMaxX())));
450  }
451  }
452  return std::make_shared<SpanSet>(std::move(tempVec), false);
453 }

◆ computeCentroid()

lsst::geom::Point2D lsst::afw::geom::SpanSet::computeCentroid ( ) const

Compute the point about which the SpanSet's first moment is zero.

Definition at line 503 of file SpanSet.cc.

503  {
504  // Find the centroid of the SpanSet
505  std::size_t n = 0;
506  double xc = 0, yc = 0;
507  for (auto const& spn : _spanVector) {
508  int const y = spn.getY();
509  int const x0 = spn.getMinX();
510  int const x1 = spn.getMaxX();
511  int const npix = x1 - x0 + 1;
512 
513  n += npix;
514  xc += npix * 0.5 * (x1 + x0);
515  yc += npix * y;
516  }
517  assert(n == _area);
518 
519  return lsst::geom::Point2D(xc / _area, yc / _area);
520 }

◆ computeShape()

ellipses::Quadrupole lsst::afw::geom::SpanSet::computeShape ( ) const

Compute the shape parameters for the distribution of points in the SpanSet.

Definition at line 522 of file SpanSet.cc.

522  {
523  // Compute the shape of the SpanSet
525  double const xc = cen.getX();
526  double const yc = cen.getY();
527 
528  double sumxx = 0, sumxy = 0, sumyy = 0;
529  for (auto const& spn : _spanVector) {
530  int const y = spn.getY();
531  int const x0 = spn.getX0();
532  int const x1 = spn.getX1();
533  int const npix = x1 - x0 + 1;
534 
535  for (int x = x0; x <= x1; ++x) {
536  sumxx += (x - xc) * (x - xc);
537  }
538  sumxy += npix * (0.5 * (x1 + x0) - xc) * (y - yc);
539  sumyy += npix * (y - yc) * (y - yc);
540  }
541 
542  return ellipses::Quadrupole(sumxx / _area, sumyy / _area, sumxy / _area);
543 }

◆ contains() [1/2]

bool lsst::afw::geom::SpanSet::contains ( lsst::geom::Point2I const &  point) const

Check if a point is contained within the SpanSet instance.

Parameters
pointAn integer point object for which membership is to be tested

Definition at line 493 of file SpanSet.cc.

493  {
494  // Check to see if a given point is found within any spans in this
495  for (auto& spn : _spanVector) {
496  if (spn.contains(point)) {
497  return true;
498  }
499  }
500  return false;
501 }

◆ contains() [2/2]

bool lsst::afw::geom::SpanSet::contains ( SpanSet const &  other) const

Check if a SpanSet instance entirely contains another SpanSet.

Parameters
otherThe SpanSet who's membership is to be tested for

Definition at line 467 of file SpanSet.cc.

467  {
468  // Handle null SpanSet passed as other
469  if (other.empty()) {
470  return false;
471  }
472  // Function to check if a SpanSet is entirely contained within this
473  for (auto const& otherSpn : other) {
474  std::size_t counter = 0;
475  for (auto const& spn : _spanVector) {
476  // Check that the end points of the span from other are contained in the
477  // span from this
478  if (spn.contains(lsst::geom::Point2I(otherSpn.getMinX(), otherSpn.getY())) &&
479  spn.contains(lsst::geom::Point2I(otherSpn.getMaxX(), otherSpn.getY()))) {
480  ++counter;
481  }
482  }
483  // if counter is equal to zero, then the current span from other is not
484  // contained in any span in this, and the function should return false
485  // short circuiting any other spans from other
486  if (counter == 0) {
487  return false;
488  }
489  }
490  return true;
491 }

◆ copyImage()

template<typename ImageT >
void lsst::afw::geom::SpanSet::copyImage ( image::Image< ImageT > const &  src,
image::Image< ImageT > &  dest 
)
inline

Copy contents of source Image into destination image at the positions defined in the SpanSet.

Template Parameters
ImageTThe pixel type of the Image
Parameters
[in]srcThe Image that pixel values will be taken from
[out]destThe Image where pixels will be copied

Definition at line 416 of file SpanSet.h.

416  {
417  auto copyFunc = [](lsst::geom::Point2I const &point, ImageT const &srcPix, ImageT &destPix) {
418  destPix = srcPix;
419  };
420  applyFunctor(copyFunc, src, dest);
421  }

◆ copyMaskedImage()

template<typename ImageT , typename MaskT , typename VarT >
void lsst::afw::geom::SpanSet::copyMaskedImage ( image::MaskedImage< ImageT, MaskT, VarT > const &  src,
image::MaskedImage< ImageT, MaskT, VarT > &  dest 
)
inline

Copy contents of source MaskedImage into destination image at the positions defined in the SpanSet.

Template Parameters
ImageTThe pixel type of the MaskedImage's Image
MaskTThe pixel type of the MaskedImage's Mask
VarTThe Pixel type of the MaskedImage's Variance Image
Parameters
[in]srcThe MaskedImage that pixel values will be taken from
[out]destThe MaskedImage where pixels will be copied

Definition at line 433 of file SpanSet.h.

434  {
435  auto copyFunc = [](lsst::geom::Point2I const &point, ImageT const &srcPix, MaskT const &srcMask,
436  VarT const &srcVar, ImageT &destPix, MaskT &destMask, VarT &destVar) {
437  destPix = srcPix;
438  destMask = srcMask;
439  destVar = srcVar;
440  };
441  applyFunctor(copyFunc, *(src.getImage()), *(src.getMask()), *(src.getVariance()), *(dest.getImage()),
442  *(dest.getMask()), *(dest.getVariance()));
443  }

◆ dilated() [1/2]

std::shared_ptr< SpanSet > lsst::afw::geom::SpanSet::dilated ( int  r,
Stencil  s = Stencil::CIRCLE 
) const

Perform a set dilation operation, and return a new object.

Dilate a SpanSet with a kernel specified with the stencil parameter

Parameters
rradius of the stencil, the length is inclusive i.e. 3 ranges from -3 to 3
smust be an enumeration of type geom::Stencil. Specifies the shape of the dilation kernel. May be CIRCLE, MANHATTAN, or BOX

Definition at line 545 of file SpanSet.cc.

545  {
546  // Return a dilated SpanSet made with the given stencil, by creating a SpanSet
547  // from the stencil and forwarding to the appropriate overloaded method
548  std::shared_ptr<SpanSet> stencilToSpanSet = fromShape(r, s);
549  return dilated(*stencilToSpanSet);
550 }

◆ dilated() [2/2]

std::shared_ptr< SpanSet > lsst::afw::geom::SpanSet::dilated ( SpanSet const &  other) const

Perform a set dilation operation, and return a new object.

Dilate a SpanSet with a kernel specified by another SpanSet

Parameters
otherA SpanSet which specifies the kernel to use for dilation

Definition at line 552 of file SpanSet.cc.

552  {
553  // Handle a null SpanSet nothing should be dilated
554  if (other.size() == 0) {
555  return std::make_shared<SpanSet>(_spanVector.begin(), _spanVector.end(), false);
556  }
557 
558  // Return a dilated Spanset by the given SpanSet
559  std::vector<Span> tempVec;
560 
561  for (auto const& spn : _spanVector) {
562  for (auto const& otherSpn : other) {
563  int const xmin = spn.getMinX() + otherSpn.getMinX();
564  int const xmax = spn.getMaxX() + otherSpn.getMaxX();
565  int const yval = spn.getY() + otherSpn.getY();
566  tempVec.push_back(Span(yval, xmin, xmax));
567  }
568  }
569  // Allow constructor to handle merging adjacent and overlapping spans
570  return std::make_shared<SpanSet>(std::move(tempVec));
571 }

◆ dynamicCast()

Dynamically cast a shared_ptr.

Dynamically cast a shared pointer and raise on failure.

You must provide an explicit template instantiation in the .cc file for each class that inherits from PersistableFacade. Designed to work around RTTI issues on macOS with hidden symbols;

Exceptions
lsst::pex::exceptions::LogicErrorif the cast fails

param[in] ptr The pointer to be cast.

Returns
The cast pointer.
Exceptions
lsst::pex::exceptions::TypeErrorIf the dynamic cast fails.

Definition at line 218 of file Persistable.cc.

18  {
19  auto result = std::dynamic_pointer_cast<T>(ptr);
20  if (!result) {
21  throw LSST_EXCEPT(pex::exceptions::TypeError, "Dynamic pointer cast failed");
22  }
23  return result;
24 }

◆ empty()

bool lsst::afw::geom::SpanSet::empty ( ) const
inline

Definition at line 95 of file SpanSet.h.

95 { return _spanVector.empty(); }

◆ end()

const_iterator lsst::afw::geom::SpanSet::end ( ) const
inline

Definition at line 89 of file SpanSet.h.

89 { return _spanVector.cend(); }

◆ eroded() [1/2]

std::shared_ptr< SpanSet > lsst::afw::geom::SpanSet::eroded ( int  r,
Stencil  s = Stencil::CIRCLE 
) const

Perform a set erosion, and return a new object.

Erode a SpanSet with a kernel specified with the stencil parameter

Parameters
rradius of the stencil, the length is inclusive i.e. 3 ranges from -3 to 3
smust be an enumeration of type geom::Stencil. Specifies the shape of the erosion kernel. May be CIRCLE, MANHATTAN, or BOX

Definition at line 573 of file SpanSet.cc.

573  {
574  // Return an eroded SpanSet made with the given stencil, by creating a SpanSet
575  // from the stencil and forwarding to the appropriate overloaded method
576  std::shared_ptr<SpanSet> stencilToSpanSet = fromShape(r, s);
577  return eroded(*stencilToSpanSet);
578 }

◆ eroded() [2/2]

std::shared_ptr< SpanSet > lsst::afw::geom::SpanSet::eroded ( SpanSet const &  other) const

Perform a set erosion operation, and return a new object.

Erode a SpanSet with a kernel specified by another SpanSet

Parameters
otherA SpanSet which specifies the kernel to use for erosion

Definition at line 580 of file SpanSet.cc.

580  {
581  // Handle a null SpanSet nothing should be eroded
582  if (other.size() == 0 || this->size() == 0) {
583  return std::make_shared<SpanSet>(_spanVector.begin(), _spanVector.end(), false);
584  }
585 
586  // Return a SpanSet eroded by the given SpanSet
587  std::vector<Span> tempVec;
588 
589  // Calculate all possible primary runs.
590  std::vector<PrimaryRun> primaryRuns;
591  for (auto const& spn : _spanVector) {
592  int m = 0;
593  for (auto const& otherSpn : other) {
594  if ((otherSpn.getMaxX() - otherSpn.getMinX()) <= (spn.getMaxX() - spn.getMinX())) {
595  int xmin = spn.getMinX() - otherSpn.getMinX();
596  int xmax = spn.getMaxX() - otherSpn.getMaxX();
597  int y = spn.getY() - otherSpn.getY();
598  primaryRuns.push_back(PrimaryRun({m, y, xmin, xmax}));
599  }
600  ++m;
601  }
602  }
603 
604  // Iterate over the primary runs in such a way that we consider all values of m
605  // for a given y, then all m for y+1 etc.
606  std::sort(primaryRuns.begin(), primaryRuns.end(), comparePrimaryRun);
607 
608  for (int y = primaryRuns.front().y; y <= primaryRuns.back().y; ++y) {
609  auto yRange = std::equal_range(primaryRuns.begin(), primaryRuns.end(), y, ComparePrimaryRunY());
610 
611  /* Discard runs for any value of y for which we find fewer groups than M,
612  * the total Y range of the structuring element. This is step 3.1 of the
613  * Kim et al. algorithm.
614  */
615  // Plus one because end points are inclusive
616  auto otherYRange = other.back().getY() - other.front().getY() + 1;
617  if (std::distance(yRange.first, yRange.second) < otherYRange) {
618  continue;
619  }
620 
621  /* "good" runs are those which are covered by each value of m, ie by each
622  * row in the structuring element. Our algorithm will consider each value
623  * of m in turn, gradually whittling down the list of good runs, then
624  * finally convert the remainder into Spans.
625  */
626  std::list<PrimaryRun> goodRuns;
627 
628  for (int m = 0; m < otherYRange; ++m) {
629  auto mRange = std::equal_range(yRange.first, yRange.second, m, ComparePrimaryRunM());
630  if ((mRange.first == mRange.second)) {
631  // If a particular m is missing, we known that this y contains
632  // no good runs; this is equivalent to Kim et al. step 3.2.
633  goodRuns.clear();
634  } else {
635  // Consolidate all primary runs at this m so that they don't overlap.
636  std::list<PrimaryRun> candidateRuns;
637  int startX = mRange.first->xmin;
638  int endX = mRange.first->xmax;
639  for (auto run = mRange.first + 1; run != mRange.second; ++run) {
640  if (run->xmin > endX) {
641  // Start of a new run
642  candidateRuns.push_back(PrimaryRun{m, y, startX, endX});
643  startX = run->xmin;
644  endX = run->xmax;
645  } else {
646  // Continuation of an existing run
647  endX = run->xmax;
648  }
649  }
650  candidateRuns.push_back(PrimaryRun{m, y, startX, endX});
651 
652  // Otherwise, calculate the intersection of candidate runs at
653  // this m with good runs from all previous m.
654  if (m == 0) {
655  // For m = 0 we have nothing to compare to; all runs are accepted
656  std::swap(goodRuns, candidateRuns);
657  } else {
658  std::list<PrimaryRun> newlist;
659  for (auto& good : goodRuns) {
660  for (auto& cand : candidateRuns) {
661  int start = std::max(good.xmin, cand.xmin);
662  int end = std::min(good.xmax, cand.xmax);
663  if (end >= start) {
664  newlist.push_back(PrimaryRun({m, y, start, end}));
665  }
666  }
667  }
668  std::swap(newlist, goodRuns);
669  }
670  }
671  }
672  for (auto& run : goodRuns) {
673  tempVec.push_back(Span(run.y, run.xmin, run.xmax));
674  }
675  }
676  return std::make_shared<SpanSet>(std::move(tempVec));
677 }

◆ findEdgePixels()

std::shared_ptr< SpanSet > lsst::afw::geom::SpanSet::findEdgePixels ( ) const

Select pixels within the SpanSet which touch its edge.

Definition at line 412 of file SpanSet.cc.

412  {
414  setMask(tempMask, static_cast<image::MaskPixel>(1));
415  auto erodedSpanSet = eroded(1, Stencil::CIRCLE);
416  erodedSpanSet->clearMask(tempMask, static_cast<image::MaskPixel>(1));
417  return SpanSet::fromMask(tempMask);
418 }

◆ flatten() [1/2]

template<typename Pixel , int inN, int inC>
ndarray::Array<typename std::remove_const<Pixel>::type, inN - 1, inN - 1> lsst::afw::geom::SpanSet::flatten ( ndarray::Array< Pixel, inN, inC > const &  input,
lsst::geom::Point2I const &  xy0 = lsst::geom::Point2I() 
) const
inline

Reduce the pixel dimensionality from 2 to 1 of an array at points given by SpanSet.

Take values from an array at points defined by SpanSet and use them to populate a new array where the x,y coordinates of the SpanSet have been flattened to one dimension. First two dimensions of the input array must be the h,w which correspond to the SpanSet coordinates. Any number of remaining dimensions is permissible.

Template Parameters
PixelThe datatype for the ndarray
inNThe number of dimensions in the array object
inCNumber of guaranteed row-major contiguous dimensions, starting from the end
Parameters
inputThe ndarray from which the values will be taken
xy0A point object with is used as the origin point for the SpanSet coordinate system

Definition at line 303 of file SpanSet.h.

305  {
306  // Populate a lower dimensional array with the values from input taken at the points of SpanSet
307  auto outputShape = ndarray::concatenate(ndarray::makeVector(getArea()),
308  input.getShape().template last<inN - 2>());
309  ndarray::Array<typename std::remove_const<Pixel>::type, inN - 1, inN - 1> outputArray =
310  ndarray::allocate(outputShape);
311  outputArray.deep() = 0;
312  flatten(outputArray, input, xy0);
313  return outputArray;
314  }

◆ flatten() [2/2]

template<typename PixelIn , typename PixelOut , int inA, int outC, int inC>
void lsst::afw::geom::SpanSet::flatten ( ndarray::Array< PixelOut, inA - 1, outC > const &  output,
ndarray::Array< PixelIn, inA, inC > const &  input,
lsst::geom::Point2I const &  xy0 = lsst::geom::Point2I() 
) const
inline

Reduce the pixel dimensionality from 2 to 1 of an array at points given by SpanSet.

Take values from an array at points defined by SpanSet and use them to populate a new array where the x,y coordinates of the SpanSet have been flattened to one dimension. First two dimensions of the input array must be the h,w which correspond to the SpanSet coordinates. Any number of remaining dimensions is permissible.

Template Parameters
PixelOutThe data-type for the output ndarray
PixelInThe data-type for the input ndarray
inAThe number of dimensions in the input array
outCNumber of guaranteed row-major contiguous dimensions in the output array, starting from the end
inCNumber of guaranteed row-major contiguous dimensions in the input array, starting from the end
Parameters
[out]outputThe 1d ndarray which will be populated with output parameters, will happen in place
[in]inputThe ndarray from which the values will be taken
[in]xy0A point object which is used as the origin point for the SpanSet coordinate system

Definition at line 336 of file SpanSet.h.

338  {
339  auto ndAssigner = [](lsst::geom::Point2I const &point,
340  typename details::FlatNdGetter<PixelOut, inA - 1, outC>::Reference out,
341  typename details::ImageNdGetter<PixelIn, inA, inC>::Reference in) { out = in; };
342  // Populate array output with values from input at positions given by SpanSet
343  applyFunctor(ndAssigner, ndarray::ndFlat(output), ndarray::ndImage(input, xy0));
344  }

◆ fromMask() [1/2]

template<typename T >
static std::shared_ptr<geom::SpanSet> lsst::afw::geom::SpanSet::fromMask ( image::Mask< T > const &  mask,
bitmask 
)
inlinestatic

Create a SpanSet from a mask.

Create a SpanSet from a Mask at pixels with the specified bit pattern

Template Parameters
TPixel type of the Mask
Parameters
maskmask to convert to a SpanSet
bitmaskbit pattern used to specify which pixel to include

Definition at line 701 of file SpanSet.h.

701  {
702  return fromMask(mask, [bitmask](T const &bitPattern) { return bitPattern & bitmask; });
703  }

◆ fromMask() [2/2]

template<typename T , typename UnaryPredicate = details::AnyBitSetFunctor<T>>
static std::shared_ptr<geom::SpanSet> lsst::afw::geom::SpanSet::fromMask ( image::Mask< T > const &  mask,
UnaryPredicate  comparator = details::AnyBitSetFunctor<T>() 
)
inlinestatic

Create a SpanSet from a mask.

Create a SpanSet from a class. The default behavior is to include any pixels which have any bits set. More complex selection/filtering of bit patterns can be done by supplying a comparator function.

Template Parameters
TPixel type of the Mask
FType of the functor
Parameters
maskmask to convert to a SpanSet
comparatorFunctor object to use in the decision to include pixel in SpanSet. Should return true when a given pixel in the mask should be part of the SpanSet, and false otherwise. The functor takes a single value taken from the mask at the pixel under consideration. Defaults to evaluating true if the mask has bits set, and false otherwise.

Definition at line 644 of file SpanSet.h.

645  {
646  // Create a vector which will hold all the spans created from the mask
647  std::vector<Span> tempVec;
648  // Grab some variables that will be used in the loop, so that they do not need to be fetched
649  // every iteration.
650  auto const maskArray = mask.getArray();
651  auto const minPoint = mask.getBBox().getMin();
652  auto const dimensions = maskArray.getShape();
653  auto const minY = minPoint.getY();
654  auto const minX = minPoint.getX();
655  auto const dimMinusOne = dimensions[1] - 1;
656  auto const yDim = dimensions[0];
657  auto const xDim = dimensions[1];
658  auto arrIter = maskArray.begin();
659  for (size_t y = 0; y < yDim; ++y) {
660  auto yWithOffset = y + minY;
661  bool inSpan = false; // are we currently in a span of interest?
662  std::size_t start; // starting x value of span we're currently in
663  for (size_t x = 0; x < xDim; ++x) {
664  bool compareValue = comparator((*arrIter)[x]);
665  if (inSpan) {
666  // If we were in a span but now the condition isn't satisfied, it means the Span stops
667  // at the previous pixel.
668  if (!compareValue) {
669  tempVec.push_back(Span(yWithOffset, start + minX, x - 1 + minX));
670  inSpan = false;
671  }
672  } else if (compareValue) {
673  // If we weren't in a span but now the condition is satisfied, we start a new span.
674  inSpan = true;
675  start = x;
676  }
677  }
678  // Since the x loop is over, if we're still in a span, this means the Span was not
679  // closed out and added to the vector. The last pixel should be included in the Span
680  // and the Span should be closed and added to the vector of spans.
681  if (inSpan) {
682  tempVec.push_back(Span(yWithOffset, start + minX, dimMinusOne + minX));
683  }
684  ++arrIter;
685  }
686 
687  // construct a SpanSet from the spans determined above
688  return std::make_shared<SpanSet>(std::move(tempVec), false);
689  }

◆ fromShape() [1/2]

std::shared_ptr< SpanSet > lsst::afw::geom::SpanSet::fromShape ( geom::ellipses::Ellipse const &  ellipse)
static

Factory function for creating SpanSets from an ellipse object.

Parameters
ellipseAn ellipse defining the region to create a SpanSet from

Definition at line 716 of file SpanSet.cc.

716  {
717  ellipses::PixelRegion pr(ellipse);
718  return std::make_shared<SpanSet>(pr.begin(), pr.end());
719 }

◆ fromShape() [2/2]

std::shared_ptr< SpanSet > lsst::afw::geom::SpanSet::fromShape ( int  r,
Stencil  s = Stencil::CIRCLE,
lsst::geom::Point2I  offset = lsst::geom::Point2I() 
)
static

Factory function for creating SpanSets from a Stencil.

Parameters
rradius of the stencil, the length is inclusive i.e. 3 ranges from -3 to 3
smust be an enumeration of type geom::Stencil. Specifies the shape of the newly created SpanSet. May be CIRCLE, MANHATTAN, or BOX
offsetThis function usually creates a SpanSet centered about zero. This parameter is a point2I object which specifies an offset from zero to apply when creating the SpanSet.

Definition at line 689 of file SpanSet.cc.

689  {
690  // Create a SpanSet from a given Stencil
691  std::vector<Span> tempVec;
692  tempVec.reserve(2 * r + 1);
693  switch (s) {
694  case Stencil::CIRCLE:
695  for (auto dy = -r; dy <= r; ++dy) {
696  int dx = static_cast<int>(sqrt(r * r - dy * dy));
697  tempVec.push_back(Span(dy + offset.getY(), -dx + offset.getX(), dx + offset.getX()));
698  }
699  break;
700  case Stencil::MANHATTAN:
701  for (auto dy = -r; dy <= r; ++dy) {
702  int dx = r - abs(dy);
703  tempVec.push_back(Span(dy + offset.getY(), -dx + offset.getX(), dx + offset.getX()));
704  }
705  break;
706  case Stencil::BOX:
707  for (auto dy = -r; dy <= r; ++dy) {
708  int dx = r;
709  tempVec.push_back(Span(dy + offset.getY(), -dx + offset.getX(), dx + offset.getX()));
710  }
711  break;
712  }
713  return std::make_shared<SpanSet>(std::move(tempVec), false);
714 }

◆ front()

const_reference lsst::afw::geom::SpanSet::front ( ) const
inline

Definition at line 92 of file SpanSet.h.

92 { return const_cast<geom::Span &>(_spanVector.front()); }

◆ getArea()

std::size_t lsst::afw::geom::SpanSet::getArea ( ) const

Return the number of pixels in the SpanSet.

Definition at line 284 of file SpanSet.cc.

284 { return _area; }

◆ getBBox()

lsst::geom::Box2I lsst::afw::geom::SpanSet::getBBox ( ) const

Return a new integer box which is the minimum size to contain the pixels.

Definition at line 287 of file SpanSet.cc.

287 { return _bbox; }

◆ intersect() [1/2]

template<typename T >
std::shared_ptr< SpanSet > lsst::afw::geom::SpanSet::intersect ( image::Mask< T > const &  other,
bitmask 
) const

Determine the common points between a SpanSet and a Mask with a given bit pattern.

Template Parameters
TPixel type of the Mask
Parameters
otherMask with which to calculate intersection
bitmaskThe bit value to consider when intersecting

Definition at line 951 of file SpanSet.cc.

951  {
952  return maskIntersect<T, false>(*this, other, bitmask);
953 }

◆ intersect() [2/2]

std::shared_ptr< SpanSet > lsst::afw::geom::SpanSet::intersect ( SpanSet const &  other) const

Determine the common points between two SpanSets, and create a new SpanSet.

Parameters
otherThe other SpanSet with which to intersect with

Definition at line 721 of file SpanSet.cc.

721  {
722  // Check if the bounding boxes overlap, if not return null SpanSet
723  if (!_bbox.overlaps(other.getBBox())) {
724  return std::make_shared<SpanSet>();
725  }
726  // Handel intersecting a SpanSet with itself
727  if (other == *this) {
728  return std::make_shared<SpanSet>(this->_spanVector);
729  }
730  std::vector<Span> tempVec;
731  auto otherIter = other.begin();
732  for (auto const& spn : _spanVector) {
733  while (otherIter != other.end() && otherIter->getY() <= spn.getY()) {
734  if (spansOverlap(spn, *otherIter)) {
735  auto newMin = std::max(spn.getMinX(), otherIter->getMinX());
736  auto newMax = std::min(spn.getMaxX(), otherIter->getMaxX());
737  auto newSpan = Span(spn.getY(), newMin, newMax);
738  tempVec.push_back(newSpan);
739  }
740  ++otherIter;
741  }
742  }
743  return std::make_shared<SpanSet>(std::move(tempVec));
744 }

◆ intersectNot() [1/2]

template<typename T >
std::shared_ptr< SpanSet > lsst::afw::geom::SpanSet::intersectNot ( image::Mask< T > const &  other,
bitmask 
) const

Determine the common points between a SpanSet and the logical inverse of a Mask for a given bit pattern.

Parameters
otherMask with which to calculate intersection
bitmaskThe bit value to consider when intersecting
Template Parameters
TPixel type of the Mask

Definition at line 956 of file SpanSet.cc.

956  {
957  return maskIntersect<T, true>(*this, other, bitmask);
958 }

◆ intersectNot() [2/2]

std::shared_ptr< SpanSet > lsst::afw::geom::SpanSet::intersectNot ( SpanSet const &  other) const

Determine the common points between a SpanSet and the logical inverse of a second SpanSet and return them in a new SpanSet.

Parameters
otherThe spanset which will be logically inverted when computing the intersection

Definition at line 746 of file SpanSet.cc.

746  {
747  // Check if the bounding boxes overlap, if not simply return a copy of this
748  if (!getBBox().overlaps(other.getBBox())) {
749  return std::make_shared<SpanSet>(this->begin(), this->end());
750  }
751  // Handle calling a SpanSet's intersectNot with itself as an argument
752  if (other == *this) {
753  return std::make_shared<SpanSet>();
754  }
755  /* This function must find all the areas in this and not in other. These SpanSets
756  * may be overlapping with this less than other a1| b1| a2| b2|,
757  * with this greater than other b1| a1| b2| a2|,
758  * with this containing other a1| b1| b2| a2|,
759  * or with other containing this b1| a1| a2| b2|
760  */
761  std::vector<Span> tempVec;
762  auto otherIter = other.begin();
763  for (auto const& spn : _spanVector) {
764  bool added = false;
765  bool spanStarted = false;
766  int spanBottom = 0;
767  while (otherIter != other.end() && otherIter->getY() <= spn.getY()) {
768  if (spansOverlap(spn, *otherIter)) {
769  added = true;
770  /* To handle one span containing the other, the spans will be added
771  * piecewise, and let the SpanSet constructor normalize spans which
772  * end up contiguous. In the case where this is contained in other,
773  * these statements will all be false, and nothing will be added,
774  * which is the expected behavior.
775  *
776  * Intersection with the logical not of another SpanSet requires that the Intersection
777  * be tested against the condition that multiple Spans may be present in the other
778  * SpanSet at the same Y coordinate. I.E. If one row in *this would contain two
779  * disconnected Spans in other, the result should be three new Spans.
780  */
781  // Check if a span is in the process of being created
782  if (!spanStarted) {
783  // If the minimum value of the Span in *this is less than that of other, add a new Span
784  if (spn.getMinX() < otherIter->getMinX()) {
785  tempVec.push_back(Span(spn.getY(), spn.getMinX(), otherIter->getMinX() - 1));
786  }
787  // Conversely if the maximum value of the Span in *this is greater than that of other,
788  // Start a new span, and record what the minimum value of that span should be. This is
789  // because SpanSets can be disconnected, and the function must check if there are any
790  // additional Spans which fall in the same row
791  if (spn.getMaxX() > otherIter->getMaxX()) {
792  spanStarted = true;
793  spanBottom = otherIter->getMaxX() + 1;
794  }
795  } else {
796  // A span is in the process of being created and should be finished and added
797  tempVec.push_back(
798  Span(spn.getY(), spanBottom, std::min(spn.getMaxX(), otherIter->getMinX() - 1)));
799  spanStarted = false;
800  // Check if the span in *this extends past that of the Span from other, if so
801  // begin a new Span
802  if (spn.getMaxX() > otherIter->getMaxX()) {
803  spanStarted = true;
804  spanBottom = otherIter->getMaxX() + 1;
805  }
806  }
807  }
808  if (otherIter->getMaxX() > spn.getMaxX()) {
809  break;
810  }
811  ++otherIter;
812  }
813  // Check if a span has been started but not finished, if that is the case that means there are
814  // no further spans on this row to consider and the span should be closed and added
815  if (spanStarted) {
816  tempVec.push_back(Span(spn.getY(), spanBottom, spn.getMaxX()));
817  }
818  /* If added is still zero, that means it did not overlap any of the spans in other
819  * and should be included in the new span
820  */
821  if (!added) {
822  tempVec.push_back(Span(spn));
823  }
824  }
825  return std::make_shared<SpanSet>(std::move(tempVec));
826 }

◆ isContiguous()

bool lsst::afw::geom::SpanSet::isContiguous ( ) const

Defines if the SpanSet is simply contiguous.

If the pixels can be traversed in such a way that every pixel can be reached without going over a pixel not contained in the SpanSet this method will return true. If the SpanSet is disjoint aka the above is not true and there is more than one region, returns false.

Definition at line 374 of file SpanSet.cc.

374  {
375  auto labeledPair = _makeLabels();
376  // Here we want to check if there is only one label. Since _makeLabels always increments
377  // at the end of each loop, we need to compare against the number 2. I.e. if everything
378  // gets labeled 1, the label counter will increment to 2, and the if statement will always
379  // be false and _makeLabels will fall through to the end and return to here.
380  return labeledPair.second <= 2;
381 }

◆ isPersistable()

bool lsst::afw::geom::SpanSet::isPersistable ( ) const
inlineoverridevirtualnoexcept

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

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

Definition at line 709 of file SpanSet.h.

709 { return true; }

◆ operator!=()

bool lsst::afw::geom::SpanSet::operator!= ( SpanSet const &  other) const

Definition at line 684 of file SpanSet.cc.

684  {
685  // Check the equivalence of this SpanSet with another
686  return _spanVector != other._spanVector;
687 }

◆ operator=() [1/2]

SpanSet& lsst::afw::geom::SpanSet::operator= ( SpanSet &&  other)
inline

Definition at line 169 of file SpanSet.h.

169 { return *this = other; }

◆ operator=() [2/2]

SpanSet& lsst::afw::geom::SpanSet::operator= ( SpanSet const &  )
default

◆ operator==()

bool lsst::afw::geom::SpanSet::operator== ( SpanSet const &  other) const

Compute equality between two SpanSets.

Parameters
otherThe SpanSet for which equality will be computed

Definition at line 679 of file SpanSet.cc.

679  {
680  // Check the equivalence of this SpanSet with another
681  return _spanVector == other._spanVector;
682 }

◆ overlaps()

bool lsst::afw::geom::SpanSet::overlaps ( SpanSet const &  other) const

Specifies if this SpanSet overlaps with another SpanSet.

Parameters
otherA SpanSet for which overlapping comparison will be made

Definition at line 455 of file SpanSet.cc.

455  {
456  // Function to check if two SpanSets overlap
457  for (auto const& otherSpan : other) {
458  for (auto const& spn : _spanVector) {
459  if (spansOverlap(otherSpan, spn)) {
460  return true;
461  }
462  }
463  }
464  return false;
465 }

◆ readFits() [1/3]

Read an object from an already open FITS object.

Parameters
[in]fitsfileFITS object to read from, already positioned at the desired HDU.

Definition at line 183 of file Persistable.h.

183  {
184  return dynamicCast(Persistable::_readFits(fitsfile));
185  }

◆ readFits() [2/3]

static std::shared_ptr<lsst::afw::geom::SpanSet > lsst::afw::table::io::PersistableFacade< lsst::afw::geom::SpanSet >::readFits ( fits::MemFileManager manager,
int  hdu = fits::DEFAULT_HDU 
)
inlinestaticinherited

Read an object from a FITS file in memory.

Parameters
[in]managerManager for the memory to read from.
[in]hduHDU to read, where 0 is the primary. The special value of afw::fits::DEFAULT_HDU skips the primary HDU if it is empty.

Definition at line 205 of file Persistable.h.

205  {
206  return dynamicCast(Persistable::_readFits(manager, hdu));
207  }

◆ readFits() [3/3]

static std::shared_ptr<lsst::afw::geom::SpanSet > lsst::afw::table::io::PersistableFacade< lsst::afw::geom::SpanSet >::readFits ( std::string const &  fileName,
int  hdu = fits::DEFAULT_HDU 
)
inlinestaticinherited

Read an object from a regular FITS file.

Parameters
[in]fileNameName of the file to read.
[in]hduHDU to read, where 0 is the primary. The special value of afw::fits::DEFAULT_HDU skips the primary HDU if it is empty.

Definition at line 194 of file Persistable.h.

194  {
195  return dynamicCast(Persistable::_readFits(fileName, hdu));
196  }

◆ setImage()

template<typename ImageT >
template void lsst::afw::geom::SpanSet::setImage< double > ( image::Image< ImageT > &  image,
ImageT  val,
lsst::geom::Box2I const &  region = lsst::geom::Box2I(),
bool  doClip = false 
) const

Set the values of an Image at points defined by the SpanSet.

Template Parameters
ImageTThe pixel type of the Image to be set
Parameters
[out]imageThe Image in which pixels will be set
[in]valThe value to set
[in]regionA bounding box limiting the scope of the SpanSet, points defined in the SpanSet which fall outside this box will be ignored if the doClip parameter is set to true, defaults to the bounding box of the image
[in]doClipLimit the copy operation to pixels in the SpanSet that lie within the region parameter defaults to false

Definition at line 906 of file SpanSet.cc.

907  {
909  if (region.isEmpty()) {
910  bbox = image.getBBox();
911  } else {
912  bbox = region;
913  }
914  auto setterFunc = [](lsst::geom::Point2I const& point, ImageT& out, ImageT in) { out = in; };
915  try {
916  if (doClip) {
917  auto tmpSpan = this->clippedTo(bbox);
918  tmpSpan->applyFunctor(setterFunc, image, val);
919  } else {
920  applyFunctor(setterFunc, image, val);
921  }
922  } catch (pex::exceptions::OutOfRangeError const&) {
923  throw LSST_EXCEPT(pex::exceptions::OutOfRangeError,
924  "Footprint Bounds Outside image, set doClip to true");
925  }
926 }

◆ setMask()

template<typename T >
void lsst::afw::geom::SpanSet::setMask ( lsst::afw::image::Mask< T > &  target,
bitmask 
) const

Set a Mask at pixels defined by the SpanSet.

Template Parameters
Tdata-type of a pixel in the Mask plane
Parameters
[in,out]targetMask in which values will be set
[in]bitmaskThe bit pattern to set in the mask

Definition at line 929 of file SpanSet.cc.

929  {
930  // Use a lambda to set bits in a mask at the locations given by SpanSet
931  auto targetArray = target.getArray();
932  auto xy0 = target.getBBox().getMin();
933  auto maskFunctor = [](lsst::geom::Point2I const& point,
935  T bitmask) { maskVal |= bitmask; };
936  applyFunctor(maskFunctor, ndarray::ndImage(targetArray, xy0), bitmask);
937 }

◆ shiftedBy() [1/2]

std::shared_ptr< SpanSet > lsst::afw::geom::SpanSet::shiftedBy ( int  x,
int  y 
) const

Return a new SpanSet shifted by specified amount.

Parameters
xnumber of pixels to shift in x dimension
ynumber of pixels to shift in y dimension

Definition at line 420 of file SpanSet.cc.

420  {
421  // Function to create a new SpanSet which is a copy of this, shifted by x and y
422  return makeShift(x, y);
423 }

◆ shiftedBy() [2/2]

std::shared_ptr< SpanSet > lsst::afw::geom::SpanSet::shiftedBy ( lsst::geom::Extent2I const &  offset) const

Return a new SpanSet shifted by specified amount.

Parameters
offsetinteger extent which specifies amount to offset in x and y

Definition at line 425 of file SpanSet.cc.

425  {
426  // Function to create a new SpanSet which is a copy of this, shifted by an extent object
427  return makeShift(offset.getX(), offset.getY());
428 }

◆ size()

size_type lsst::afw::geom::SpanSet::size ( ) const
inline

Definition at line 94 of file SpanSet.h.

94 { return _spanVector.size(); }

◆ split()

std::vector< std::shared_ptr< SpanSet > > lsst::afw::geom::SpanSet::split ( ) const

Split a discontinuous SpanSet into multiple SpanSets which are contiguous.

Definition at line 383 of file SpanSet.cc.

383  {
384  auto labeledPair = _makeLabels();
385  auto labels = labeledPair.first;
386  auto numberOfLabels = labeledPair.second;
388  // As the number of labels is known, the number of SpanSets to be created is also known
389  // make a vector of vectors to hold the Spans which will correspond to each SpanSet
390  std::vector<std::vector<Span>> subSpanLists(numberOfLabels - 1);
391 
392  // if numberOfLabels is 1, that means a null SpanSet is being operated on,
393  // and we should return like
394  if (numberOfLabels == 1) {
395  subRegions.push_back(std::make_shared<SpanSet>());
396  return subRegions;
397  }
398  subRegions.reserve(numberOfLabels - 1);
399 
400  // loop over the current SpanSet's spans sorting each of the spans according to the label
401  // that was assigned
402  for (std::size_t i = 0; i < _spanVector.size(); ++i) {
403  subSpanLists[labels[i] - 1].push_back(_spanVector[i]);
404  }
405  // Transform each of the vectors of Spans into a SpanSet
406  for (std::size_t i = 0; i < numberOfLabels - 1; ++i) {
407  subRegions.push_back(std::make_shared<SpanSet>(subSpanLists[i]));
408  }
409  return subRegions;
410 }

◆ transformedBy() [1/3]

std::shared_ptr< SpanSet > lsst::afw::geom::SpanSet::transformedBy ( lsst::geom::AffineTransform const &  t) const

Return a new SpanSet who's pixels are the product of applying the specified transformation.

Parameters
tAn affine transform object which will be used to map the pixels

Definition at line 847 of file SpanSet.cc.

847  {
848  // Transform points in SpanSet by the AffineTransform
849  return transformedBy(*makeTransform(t));
850 }

◆ transformedBy() [2/3]

std::shared_ptr< SpanSet > lsst::afw::geom::SpanSet::transformedBy ( lsst::geom::LinearTransform const &  t) const

Return a new SpanSet who's pixels are the product of applying the specified transformation.

Parameters
tA linear transform object which will be used to map the pixels

Definition at line 842 of file SpanSet.cc.

842  {
843  // Transform points in SpanSet by the LinearTransform
845 }

◆ transformedBy() [3/3]

std::shared_ptr< SpanSet > lsst::afw::geom::SpanSet::transformedBy ( TransformPoint2ToPoint2 const &  t) const

Return a new SpanSet who's pixels are the product of applying the specified transformation.

Parameters
tA 2-D transform which will be used to map the pixels

Definition at line 852 of file SpanSet.cc.

852  {
853  // Transform points in SpanSet by Transform<Point2Endpoint, Point2Endpoint>
854  // Transform the original bounding box
855  lsst::geom::Box2D newBBoxD;
857  fromCorners.reserve(4);
858  for (auto const& fc : _bbox.getCorners()) {
859  fromCorners.emplace_back(lsst::geom::Point2D(fc));
860  }
861  auto toPoints = t.applyForward(fromCorners);
862  for (auto const& tc : toPoints) {
863  newBBoxD.include(tc);
864  }
865 
866  lsst::geom::Box2I newBBoxI(newBBoxD);
867 
869  newBoxPoints.reserve(newBBoxI.getWidth());
870  std::vector<Span> tempVec;
871  for (int y = newBBoxI.getBeginY(); y < newBBoxI.getEndY(); ++y) {
872  bool inSpan = false; // Are we in a span?
873  int start = -1; // Start of span
874 
875  // vectorize one row at a time (vectorizing the whole bbox would further improve performance
876  // but could lead to memory issues for very large bounding boxes)
877  newBoxPoints.clear();
878  for (int x = newBBoxI.getBeginX(); x < newBBoxI.getEndX(); ++x) {
879  newBoxPoints.emplace_back(lsst::geom::Point2D(x, y));
880  }
881  auto oldBoxPoints = t.applyInverse(newBoxPoints);
882  auto oldBoxPointIter = oldBoxPoints.cbegin();
883  for (int x = newBBoxI.getBeginX(); x < newBBoxI.getEndX(); ++x, ++oldBoxPointIter) {
884  auto p = *oldBoxPointIter;
885  int const xSource = std::floor(0.5 + p.getX());
886  int const ySource = std::floor(0.5 + p.getY());
887 
888  if (contains(lsst::geom::Point2I(xSource, ySource))) {
889  if (!inSpan) {
890  inSpan = true;
891  start = x;
892  }
893  } else if (inSpan) {
894  inSpan = false;
895  tempVec.push_back(Span(y, start, x - 1));
896  }
897  }
898  if (inSpan) {
899  tempVec.push_back(Span(y, start, newBBoxI.getMaxX()));
900  }
901  }
902  return std::make_shared<SpanSet>(std::move(tempVec));
903 }

◆ unflatten() [1/2]

template<typename Pixel , int inA, int inC>
ndarray::Array<typename std::remove_const<Pixel>::type, inA + 1, inA + 1> lsst::afw::geom::SpanSet::unflatten ( ndarray::Array< Pixel, inA, inC > const &  input) const
inline

Expand an array by one spatial dimension at points given by SpanSet.

Take values from a lower dimensional array and insert them in an output array with one additional dimension at points defined by the SpanSet, offset by the lower left hand corner of the bounding box of the SpanSet. The first two dimensions of the output array will correspond to the y,x dimensions of the SpanSet

Template Parameters
PixelThe data-type for the ndarray
inANumber of dimension of the input array
inCNumber of guaranteed row-major contiguous dimensions, starting from the end
Parameters
inputThe ndarray from which the values will be taken

Definition at line 360 of file SpanSet.h.

361  {
362  // Create a higher dimensional array the size of the bounding box and extra dimensions of input.
363  // Populate values from input, placed at locations corresponding to SpanSet, offset by the
364  // lower corner of the bounding box
365  auto existingShape = input.getShape();
366  typename decltype(existingShape)::Element height = _bbox.getHeight();
367  typename decltype(existingShape)::Element width = _bbox.getWidth();
368  auto outputShape = ndarray::concatenate(ndarray::makeVector(height, width),
369  input.getShape().template last<inA - 1>());
370  ndarray::Array<typename std::remove_const<Pixel>::type, inA + 1, inA + 1> outputArray =
371  ndarray::allocate(outputShape);
372  outputArray.deep() = 0;
373  unflatten(outputArray, input, lsst::geom::Point2I(_bbox.getMinX(), _bbox.getMinY()));
374  return outputArray;
375  }

◆ unflatten() [2/2]

template<typename PixelIn , typename PixelOut , int inA, int outC, int inC>
void lsst::afw::geom::SpanSet::unflatten ( ndarray::Array< PixelOut, inA+1, outC > const &  output,
ndarray::Array< PixelIn, inA, inC > const &  input,
lsst::geom::Point2I const &  xy0 = lsst::geom::Point2I() 
) const
inline

Expand an array by one spatial dimension at points given by SpanSet.

Take values from a lower dimensional array and insert them in an output array with one additional dimension at points defined by the SpanSet, offset by the lower left hand corner of the bounding box of the SpanSet. The first two dimensions of the output array will correspond to the y,x dimensions of the SpanSet

Template Parameters
PixelOutThe datatype for the output ndarray
PixelInThe datatype for the input ndarray
inANumber of dimensions of the input ndarray
outCNumber of guaranteed row-major contiguous dimensions in the output array, starting from the end
inCNumber of guaranteed row-major contiguous dimensions in the input array, starting from the end
Parameters
[out]outputThe 1d ndarray which will be populated with output parameters, will happen in place
[in]inputThe ndarray from which the values will be taken
[in]xy0A point object with is used as the origin point for the SpanSet coordinate system

Definition at line 397 of file SpanSet.h.

399  {
400  // Populate 2D ndarray output with values from input, at locations defined by SpanSet, optionally
401  // offset by xy0
402  auto ndAssigner = [](lsst::geom::Point2I const &point,
404  typename details::FlatNdGetter<PixelIn, inA, inC>::Reference in) { out = in; };
405  applyFunctor(ndAssigner, ndarray::ndImage(output, xy0), ndarray::ndFlat(input));
406  }

◆ union_() [1/2]

template<typename T >
std::shared_ptr< SpanSet > lsst::afw::geom::SpanSet::union_ ( image::Mask< T > const &  other,
bitmask 
) const

Determine the union between a SpanSet and a Mask for a given bit pattern.

Template Parameters
TPixel type of the Mask
Parameters
otherMask with which to calculate intersection
bitmaskThe bit value to consider when intersecting

Definition at line 961 of file SpanSet.cc.

961  {
962  auto comparator = [bitmask](T pixelValue) { return (pixelValue & bitmask); };
963  auto spanSetFromMask = fromMask(other, comparator);
964  return union_(*spanSetFromMask);
965 }

◆ union_() [2/2]

std::shared_ptr< SpanSet > lsst::afw::geom::SpanSet::union_ ( SpanSet const &  other) const

Create a new SpanSet that contains all points from two SpanSets.

Parameters
otherThe SpanSet from which the union will be calculated

Definition at line 828 of file SpanSet.cc.

828  {
829  /* Simply include Spans from both SpanSets in a new vector and let the SpanSet
830  * constructor normalize any of the SpanSets which may be contiguous
831  */
832  std::size_t combineSize = size() + other.size();
833  std::vector<Span> tempVec;
834  tempVec.reserve(combineSize);
835  // Copy this
836  tempVec.insert(tempVec.end(), _spanVector.begin(), _spanVector.end());
837  // Copy other
838  tempVec.insert(tempVec.end(), other.begin(), other.end());
839  return std::make_shared<SpanSet>(std::move(tempVec));
840 }

◆ writeFits() [1/3]

void lsst::afw::table::io::Persistable::writeFits ( fits::Fits fitsfile) const
inherited

Write the object to an already-open FITS object.

Parameters
[in]fitsfileOpen FITS object to write to.

Definition at line 18 of file Persistable.cc.

18  {
19  OutputArchive archive;
20  archive.put(this);
21  archive.writeFits(fitsfile);
22 }

◆ writeFits() [2/3]

void lsst::afw::table::io::Persistable::writeFits ( fits::MemFileManager manager,
std::string const &  mode = "w" 
) const
inherited

Write the object to a FITS image in memory.

Parameters
[in]managerName of the file to write to.
[in]modeIf "w", any existing file with the given name will be overwritten. If "a", new HDUs will be appended to an existing file.

Definition at line 29 of file Persistable.cc.

29  {
30  fits::Fits fitsfile(manager, mode, fits::Fits::AUTO_CLOSE | fits::Fits::AUTO_CHECK);
31  writeFits(fitsfile);
32 }

◆ writeFits() [3/3]

void lsst::afw::table::io::Persistable::writeFits ( std::string const &  fileName,
std::string const &  mode = "w" 
) const
inherited

Write the object to a regular FITS file.

Parameters
[in]fileNameName of the file to write to.
[in]modeIf "w", any existing file with the given name will be overwritten. If "a", new HDUs will be appended to an existing file.

Definition at line 24 of file Persistable.cc.

24  {
25  fits::Fits fitsfile(fileName, mode, fits::Fits::AUTO_CLOSE | fits::Fits::AUTO_CHECK);
26  writeFits(fitsfile);
27 }

Friends And Related Function Documentation

◆ SpansSetFactory

friend class SpansSetFactory
friend

Definition at line 732 of file SpanSet.h.


The documentation for this class was generated from the following files:
ndarray::ndImage
details::ImageNdGetter< T, inA, inB > ndImage(ndarray::Array< T, inA, inB > const &array, lsst::geom::Point2I xy0=lsst::geom::Point2I())
Marks a ndarray to be interpreted as an image when applying a functor from a SpanSet.
Definition: SpanSetFunctorGetters.h:333
y
int y
Definition: SpanSet.cc:49
lsst::afw::image
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
Definition: imageAlgorithm.dox:1
std::floor
T floor(T... args)
lsst::afw::table::io::Persistable::writeFits
void writeFits(std::string const &fileName, std::string const &mode="w") const
Write the object to a regular FITS file.
Definition: Persistable.cc:24
lsst::afw::geom::SpanSet::flatten
ndarray::Array< typename std::remove_const< Pixel >::type, inN - 1, inN - 1 > flatten(ndarray::Array< Pixel, inN, inC > const &input, lsst::geom::Point2I const &xy0=lsst::geom::Point2I()) const
Reduce the pixel dimensionality from 2 to 1 of an array at points given by SpanSet.
Definition: SpanSet.h:303
std::shared_ptr
STL class.
lsst::afw::image::Mask
Represent a 2-dimensional array of bitmask pixels.
Definition: Mask.h:77
lsst::meas::algorithms.psfSelectionFromMatchList.args
list args
Definition: psfSelectionFromMatchList.py:27
std::list
STL class.
xmax
int xmax
Definition: SpanSet.cc:49
std::move
T move(T... args)
lsst::afw::geom::SpanSet::setMask
void setMask(lsst::afw::image::Mask< T > &target, T bitmask) const
Set a Mask at pixels defined by the SpanSet.
Definition: SpanSet.cc:929
lsst::afw::geom::SpanSet::eroded
std::shared_ptr< SpanSet > eroded(int r, Stencil s=Stencil::CIRCLE) const
Perform a set erosion, and return a new object.
Definition: SpanSet.cc:573
std::vector::reserve
T reserve(T... args)
std::vector
STL class.
lsst::sphgeom::abs
Angle abs(Angle const &a)
Definition: Angle.h:106
lsst::afw::geom::Stencil::MANHATTAN
@ MANHATTAN
lsst::afw::geom::SpanSet::unflatten
ndarray::Array< typename std::remove_const< Pixel >::type, inA+1, inA+1 > unflatten(ndarray::Array< Pixel, inA, inC > const &input) const
Expand an array by one spatial dimension at points given by SpanSet.
Definition: SpanSet.h:360
lsst::afw::geom::SpanSet::getArea
size_type getArea() const
Return the number of pixels in the SpanSet.
Definition: SpanSet.cc:284
std::distance
T distance(T... args)
lsst::afw::geom::details::ImageNdGetter
Definition: SpanSetFunctorGetters.h:155
std::vector::back
T back(T... args)
lsst::afw::geom::SpanSet::transformedBy
std::shared_ptr< SpanSet > transformedBy(lsst::geom::LinearTransform const &t) const
Return a new SpanSet who's pixels are the product of applying the specified transformation.
Definition: SpanSet.cc:842
val
ImageT val
Definition: CR.cc:146
lsst::geom::Point2D
Point< double, 2 > Point2D
Definition: Point.h:324
mask
afw::table::Key< afw::table::Array< MaskPixelT > > mask
Definition: HeavyFootprint.cc:217
std::vector::front
T front(T... args)
std::sort
T sort(T... args)
std::sqrt
T sqrt(T... args)
std::list::clear
T clear(T... args)
src
std::shared_ptr< RecordT > src
Definition: Match.cc:48
lsst::geom::Box2I::getEndY
int getEndY() const noexcept
Definition: Box.h:177
std::vector::push_back
T push_back(T... args)
lsst::geom::AffineTransform
An affine coordinate transformation consisting of a linear transformation and an offset.
Definition: AffineTransform.h:75
lsst::afw::geom::SpanSet::fromMask
static std::shared_ptr< geom::SpanSet > fromMask(image::Mask< T > const &mask, UnaryPredicate comparator=details::AnyBitSetFunctor< T >())
Create a SpanSet from a mask.
Definition: SpanSet.h:644
lsst::afw::geom::details::FlatNdGetter
Definition: SpanSetFunctorGetters.h:195
lsst::afw::geom::SpanSet::clippedTo
std::shared_ptr< SpanSet > clippedTo(lsst::geom::Box2I const &box) const
Return a new SpanSet which has all pixel values inside specified box.
Definition: SpanSet.cc:440
lsst::afw::geom::SpanSet::overlaps
bool overlaps(SpanSet const &other) const
Specifies if this SpanSet overlaps with another SpanSet.
Definition: SpanSet.cc:455
lsst::afw::geom::SpanSet::size
size_type size() const
Definition: SpanSet.h:94
lsst.pipe.tasks.assembleCoadd.run
def run(self, skyInfo, tempExpRefList, imageScalerList, weightList, altMaskList=None, mask=None, supplementaryData=None)
Definition: assembleCoadd.py:712
lsst::afw::fits::Fits::AUTO_CHECK
@ AUTO_CHECK
Definition: fits.h:308
lsst::afw::fits::Fits::AUTO_CLOSE
@ AUTO_CLOSE
Definition: fits.h:307
x
double x
Definition: ChebyshevBoundedField.cc:277
ndarray::ndFlat
details::FlatNdGetter< T, inA, inB > ndFlat(ndarray::Array< T, inA, inB > const &array)
Marks a ndarray to be interpreted as a 1D vector when applying a functor from a SpanSet.
Definition: SpanSetFunctorGetters.h:318
lsst::afw::geom::Stencil::BOX
@ BOX
other
ItemVariant const * other
Definition: Schema.cc:56
ptr
uint64_t * ptr
Definition: RangeSet.cc:88
std::int32_t
dimensions
afw::table::PointKey< int > dimensions
Definition: GaussianPsf.cc:49
lsst::afw::geom::Stencil::CIRCLE
@ CIRCLE
lsst::afw::geom::details::makeGetter
FlatNdGetter< T, inA, inC > makeGetter(FlatNdGetter< T, inA, inC > &getter)
Definition: SpanSetFunctorGetters.h:239
result
py::object result
Definition: _schema.cc:429
lsst::afw::geom::SpanSet::applyFunctor
void applyFunctor(Functor &&func, Args &&... args) const
Apply functor on individual elements from the supplied parameters.
Definition: SpanSet.h:512
lsst::afw::image::MaskedImage::getVariance
VariancePtr getVariance() const
Return a (shared_ptr to) the MaskedImage's variance.
Definition: MaskedImage.h:1090
lsst::afw::geom::SpanSet::contains
bool contains(SpanSet const &other) const
Check if a SpanSet instance entirely contains another SpanSet.
Definition: SpanSet.cc:467
LSST_EXCEPT
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
target
Key< Flag > const & target
Definition: BaseColumnView.cc:20
std::swap
T swap(T... args)
std::min
T min(T... args)
xmin
int xmin
Definition: SpanSet.cc:49
std::equal_range
T equal_range(T... args)
std::vector::emplace_back
T emplace_back(T... args)
lsst::afw::geom::SpanSet::fromShape
static std::shared_ptr< geom::SpanSet > fromShape(int r, Stencil s=Stencil::CIRCLE, lsst::geom::Point2I offset=lsst::geom::Point2I())
Factory function for creating SpanSets from a Stencil.
Definition: SpanSet.cc:689
lsst::geom::Box2I::overlaps
bool overlaps(Box2I const &other) const noexcept
Return true if any points in other are also in this.
Definition: Box.cc:122
lsst::afw::table::io::PersistableFacade< lsst::afw::geom::SpanSet >::dynamicCast
static std::shared_ptr< lsst::afw::geom::SpanSet > dynamicCast(std::shared_ptr< Persistable > const &ptr)
Dynamically cast a shared_ptr.
Definition: Persistable.cc:18
std::vector::begin
T begin(T... args)
type
table::Key< int > type
Definition: Detector.cc:163
std::vector::insert
T insert(T... args)
lsst::afw::geom::SpanSet::end
const_iterator end() const
Definition: SpanSet.h:89
lsst::geom::Point< int, 2 >
lsst::geom::Box2I
An integer coordinate rectangle.
Definition: Box.h:55
lsst::geom::Box2I::getMinX
int getMinX() const noexcept
Definition: Box.h:157
lsst::geom::Box2D::include
void include(Point2D const &point) noexcept
Expand this to ensure that this->contains(point).
Definition: Box.cc:380
lsst::afw::image::MaskedImage::getImage
ImagePtr getImage() const
Return a (shared_ptr to) the MaskedImage's image.
Definition: MaskedImage.h:1057
lsst::afw::geom::SpanSet::union_
std::shared_ptr< SpanSet > union_(SpanSet const &other) const
Create a new SpanSet that contains all points from two SpanSets.
Definition: SpanSet.cc:828
std::size_t
std::vector::end
T end(T... args)
lsst::afw::geom::SpanSet::begin
const_iterator begin() const
Definition: SpanSet.h:88
lsst::afw::geom::SpanSet::computeCentroid
lsst::geom::Point2D computeCentroid() const
Compute the point about which the SpanSet's first moment is zero.
Definition: SpanSet.cc:503
std::max
T max(T... args)
lsst::geom::Box2D
A floating-point coordinate rectangle geometry.
Definition: Box.h:413
lsst::afw::image::MaskedImage::getMask
MaskPtr getMask() const
Return a (shared_ptr to) the MaskedImage's mask.
Definition: MaskedImage.h:1069
lsst::afw::geom::SpanSet::dilated
std::shared_ptr< SpanSet > dilated(int r, Stencil s=Stencil::CIRCLE) const
Perform a set dilation operation, and return a new object.
Definition: SpanSet.cc:545
lsst::afw::geom::makeTransform
std::shared_ptr< TransformPoint2ToPoint2 > makeTransform(lsst::geom::AffineTransform const &affine)
Wrap an lsst::geom::AffineTransform as a Transform.
Definition: transformFactory.cc:154
bbox
AmpInfoBoxKey bbox
Definition: Amplifier.cc:117
lsst::geom::Box2I::getMinY
int getMinY() const noexcept
Definition: Box.h:158
m
int m
Definition: SpanSet.cc:49
lsst::geom::Box2I::getCorners
std::vector< Point2I > getCorners() const
Get the corner points.
Definition: Box.cc:261
lsst::afw::geom::SpanSet::getBBox
lsst::geom::Box2I getBBox() const
Return a new integer box which is the minimum size to contain the pixels.
Definition: SpanSet.cc:287