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);
108 peakPosList.emplace_back(
peak.getF());
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) {
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()
214 spanY(spanSchema.addField<
int>(
"y",
"The row of the span",
"pixel")),
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;
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);
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;
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;
394 for (++
y;
y != height; ++
y) {
395 if (
std::find(idImage->at(x0,
y), idImage->at(x1 + 1,
y), 0) != idImage->at(x1 + 1,
y)) {
398 std::fill(idImage->at(x0,
y), idImage->at(x1 + 1,
y), 0);
Defines the fields and offsets for a table.
Stencil
An enumeration class which describes the shapes.
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...
int getHeight() const noexcept
Key< Flag > const & target
An object passed to Persistable::write to allow it to persist itself.
static afw::table::Schema makeMinimalSchema()
Return a minimal schema for Peak tables and records.
A mapping between the keys of two Schemas, used to copy data between them.
#define LSST_ARCHIVE_ASSERT(EXPR)
An assertion macro used to validate the structure of an InputArchive.
A base class for factory classes used to reconstruct objects from records.
std::shared_ptr< Table > getTable() const
Return the table associated with the catalog.
Table class for Peaks in Footprints.
void sort(Key< T > const &key)
Sort the catalog in-place by the field with the given key.
_view_t::x_iterator x_iterator
An iterator for traversing the pixels in a row.
Schema getSchema() const
Return the schema associated with the catalog's table.
ItemVariant const * other
void insert(iterator pos, InputIterator first, InputIterator last, bool deep=false)
Insert an iterator range into the table.
static afw::table::Key< float > getPeakValueKey()
Get keys for standard fields shared by all peaks.
Field< T >::Value get(Key< T > const &key) const
Return the value of a field for the given key.
bool isValid() const noexcept
Return true if the key was initialized to valid offset.
Transform< Point2Endpoint, Point2Endpoint > TransformPoint2ToPoint2
A base class for image defects.
afw::table::CatalogT< PeakRecord > PeakCatalog
reference front() const
Return the first record.
int contains(Schema const &other, int flags=EQUAL_KEYS) const
Test whether the given schema is a subset of this.
iterator end()
Iterator access.
iterator erase(iterator pos)
Erase the record pointed to by pos, and return an iterator the next record.
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...
const char * source()
Source function that allows astChannel to source from a Stream.
T dynamic_pointer_cast(T... args)
Reports errors in the logical structure of the program.
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...
int getFieldCount() const
The total number of fields.
BaseCatalog makeCatalog(Schema const &schema)
Return a new, empty catalog with the given schema.
void reserve(size_type n)
Increase the capacity of the catalog to the given size.
int getMinX() const noexcept
std::shared_ptr< TransformPoint2ToPoint2 > makeWcsPairTransform(SkyWcs const &src, SkyWcs const &dst)
A Transform obtained by putting two SkyWcs objects "back to back".
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
A vector of catalogs used by Persistable.
void include(Point2I const &point)
Expand this to ensure that this->contains(point).
void shift(Extent2I const &offset)
Shift the position of the box by the given offset.
lsst::afw::detection::Footprint Footprint
Reports invalid arguments.
size_type size() const
Return the number of elements in the catalog.
void saveCatalog(BaseCatalog const &catalog)
Save a catalog in the archive.
iterator begin()
Iterator access.
Record class that represents a peak in a Footprint.
An integer coordinate rectangle.
A class to represent a 2-dimensional array of pixels.
int getMinY() const noexcept
std::shared_ptr< TransformPoint2ToPoint2 > makeTransform(lsst::geom::AffineTransform const &affine)
Wrap an lsst::geom::AffineTransform as a Transform.
std::shared_ptr< RecordT > addNew()
Create a new record, add it to the end of the catalog, and return a pointer to it.