28 #include "lsst/afw/table/io/Persistable.cc" 39 : daf::
base::Citizen(typeid(this)),
46 : daf::
base::
Citizen(typeid(this)), _spans(inputSpans), _peaks(peakSchema), _region(region) {}
56 p->setPeakValue(height);
63 return a.
get(validatedKey) > b.
get(validatedKey);
70 peak.setIx(peak.getIx() + dx);
71 peak.setIy(peak.getIy() + dy);
72 peak.setFx(peak.getFx() + dx);
73 peak.setFy(peak.getFy() + dy);
88 return transform(*srcToTarget, region, doClip);
104 auto transformedSpan =
getSpans()->transformedBy(t);
106 auto newFootprint = std::make_shared<Footprint>(transformedSpan,
getPeaks().
getSchema(), region);
110 for (
auto const& peak :
getPeaks()) {
111 peakPosList.emplace_back(peak.getF());
114 auto newPeakPos = newPeakPosList.cbegin();
115 for (
auto peak =
getPeaks().cbegin(), endPeak =
getPeaks().cend(); peak != endPeak;
116 ++peak, ++newPeakPos) {
117 newFootprint->addPeak(newPeakPos->getX(), newPeakPos->getY(), peak->getPeakValue());
120 newFootprint->clipTo(region);
149 auto splitSpanSets =
getSpans()->split();
151 footprintList.
reserve(splitSpanSets.size());
152 for (
auto& spanPtr : splitSpanSets) {
154 tmpFootprintPointer->_peaks =
getPeaks();
157 if (splitSpanSets.size() > 1) {
158 tmpFootprintPointer->removeOrphanPeaks();
162 return footprintList;
173 for (
auto const& selfPeak :
getPeaks()) {
175 for (
auto const& otherPeak : other.
getPeaks()) {
176 if (selfPeak.getI() == otherPeak.getI() && selfPeak.getF() == otherPeak.getF() &&
177 selfPeak.getPeakValue() == otherPeak.getPeakValue()) {
192 std::string getFootprintPersistenceName() {
return "Footprint"; }
194 class LegacyFootprintPersistenceHelper {
201 static LegacyFootprintPersistenceHelper
const&
get() {
202 static LegacyFootprintPersistenceHelper instance;
207 LegacyFootprintPersistenceHelper(
const LegacyFootprintPersistenceHelper&) =
delete;
208 LegacyFootprintPersistenceHelper&
operator=(
const LegacyFootprintPersistenceHelper&) =
delete;
211 LegacyFootprintPersistenceHelper(LegacyFootprintPersistenceHelper&&) =
delete;
212 LegacyFootprintPersistenceHelper&
operator=(LegacyFootprintPersistenceHelper&&) =
delete;
215 LegacyFootprintPersistenceHelper()
217 spanY(spanSchema.addField<
int>(
"y",
"The row of the span",
"pixel")),
218 spanX0(spanSchema.addField<
int>(
"x0",
"First column of span (inclusive)",
"pixel")),
219 spanX1(spanSchema.addField<
int>(
"x1",
"Second column of span (inclusive)",
"pixel")) {
220 spanSchema.getCitizen().markPersistent();
225 static afw::table::Schema spanSetIdSchema;
226 static int initialize =
true;
227 static table::Key<int> idKey;
229 idKey = spanSetIdSchema.addField<
int>(
"id",
"id of the SpanSet catalog");
231 spanSetIdSchema.getCitizen().markPersistent();
249 return loadedFootprint;
265 auto const keys = spanSetPersistenceHelper();
269 auto record = spanSetCat.
addNew();
283 if (fieldCount == 1) {
285 auto const schemaAndKey = spanSetPersistenceHelper();
286 int persistedSpanSetId = catalog.
front().
get(schemaAndKey.second);
290 auto const&
keys = LegacyFootprintPersistenceHelper::get();
293 for (
auto const&
val : catalog) {
296 loadedSpanSet = std::make_shared<geom::SpanSet>(
std::move(tempVec));
299 return loadedFootprint;
311 mapper.addMapping(oldX,
"f.x"s);
312 mapper.addMapping(oldY,
"f.y"s);
313 mapper.addMapping(oldPeakValue,
"peakValue"s);
315 auto peaks = loadedFootprint.
getPeaks();
317 for (
auto const& peak : peakCat) {
318 auto newPeak = peaks.addNew();
319 newPeak->assign(peak,
mapper);
320 newPeak->setIx(static_cast<int>(newPeak->getFx()));
321 newPeak->setIy(static_cast<int>(newPeak->getFy()));
326 auto& peaks = loadedFootprint.
getPeaks();
328 for (
auto const& peak : peakCat) {
329 peaks.addNew()->assign(peak);
337 "Cannot merge Footprints with different Schemas");
341 auto unionedSpanSet = footprint1.
getSpans()->union_(*(footprint2.
getSpans()));
344 auto mergedFootprint = std::make_shared<Footprint>(unionedSpanSet, footprint1.
getPeaks().
getSchema());
353 mergedFootprint->sortPeaks();
355 return mergedFootprint;
365 footprint.
getSpans()->setImage(*idImage, static_cast<PixelT>(1), fpBBox,
true);
382 while (y0 < height) {
384 for (
int y = y0;
y != height; ++
y) {
391 int const x0 = first - begin;
392 int const x1 = last - begin;
400 for (++
y;
y != height; ++
y) {
401 if (
std::find(idImage->at(x0,
y), idImage->at(x1 + 1,
y), 0) != idImage->at(x1 + 1,
y)) {
404 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
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 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.
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.
bool isValid() const noexcept
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...
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.
Key< Flag > const & target
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.
Citizen(const std::type_info &)
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.
#define LSST_ARCHIVE_ASSERT(EXPR)
An assertion macro used to validate the structure of an InputArchive.
lsst::afw::detection::Footprint Footprint
Reports invalid arguments.
size_type size() const
Return the number of elements in the catalog.
ItemVariant const * other
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.