LSSTApplications
19.0.0-14-gb0260a2+72efe9b372,20.0.0+7927753e06,20.0.0+8829bf0056,20.0.0+995114c5d2,20.0.0+b6f4b2abd1,20.0.0+bddc4f4cbe,20.0.0-1-g253301a+8829bf0056,20.0.0-1-g2b7511a+0d71a2d77f,20.0.0-1-g5b95a8c+7461dd0434,20.0.0-12-g321c96ea+23efe4bbff,20.0.0-16-gfab17e72e+fdf35455f6,20.0.0-2-g0070d88+ba3ffc8f0b,20.0.0-2-g4dae9ad+ee58a624b3,20.0.0-2-g61b8584+5d3db074ba,20.0.0-2-gb780d76+d529cf1a41,20.0.0-2-ged6426c+226a441f5f,20.0.0-2-gf072044+8829bf0056,20.0.0-2-gf1f7952+ee58a624b3,20.0.0-20-geae50cf+e37fec0aee,20.0.0-25-g3dcad98+544a109665,20.0.0-25-g5eafb0f+ee58a624b3,20.0.0-27-g64178ef+f1f297b00a,20.0.0-3-g4cc78c6+e0676b0dc8,20.0.0-3-g8f21e14+4fd2c12c9a,20.0.0-3-gbd60e8c+187b78b4b8,20.0.0-3-gbecbe05+48431fa087,20.0.0-38-ge4adf513+a12e1f8e37,20.0.0-4-g97dc21a+544a109665,20.0.0-4-gb4befbc+087873070b,20.0.0-4-gf910f65+5d3db074ba,20.0.0-5-gdfe0fee+199202a608,20.0.0-5-gfbfe500+d529cf1a41,20.0.0-6-g64f541c+d529cf1a41,20.0.0-6-g9a5b7a1+a1cd37312e,20.0.0-68-ga3f3dda+5fca18c6a4,20.0.0-9-g4aef684+e18322736b,w.2020.45
LSSTDataManagementBasePackage
|
Go to the documentation of this file.
25 #ifndef LSST_AFW_GEOM_SPANSET_H
26 #define LSST_AFW_GEOM_SPANSET_H
55 bool operator()(T pixelValue) {
return pixelValue != 0; }
95 bool empty()
const {
return _spanVector.empty(); }
122 template <
typename iter>
125 if (_spanVector.size() == 0) {
302 template <
typename Pixel,
int inN,
int inC>
304 ndarray::Array<Pixel, inN, inC>
const &input,
307 auto outputShape = ndarray::concatenate(ndarray::makeVector(
getArea()),
308 input.getShape().template last<inN - 2>());
310 ndarray::allocate(outputShape);
311 outputArray.deep() = 0;
312 flatten(outputArray, input, xy0);
335 template <
typename PixelIn,
typename PixelOut,
int inA,
int outC,
int inC>
336 void flatten(ndarray::Array<PixelOut, inA - 1, outC>
const &output,
337 ndarray::Array<PixelIn, inA, inC>
const &input,
359 template <
typename Pixel,
int inA,
int inC>
361 ndarray::Array<Pixel, inA, inC>
const &input)
const {
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>());
371 ndarray::allocate(outputShape);
372 outputArray.deep() = 0;
396 template <
typename PixelIn,
typename PixelOut,
int inA,
int outC,
int inC>
397 void unflatten(ndarray::Array<PixelOut, inA + 1, outC>
const &output,
398 ndarray::Array<PixelIn, inA, inC>
const &input,
415 template <
typename ImageT>
417 auto copyFunc = [](
lsst::geom::Point2I const &point, ImageT
const &srcPix, ImageT &destPix) {
432 template <
typename ImageT,
typename MaskT,
typename VarT>
435 auto copyFunc = [](
lsst::geom::Point2I const &point, ImageT
const &srcPix, MaskT
const &srcMask,
436 VarT
const &srcVar, ImageT &destPix, MaskT &destMask, VarT &destVar) {
458 template <
typename ImageT>
507 template <
typename Functor,
typename... Args>
531 template <
typename T>
541 template <
typename T>
558 template <
typename T>
576 template <
typename T>
592 template <
typename T>
643 template <
typename T,
typename UnaryPredicate = details::AnyBitSetFunctor<T>>
650 auto const maskArray =
mask.getArray();
651 auto const minPoint =
mask.getBBox().getMin();
653 auto const minY = minPoint.getY();
654 auto const minX = minPoint.getX();
658 auto arrIter = maskArray.begin();
659 for (
size_t y = 0;
y < yDim; ++
y) {
660 auto yWithOffset =
y + minY;
663 for (
size_t x = 0;
x < xDim; ++
x) {
664 bool compareValue = comparator((*arrIter)[
x]);
672 }
else if (compareValue) {
682 tempVec.
push_back(
Span(yWithOffset, start + minX, dimMinusOne + minX));
688 return std::make_shared<SpanSet>(
std::move(tempVec),
false);
700 template <
typename T>
702 return fromMask(
mask, [bitmask](T
const &bitPattern) {
return bitPattern & bitmask; });
724 inline std::string getPythonModule()
const override {
return "lsst.afw.geom"; }
736 void _runNormalize();
751 template <
typename F,
typename... T>
752 void applyFunctorImpl(F &&f, T...
args)
const {
759 for (
auto const &spn : _spanVector) {
762 for (
int x = spn.getX0();
x <= spn.getX1(); ++
x) {
764 f(point,
args.get()...);
783 #endif // LSST_AFW_GEOM_SPANSET_H
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.
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
void setImage(image::Image< ImageT > &image, ImageT val, lsst::geom::Box2I const ®ion=lsst::geom::Box2I(), bool doClip=false) const
Set the values of an Image at points defined by the SpanSet.
A range of pixels within one row of an Image.
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.
friend class SpansSetFactory
const_iterator cend() const
Represent a 2-dimensional array of bitmask pixels.
bool operator==(SpanSet const &other) const
Compute equality between two SpanSets.
value_type const & const_reference
void setMask(lsst::afw::image::Mask< T > &target, T bitmask) const
Set a Mask at pixels defined by the SpanSet.
typename ndarray::Array< T, inA, inC >::Reference Reference
int getHeight() const noexcept
std::shared_ptr< SpanSet > eroded(int r, Stencil s=Stencil::CIRCLE) const
Perform a set erosion, and return a new object.
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.
SpanSet & operator=(SpanSet &&other)
SpanSet()
Default constructor.
size_type getArea() const
Return the number of pixels in the SpanSet.
SpanSet(iter begin, iter end, bool normalize=true)
Construct a SpanSet from an iterator.
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.
const_reference front() const
~SpanSet() override=default
std::vector< Span >::const_iterator const_iterator
std::shared_ptr< geom::SpanSet > findEdgePixels() const
Select pixels within the SpanSet which touch its edge.
std::vector< Span >::size_type size_type
SpanSet(SpanSet const &other)=delete
std::shared_ptr< RecordT > src
bool isPersistable() const noexcept override
Return true if this particular object can be persisted using afw::table::io.
SpanSet(SpanSet &&other)=delete
bool operator!=(SpanSet const &other) const
static std::shared_ptr< geom::SpanSet > fromMask(image::Mask< T > const &mask, UnaryPredicate comparator=details::AnyBitSetFunctor< T >())
Create a SpanSet from a mask.
A compact representation of a collection of pixels.
A class to manipulate images, masks, and variance as a single object.
std::shared_ptr< SpanSet > clippedTo(lsst::geom::Box2I const &box) const
Return a new SpanSet which has all pixel values inside specified box.
int getWidth() const noexcept
bool overlaps(SpanSet const &other) const
Specifies if this SpanSet overlaps with another SpanSet.
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.
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.
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.
ItemVariant const * other
void clearMask(lsst::afw::image::Mask< T > &target, T bitmask) const
Unset a Mask at pixels defined by the SpanSet.
afw::table::PointKey< int > dimensions
FlatNdGetter< T, inA, inC > makeGetter(FlatNdGetter< T, inA, inC > &getter)
SpanSet & operator=(SpanSet const &)=default
void applyFunctor(Functor &&func, Args &&... args) const
Apply functor on individual elements from the supplied parameters.
std::shared_ptr< SpanSet > shiftedBy(int x, int y) const
Return a new SpanSet shifted by specified amount.
A base class for image defects.
VariancePtr getVariance() const
Return a (shared_ptr to) the MaskedImage's variance.
bool contains(SpanSet const &other) const
Check if a SpanSet instance entirely contains another SpanSet.
Key< Flag > const & target
An ellipse defined by an arbitrary BaseCore and a center point.
An ellipse core with quadrupole moments as parameters.
std::shared_ptr< SpanSet > intersect(SpanSet const &other) const
Determine the common points between two SpanSets, and create a new SpanSet.
A base class for objects that can be persisted via afw::table::io Archive classes.
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.
const_reference back() const
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.
bool isContiguous() const
Defines if the SpanSet is simply contiguous.
ellipses::Quadrupole computeShape() const
Compute the shape parameters for the distribution of points in the SpanSet.
static std::shared_ptr< geom::SpanSet > fromMask(image::Mask< T > const &mask, T bitmask)
Create a SpanSet from a mask.
const_iterator end() const
A CRTP facade class for subclasses of Persistable.
const_iterator cbegin() const
An integer coordinate rectangle.
void variadicIncrementPosition(T &x)
int getMinX() const noexcept
void variadicBoundChecker(lsst::geom::Box2I const box, int area, T const &x)
ImagePtr getImage() const
Return a (shared_ptr to) the MaskedImage's image.
std::shared_ptr< SpanSet > union_(SpanSet const &other) const
Create a new SpanSet that contains all points from two SpanSets.
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.
const_iterator begin() const
lsst::geom::Point2D computeCentroid() const
Compute the point about which the SpanSet's first moment is zero.
typename ndarray::Array< T, N, C >::Reference::Reference Reference
MaskPtr getMask() const
Return a (shared_ptr to) the MaskedImage's mask.
std::shared_ptr< SpanSet > dilated(int r, Stencil s=Stencil::CIRCLE) const
Perform a set dilation operation, and return a new object.
io::OutputArchiveHandle OutputArchiveHandle
Stencil
An enumeration class which describes the shapes.
std::vector< std::shared_ptr< geom::SpanSet > > split() const
Split a discontinuous SpanSet into multiple SpanSets which are contiguous.
void variadicSpanSetter(Span const spn, T &x)
bool operator()(T pixelValue)
int getMinY() const noexcept
std::shared_ptr< SpanSet > intersectNot(SpanSet const &other) const
Determine the common points between a SpanSet and the logical inverse of a second SpanSet and return ...
lsst::geom::Box2I getBBox() const
Return a new integer box which is the minimum size to contain the pixels.