39 : _spans(inputSpans), _peaks(
PeakTable::makeMinimalSchema()), _region(region) {}
43 : _spans(inputSpans), _peaks(peakSchema), _region(region) {}
53 p->setPeakValue(height);
60 return a.get(validatedKey) >
b.get(validatedKey);
85 return transform(*srcToTarget, region, doClip);
101 auto transformedSpan =
getSpans()->transformedBy(t);
103 auto newFootprint = std::make_shared<Footprint>(transformedSpan,
getPeaks().getSchema(), region);
110 auto newPeakPosList = t.applyForward(peakPosList);
111 auto newPeakPos = newPeakPosList.cbegin();
113 ++
peak, ++newPeakPos) {
114 newFootprint->addPeak(newPeakPos->getX(), newPeakPos->getY(),
peak->getPeakValue());
117 newFootprint->clipTo(region);
146 auto splitSpanSets =
getSpans()->split();
148 footprintList.
reserve(splitSpanSets.size());
149 for (
auto& spanPtr : splitSpanSets) {
150 auto tmpFootprintPointer = std::make_shared<Footprint>(spanPtr,
getPeaks().getSchema(),
getRegion());
151 tmpFootprintPointer->_peaks =
getPeaks();
154 if (splitSpanSets.size() > 1) {
155 tmpFootprintPointer->removeOrphanPeaks();
159 return footprintList;
170 for (
auto const& selfPeak :
getPeaks()) {
172 for (
auto const& otherPeak :
other.getPeaks()) {
173 if (selfPeak.getI() == otherPeak.getI() && selfPeak.getF() == otherPeak.getF() &&
174 selfPeak.getPeakValue() == otherPeak.getPeakValue()) {
189 std::string getFootprintPersistenceName() {
return "Footprint"; }
191 class LegacyFootprintPersistenceHelper {
198 static LegacyFootprintPersistenceHelper
const& get() {
199 static LegacyFootprintPersistenceHelper instance;
204 LegacyFootprintPersistenceHelper(
const LegacyFootprintPersistenceHelper&) =
delete;
205 LegacyFootprintPersistenceHelper&
operator=(
const LegacyFootprintPersistenceHelper&) =
delete;
208 LegacyFootprintPersistenceHelper(LegacyFootprintPersistenceHelper&&) =
delete;
209 LegacyFootprintPersistenceHelper&
operator=(LegacyFootprintPersistenceHelper&&) =
delete;
212 LegacyFootprintPersistenceHelper()
215 spanX0(
spanSchema.addField<int>(
"x0",
"First column of span (inclusive)",
"pixel")),
216 spanX1(
spanSchema.addField<int>(
"x1",
"Second column of span (inclusive)",
"pixel")) {}
220 static afw::table::Schema spanSetIdSchema;
221 static int initialize =
true;
222 static table::Key<int> idKey;
224 idKey = spanSetIdSchema.addField<
int>(
"id",
"id of the SpanSet catalog");
243 return loadedFootprint;
252 FootprintFactory registration(getFootprintPersistenceName());
259 auto const keys = spanSetPersistenceHelper();
263 auto record = spanSetCat.
addNew();
277 if (fieldCount == 1) {
279 auto const schemaAndKey = spanSetPersistenceHelper();
280 int persistedSpanSetId = catalog.
front().
get(schemaAndKey.second);
281 loadedSpanSet = std::dynamic_pointer_cast<geom::SpanSet>(archive.
get(persistedSpanSetId));
284 auto const&
keys = LegacyFootprintPersistenceHelper::get();
287 for (
auto const&
val : catalog) {
290 loadedSpanSet = std::make_shared<geom::SpanSet>(
std::move(tempVec));
293 return loadedFootprint;
297 using namespace std::string_literals;
305 mapper.addMapping(oldX,
"f.x"s);
306 mapper.addMapping(oldY,
"f.y"s);
307 mapper.addMapping(oldPeakValue,
"peakValue"s);
309 auto peaks = loadedFootprint.
getPeaks();
311 for (
auto const&
peak : peakCat) {
312 auto newPeak = peaks.addNew();
314 newPeak->setIx(
static_cast<int>(newPeak->getFx()));
315 newPeak->setIy(
static_cast<int>(newPeak->getFy()));
320 auto& peaks = loadedFootprint.
getPeaks();
322 for (
auto const&
peak : peakCat) {
323 peaks.addNew()->assign(
peak);
331 "Cannot merge Footprints with different Schemas");
335 auto unionedSpanSet = footprint1.
getSpans()->union_(*(footprint2.
getSpans()));
338 auto mergedFootprint = std::make_shared<Footprint>(unionedSpanSet, footprint1.
getPeaks().
getSchema());
347 mergedFootprint->sortPeaks();
349 return mergedFootprint;
359 footprint.
getSpans()->setImage(*idImage,
static_cast<PixelT>(1), fpBBox,
true);
376 while (y0 < height) {
378 for (
int y = y0;
y < height; ++
y) {
385 int const x0 =
first - begin;
386 int const x1 = last - begin;
387 int const x_size = 1 + x1 - x0;
395 for (++
y;
y < height; ++
y) {
396 if (
std::find(idImage->at(x0,
y), idImage->at(x0,
y) + x_size, 0) !=
397 idImage->at(x0,
y) + x_size) {
400 std::fill(idImage->at(x0,
y), idImage->at(x0,
y) + x_size, 0);
table::Key< std::string > name
Key< Flag > const & target
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
ItemVariant const * other
#define LSST_ARCHIVE_ASSERT(EXPR)
An assertion macro used to validate the structure of an InputArchive.
Record class that represents a peak in a Footprint.
Table class for Peaks in Footprints.
static afw::table::Schema makeMinimalSchema()
Return a minimal schema for Peak tables and records.
static afw::table::Key< float > getPeakValueKey()
_view_t::x_iterator x_iterator
An iterator for traversing the pixels in a row.
A class to represent a 2-dimensional array of pixels.
Field< T >::Value get(Key< T > const &key) const
Return the value of a field for the given key.
std::shared_ptr< RecordT > addNew()
Create a new record, add it to the end of the catalog, and return a pointer to it.
size_type size() const
Return the number of elements in the catalog.
iterator begin()
Iterator access.
iterator erase(iterator pos)
Erase the record pointed to by pos, and return an iterator the next record.
void reserve(size_type n)
Increase the capacity of the catalog to the given size.
reference front() const
Return the first record.
void sort(Key< T > const &key)
Sort the catalog in-place by the field with the given key.
std::shared_ptr< Table > getTable() const
Return the table associated with the catalog.
void insert(iterator pos, InputIterator first, InputIterator last, bool deep=false)
Insert an iterator range into the table.
Schema getSchema() const
Return the schema associated with the catalog's table.
Defines the fields and offsets for a table.
int getFieldCount() const
The total number of fields.
int contains(Schema const &other, int flags=EQUAL_KEYS) const
Test whether the given schema is a subset of this.
A mapping between the keys of two Schemas, used to copy data between them.
A vector of catalogs used by Persistable.
An object passed to Persistable::write to allow it to persist itself.
void saveCatalog(BaseCatalog const &catalog)
Save a catalog in the archive.
BaseCatalog makeCatalog(Schema const &schema)
Return a new, empty catalog with the given schema.
int put(Persistable const *obj, bool permissive=false)
Save an object to the archive and return a unique ID that can be used to retrieve it from an InputArc...
A base class for factory classes used to reconstruct objects from records.
PersistableFactory(std::string const &name)
Constructor for the factory.
An integer coordinate rectangle.
int getMinY() const noexcept
int getHeight() const noexcept
int getMinX() const noexcept
Reports invalid arguments.
Reports errors in the logical structure of the program.
T emplace_back(T... args)
const char * source()
Source function that allows astChannel to source from a Stream.
afw::table::CatalogT< PeakRecord > PeakCatalog
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...
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.
std::shared_ptr< TransformPoint2ToPoint2 > makeTransform(lsst::geom::AffineTransform const &affine)
Wrap an lsst::geom::AffineTransform as a Transform.
Stencil
An enumeration class which describes the shapes.
std::shared_ptr< TransformPoint2ToPoint2 > makeWcsPairTransform(SkyWcs const &src, SkyWcs const &dst)
A Transform obtained by putting two SkyWcs objects "back to back".
Transform< Point2Endpoint, Point2Endpoint > TransformPoint2ToPoint2
FilterProperty & operator=(FilterProperty const &)=default
lsst::afw::detection::Footprint Footprint
A base class for image defects.