LSST Applications g070148d5b3+33e5256705,g0d53e28543+25c8b88941,g0da5cf3356+2dd1178308,g1081da9e2a+62d12e78cb,g17e5ecfddb+7e422d6136,g1c76d35bf8+ede3a706f7,g295839609d+225697d880,g2e2c1a68ba+cc1f6f037e,g2ffcdf413f+853cd4dcde,g38293774b4+62d12e78cb,g3b44f30a73+d953f1ac34,g48ccf36440+885b902d19,g4b2f1765b6+7dedbde6d2,g5320a0a9f6+0c5d6105b6,g56b687f8c9+ede3a706f7,g5c4744a4d9+ef6ac23297,g5ffd174ac0+0c5d6105b6,g6075d09f38+66af417445,g667d525e37+2ced63db88,g670421136f+2ced63db88,g71f27ac40c+2ced63db88,g774830318a+463cbe8d1f,g7876bc68e5+1d137996f1,g7985c39107+62d12e78cb,g7fdac2220c+0fd8241c05,g96f01af41f+368e6903a7,g9ca82378b8+2ced63db88,g9d27549199+ef6ac23297,gabe93b2c52+e3573e3735,gb065e2a02a+3dfbe639da,gbc3249ced9+0c5d6105b6,gbec6a3398f+0c5d6105b6,gc9534b9d65+35b9f25267,gd01420fc67+0c5d6105b6,geee7ff78d7+a14128c129,gf63283c776+ede3a706f7,gfed783d017+0c5d6105b6,w.2022.47
LSST Data Management Base Package
Loading...
Searching...
No Matches
Footprint.h
Go to the documentation of this file.
1/*
2 * LSST Data Management System
3 * Copyright 2008-2016 AURA/LSST.
4 *
5 * This product includes software developed by the
6 * LSST Project (http://www.lsst.org/).
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the LSST License Statement and
19 * the GNU General Public License along with this program. If not,
20 * see <https://www.lsstcorp.org/LegalNotices/>.
21 */
22#if !defined(LSST_DETECTION_FOOTPRINT_H)
23#define LSST_DETECTION_FOOTPRINT_H
24
25#include <algorithm>
26#include <list>
27#include <set>
28#include <cmath>
29#include <cstdint>
30#include <memory>
31#include "ndarray.h"
32#include "lsst/base.h"
35#include "lsst/afw/geom/Span.h"
37#include "lsst/geom/Box.h"
42#include "lsst/afw/table/fwd.h"
44#include "lsst/afw/table/Key.h"
47
48namespace lsst {
49namespace afw {
50namespace detection {
51
62class Footprint : public afw::table::io::PersistableFacade<lsst::afw::detection::Footprint>,
64public:
65 /*
66 * As a note there is no constructor which accepts a unique_ptr to a SpanSet.
67 * If someone did have a unique_ptr to a SpanSet it is possible to wrap the
68 * unique_ptr in a std::move when calling the constructor of a Footprint and
69 * the compiler will implicitly turn the unique_ptr into a shared_ptr and use
70 * that to construct the Footprint.
71 */
72
80 explicit Footprint(std::shared_ptr<geom::SpanSet> inputSpans,
81 lsst::geom::Box2I const &region = lsst::geom::Box2I());
82
91 explicit Footprint(std::shared_ptr<geom::SpanSet> inputSpans, afw::table::Schema const &peakSchema,
92 lsst::geom::Box2I const &region = lsst::geom::Box2I());
93
96 explicit Footprint()
97 : _spans(std::make_shared<geom::SpanSet>()),
98 _peaks(PeakTable::makeMinimalSchema()),
99 _region(lsst::geom::Box2I()) {}
100
101 Footprint(Footprint const &other) = default;
102 Footprint(Footprint &&) = default;
103
104 Footprint &operator=(Footprint const &other) = default;
106
107 ~Footprint() override = default;
108
111 virtual bool isHeavy() const { return false; }
112
115 std::shared_ptr<geom::SpanSet> getSpans() const { return _spans; }
116
121 void setSpans(std::shared_ptr<geom::SpanSet> otherSpanSet);
122
129 PeakCatalog &getPeaks() { return _peaks; }
130 const PeakCatalog &getPeaks() const { return _peaks; }
131
138 std::shared_ptr<PeakRecord> addPeak(float fx, float fy, float value);
139
149
156 void setPeakSchema(afw::table::Schema const &peakSchema);
157
166 void setPeakCatalog(PeakCatalog const &otherPeaks);
167
173 std::size_t getArea() const { return _spans->getArea(); }
174
180 lsst::geom::Point2D getCentroid() const { return _spans->computeCentroid(); }
181
188 geom::ellipses::Quadrupole getShape() const { return _spans->computeShape(); }
189
196 void shift(int dx, int dy);
197
203 void shift(lsst::geom::ExtentI const &d) { shift(d.getX(), d.getY()); }
204
208 lsst::geom::Box2I getBBox() const { return _spans->getBBox(); }
209
213 lsst::geom::Box2I getRegion() const { return _region; }
214
220 void setRegion(lsst::geom::Box2I const &region) { _region = region; }
221
228 void clipTo(lsst::geom::Box2I const &bbox);
229
235 bool contains(lsst::geom::Point2I const &pix) const;
236
248 lsst::geom::Box2I const &region, bool doClip = true) const;
249
258 lsst::geom::Box2I const &region, bool doClip = true) const;
259
268 lsst::geom::Box2I const &region, bool doClip = true) const;
269
277 std::shared_ptr<Footprint> transform(geom::TransformPoint2ToPoint2 const &t,
278 lsst::geom::Box2I const &region, bool doClip = true) const;
279
283 bool isPersistable() const noexcept override { return true; }
284
294 void dilate(int r, geom::Stencil s = geom::Stencil::CIRCLE);
295
304 void dilate(geom::SpanSet const &other);
305
315 void erode(int r, geom::Stencil s = geom::Stencil::CIRCLE);
316
325 void erode(geom::SpanSet const &other);
326
330 void removeOrphanPeaks();
331
341 void updatePeakSignificance(double sigma);
342
353 void updatePeakSignificance(image::Image<float> const &variance, int polarity);
354
358 bool isContiguous() const { return getSpans()->isContiguous(); };
359
368
374 bool operator==(Footprint const &other) const;
375
376protected:
380 std::string getPersistenceName() const override;
381
385 inline std::string getPythonModule() const override { return "lsst.afw.detection"; }
386
390 void write(OutputArchiveHandle &handle) const override;
391
392 friend class FootprintFactory;
393
402 static void readPeaks(afw::table::BaseCatalog const &, Footprint &);
403
404private:
405 friend class FootprintMerge;
406
408 PeakCatalog _peaks;
409 lsst::geom::Box2I _region;
410};
411
419
425std::shared_ptr<Footprint> mergeFootprints(Footprint const &footprint1, Footprint const &footprint2);
426
436} // namespace detection
437} // namespace afw
438} // namespace lsst
439
440#endif // LSST_DETECTION_FOOTPRINT_H
AmpInfoBoxKey bbox
Definition: Amplifier.cc:117
Key< Flag > const & target
afw::table::Key< double > sigma
Definition: GaussianPsf.cc:49
afw::table::Key< afw::table::Array< VariancePixelT > > variance
Basic LSST definitions.
Class to describe the properties of a detected object from an image.
Definition: Footprint.h:63
Footprint()
Constructor of a empty Footprint object.
Definition: Footprint.h:96
lsst::geom::Box2I getRegion() const
Return the corners of the MaskedImage the footprints live in.
Definition: Footprint.h:213
bool isPersistable() const noexcept override
Report if this object is persistable.
Definition: Footprint.h:283
virtual bool isHeavy() const
Indicates if this object is a HeavyFootprint.
Definition: Footprint.h:111
bool isContiguous() const
Reports if the Footprint is simply connected or has multiple components.
Definition: Footprint.h:358
std::shared_ptr< PeakRecord > addPeak(float fx, float fy, float value)
Convenience function to add a peak.
Definition: Footprint.cc:47
static std::unique_ptr< Footprint > readSpanSet(afw::table::BaseCatalog const &, afw::table::io::InputArchive const &)
Static method used to unpersist the SpanSet member of the Footprint class.
Definition: Footprint.cc:286
void shift(lsst::geom::ExtentI const &d)
Shift a Footprint by a given extent.
Definition: Footprint.h:203
void write(OutputArchiveHandle &handle) const override
Write an instance of a Footprint to an output Archive.
Definition: Footprint.cc:271
Footprint(Footprint const &other)=default
Footprint & operator=(Footprint const &other)=default
bool contains(lsst::geom::Point2I const &pix) const
Tests if a pixel postion falls inside the Footprint.
Definition: Footprint.cc:79
void setRegion(lsst::geom::Box2I const &region)
Set the corners of the MaskedImage wherein the footprints dwell.
Definition: Footprint.h:220
std::vector< std::shared_ptr< Footprint > > split() const
Split a multi-component Footprint into a vector of contiguous Footprints.
Definition: Footprint.cc:159
void dilate(int r, geom::Stencil s=geom::Stencil::CIRCLE)
Dilate the Footprint with a defined kernel.
Definition: Footprint.cc:122
lsst::geom::Box2I getBBox() const
Return the Footprint's bounding box.
Definition: Footprint.h:208
void sortPeaks(afw::table::Key< float > const &key=afw::table::Key< float >())
Sort Peaks from most positive value to most negative.
Definition: Footprint.cc:57
std::shared_ptr< geom::SpanSet > getSpans() const
Return a shared pointer to the SpanSet.
Definition: Footprint.h:115
void removeOrphanPeaks()
Remove peaks from the PeakCatalog that fall outside the area of the Footprint.
Definition: Footprint.cc:136
void setPeakSchema(afw::table::Schema const &peakSchema)
Set the Schema used by the PeakCatalog (will throw if PeakCatalog is not empty).
Definition: Footprint.cc:431
PeakCatalog & getPeaks()
Return the Peaks contained in this Footprint.
Definition: Footprint.h:129
~Footprint() override=default
std::size_t getArea() const
Return the number of pixels in this Footprint.
Definition: Footprint.h:173
Footprint & operator=(Footprint &&)=default
void setSpans(std::shared_ptr< geom::SpanSet > otherSpanSet)
Sets the shared pointer to the SpanSet in the Footprint.
Definition: Footprint.cc:45
std::string getPersistenceName() const override
Return the name correspoinging ot the persistence type.
Definition: Footprint.cc:269
void clipTo(lsst::geom::Box2I const &bbox)
Clip the Footprint such that all values lie inside the supplied Bounding Box.
Definition: Footprint.cc:74
void erode(int r, geom::Stencil s=geom::Stencil::CIRCLE)
Erode the Footprint with a defined kernel.
Definition: Footprint.cc:126
std::string getPythonModule() const override
Return the python module the object will live in.
Definition: Footprint.h:385
void updatePeakSignificance(double sigma)
Compute and update the significance of each peak, given a single value for sigma.
Definition: Footprint.cc:145
lsst::geom::Point2D getCentroid() const
Return the Footprint's centroid.
Definition: Footprint.h:180
void shift(int dx, int dy)
Shift a Footprint by (dx, dy)
Definition: Footprint.cc:64
bool operator==(Footprint const &other) const
equality operator
Definition: Footprint.cc:176
static void readPeaks(afw::table::BaseCatalog const &, Footprint &)
Static method used to unpersist the PeakCatalog member of the Footprint class.
Definition: Footprint.cc:310
Footprint(Footprint &&)=default
geom::ellipses::Quadrupole getShape() const
Return the Footprint's shape (interpreted as an ellipse)
Definition: Footprint.h:188
void setPeakCatalog(PeakCatalog const &otherPeaks)
Set the peakCatalog to a copy of the supplied catalog.
Definition: Footprint.cc:435
const PeakCatalog & getPeaks() const
Definition: Footprint.h:130
Table class for Peaks in Footprints.
Definition: Peak.h:102
A compact representation of a collection of pixels.
Definition: SpanSet.h:78
An ellipse core with quadrupole moments as parameters.
Definition: Quadrupole.h:47
A class to represent a 2-dimensional array of pixels.
Definition: Image.h:51
A class used as a handle to a particular field in a table.
Definition: Key.h:53
Defines the fields and offsets for a table.
Definition: Schema.h:51
A multi-catalog archive object used to load table::io::Persistable objects.
Definition: InputArchive.h:31
A CRTP facade class for subclasses of Persistable.
Definition: Persistable.h:176
A base class for objects that can be persisted via afw::table::io Archive classes.
Definition: Persistable.h:74
io::OutputArchiveHandle OutputArchiveHandle
Definition: Persistable.h:108
An affine coordinate transformation consisting of a linear transformation and an offset.
An integer coordinate rectangle.
Definition: Box.h:55
A 2D linear coordinate transformation.
std::ostream & operator<<(std::ostream &os, Footprint const &rhs)
Print a Footprint to the stream.
Definition: Footprint.cc:443
std::vector< lsst::geom::Box2I > footprintToBBoxList(Footprint const &footprint)
Return a list of BBoxs, whose union contains exactly the pixels in the footprint, neither more nor le...
Definition: Footprint.cc:366
std::shared_ptr< Footprint > mergeFootprints(Footprint const &footprint1, Footprint const &footprint2)
Merges two Footprints – appends their peaks, and unions their spans, returning a new Footprint.
Definition: Footprint.cc:341
STL namespace.