33 : daf::base::Citizen(typeid(this)),
40 : daf::base::
Citizen(typeid(this)), _spans(inputSpans), _peaks(peakSchema), _region(region) {}
50 p->setPeakValue(height);
57 return a.
get(validatedKey) > b.
get(validatedKey);
64 peak.setIx(peak.getIx() + dx);
65 peak.setIy(peak.getIy() + dy);
66 peak.setFx(peak.getFx() + dx);
67 peak.setFy(peak.getFy() + dy);
83 return transform(xyTransform, region, doClip);
99 auto transformedSpan =
getSpans()->transformedBy(t);
101 auto newFootprint = std::make_shared<Footprint>(transformedSpan,
getPeaks().
getSchema(), region);
103 for (
auto const& peak :
getPeaks()) {
106 newFootprint->addPeak(newPoint.getX(), newPoint.getY(), peak.getPeakValue());
109 newFootprint->clipTo(region);
138 auto splitSpanSets =
getSpans()->split();
140 footprintList.
reserve(splitSpanSets.size());
141 for (
auto& spanPtr : splitSpanSets) {
143 tmpFootprintPointer->_peaks =
getPeaks();
146 if (splitSpanSets.size() > 1) {
147 tmpFootprintPointer->removeOrphanPeaks();
151 return footprintList;
162 for (
auto const& selfPeak :
getPeaks()) {
164 for (
auto const& otherPeak : other.
getPeaks()) {
165 if (selfPeak.getI() == otherPeak.getI() && selfPeak.getF() == otherPeak.getF() &&
166 selfPeak.getPeakValue() == otherPeak.getPeakValue()) {
181 std::string getFootprintPersistenceName() {
return "Footprint"; }
183 class LegacyFootprintPersistenceHelper {
190 static LegacyFootprintPersistenceHelper
const&
get() {
191 static LegacyFootprintPersistenceHelper instance;
196 LegacyFootprintPersistenceHelper(
const LegacyFootprintPersistenceHelper&) =
delete;
197 LegacyFootprintPersistenceHelper&
operator=(
const LegacyFootprintPersistenceHelper&) =
delete;
200 LegacyFootprintPersistenceHelper(LegacyFootprintPersistenceHelper&&) =
delete;
201 LegacyFootprintPersistenceHelper&
operator=(LegacyFootprintPersistenceHelper&&) =
delete;
204 LegacyFootprintPersistenceHelper()
206 spanY(spanSchema.addField<
int>(
"y",
"The row of the span",
"pixel")),
207 spanX0(spanSchema.addField<
int>(
"x0",
"First column of span (inclusive)",
"pixel")),
208 spanX1(spanSchema.addField<
int>(
"x1",
"Second column of span (inclusive)",
"pixel")) {
209 spanSchema.getCitizen().markPersistent();
214 static afw::table::Schema spanSetIdSchema;
215 static int initialize =
true;
216 static table::Key<int> idKey;
218 idKey = spanSetIdSchema.addField<
int>(
"id",
"id of the SpanSet catalog");
220 spanSetIdSchema.getCitizen().markPersistent();
238 return loadedFootprint;
254 auto const keys = spanSetPersistenceHelper();
258 auto record = spanSetCat.
addNew();
272 if (fieldCount == 1) {
274 auto const schemaAndKey = spanSetPersistenceHelper();
275 int persistedSpanSetId = catalog.
front().get(schemaAndKey.second);
279 auto const& keys = LegacyFootprintPersistenceHelper::get();
282 for (
auto const& val : catalog) {
283 tempVec.
push_back(
geom::Span(val.get(keys.spanY), val.get(keys.spanX0), val.get(keys.spanX1)));
285 loadedSpanSet = std::make_shared<geom::SpanSet>(
std::move(tempVec));
288 return loadedFootprint;
299 mapper.addMapping(oldX,
"f.x");
300 mapper.addMapping(oldY,
"f.y");
301 mapper.addMapping(oldPeakValue,
"peakValue");
303 auto peaks = loadedFootprint.
getPeaks();
305 for (
auto const& peak : peakCat) {
306 auto newPeak = peaks.addNew();
307 newPeak->assign(peak, mapper);
308 newPeak->setIx(static_cast<int>(newPeak->getFx()));
309 newPeak->setIy(static_cast<int>(newPeak->getFy()));
314 auto& peaks = loadedFootprint.
getPeaks();
316 for (
auto const& peak : peakCat) {
317 peaks.addNew()->assign(peak);
325 "Cannot merge Footprints with different Schemas");
329 auto unionedSpanSet = footprint1.
getSpans()->union_(*(footprint2.
getSpans()));
332 auto mergedFootprint = std::make_shared<Footprint>(unionedSpanSet, footprint1.
getPeaks().
getSchema());
341 mergedFootprint->sortPeaks();
343 return mergedFootprint;
353 footprint.
getSpans()->setImage(*idImage, static_cast<PixelT>(1), fpBBox,
true);
370 while (y0 < height) {
372 for (
int y = y0; y != height; ++y) {
379 int const x0 = first - begin;
380 int const x1 = last - begin;
388 for (++y; y != height; ++y) {
389 if (
std::find(idImage->at(x0, y), idImage->at(x1 + 1, y), 0) != idImage->at(x1 + 1, y)) {
392 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...
table::Key< std::string > name
void shift(Extent2I const &offset)
Shift the position of the box by the given offset.
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 custom container class for records, based on std::vector.
#define LSST_ARCHIVE_ASSERT(EXPR)
An assertion macro used to validate the structure of an InputArchive.
A compact representation of a collection of pixels.
A mapping between the keys of two Schemas, used to copy data between them.
A range of pixels within one row of an Image.
void include(Point2I const &point)
Expand this to ensure that this->contains(point).
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.
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.
An integer coordinate rectangle.
bool isValid() const
Return true if the key was initialized to valid offset.
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...
T dynamic_pointer_cast(T... args)
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.
#define LSST_EXCEPT(type,...)
A vector of catalogs used by Persistable.
void addMinimalSchema(Schema const &minimal, bool doMap=true)
Add the given minimal schema to the output schema.
Citizen(const std::type_info &)
std::vector< lsst::afw::geom::Box2I > footprintToBBoxList(Footprint const &footprint)
Return a list of BBoxs, whose union contains exactly the pixels in the footprint, neither more nor le...
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.
A class to represent a 2-dimensional array of pixels.
std::shared_ptr< RecordT > addNew()
Create a new record, add it to the end of the catalog, and return a pointer to it.