LSSTApplications  18.1.0
LSSTDataManagementBasePackage
Footprint.cc
Go to the documentation of this file.
1 
2 /*
3  * LSST Data Management System
4  * Copyright 2008-2016 AURA/LSST.
5  *
6  * This product includes software developed by the
7  * LSST Project (http://www.lsst.org/).
8  *
9  * This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the LSST License Statement and
20  * the GNU General Public License along with this program. If not,
21  * see <https://www.lsstcorp.org/LegalNotices/>.
22  */
23 
28 #include "lsst/afw/table/io/Persistable.cc"
29 
30 namespace lsst {
31 namespace afw {
32 
33 template std::shared_ptr<detection::Footprint> table::io::PersistableFacade<
35 
36 namespace detection {
37 
39  : daf::base::Citizen(typeid(this)),
40  _spans(inputSpans),
41  _peaks(PeakTable::makeMinimalSchema()),
42  _region(region) {}
43 
46  : daf::base::Citizen(typeid(this)), _spans(inputSpans), _peaks(peakSchema), _region(region) {}
47 
48 void Footprint::setSpans(std::shared_ptr<geom::SpanSet> otherSpanSet) { _spans = otherSpanSet; }
49 
50 std::shared_ptr<PeakRecord> Footprint::addPeak(float fx, float fy, float height) {
52  p->setIx(fx);
53  p->setIy(fy);
54  p->setFx(fx);
55  p->setFy(fy);
56  p->setPeakValue(height);
57  return p;
58 }
59 
61  auto validatedKey = key.isValid() ? key : PeakTable::getPeakValueKey();
62  getPeaks().sort([&validatedKey](detection::PeakRecord const& a, detection::PeakRecord const& b) {
63  return a.get(validatedKey) > b.get(validatedKey);
64  });
65 }
66 
67 void Footprint::shift(int dx, int dy) {
68  setSpans(getSpans()->shiftedBy(dx, dy));
69  for (auto& peak : getPeaks()) {
70  peak.setIx(peak.getIx() + dx);
71  peak.setIy(peak.getIy() + dy);
72  peak.setFx(peak.getFx() + dx);
73  peak.setFy(peak.getFy() + dy);
74  }
75 }
76 
78  setSpans(getSpans()->clippedTo(box));
80 }
81 
82 bool Footprint::contains(lsst::geom::Point2I const& pix) const { return getSpans()->contains(pix); }
83 
86  lsst::geom::Box2I const& region, bool doClip) const {
87  auto srcToTarget = geom::makeWcsPairTransform(*source, *target);
88  return transform(*srcToTarget, region, doClip);
89 }
90 
92  lsst::geom::Box2I const& region, bool doClip) const {
93  return transform(lsst::geom::AffineTransform(t), region, doClip);
94 }
95 
97  lsst::geom::Box2I const& region, bool doClip) const {
98  return transform(*geom::makeTransform(t), region, doClip);
99 }
100 
102  lsst::geom::Box2I const& region, bool doClip) const {
103  // Transfrom the SpanSet first
104  auto transformedSpan = getSpans()->transformedBy(t);
105  // Use this new SpanSet and the peakSchema to create a new Footprint
106  auto newFootprint = std::make_shared<Footprint>(transformedSpan, getPeaks().getSchema(), region);
107  // now populate the new Footprint with transformed Peaks
109  peakPosList.reserve(_peaks.size());
110  for (auto const& peak : getPeaks()) {
111  peakPosList.emplace_back(peak.getF());
112  }
113  auto newPeakPosList = t.applyForward(peakPosList);
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());
118  }
119  if (doClip) {
120  newFootprint->clipTo(region);
121  }
122  return newFootprint;
123 }
124 
125 void Footprint::dilate(int r, geom::Stencil s) { setSpans(getSpans()->dilated(r, s)); }
126 
127 void Footprint::dilate(geom::SpanSet const& other) { setSpans(getSpans()->dilated(other)); }
128 
130  setSpans(getSpans()->eroded(r, s));
132 }
133 
135  setSpans(getSpans()->eroded(other));
137 }
138 
140  for (auto iter = getPeaks().begin(); iter != getPeaks().end(); ++iter) {
141  if (!getSpans()->contains(lsst::geom::Point2I(iter->getIx(), iter->getIy()))) {
142  iter = getPeaks().erase(iter);
143  --iter;
144  }
145  }
146 }
147 
149  auto splitSpanSets = getSpans()->split();
151  footprintList.reserve(splitSpanSets.size());
152  for (auto& spanPtr : splitSpanSets) {
153  auto tmpFootprintPointer = std::make_shared<Footprint>(spanPtr, getPeaks().getSchema(), getRegion());
154  tmpFootprintPointer->_peaks = getPeaks();
155  // No need to remove any peaks, as there is only one Footprint, so it will
156  // simply be a copy of the original
157  if (splitSpanSets.size() > 1) {
158  tmpFootprintPointer->removeOrphanPeaks();
159  }
160  footprintList.push_back(std::move(tmpFootprintPointer));
161  }
162  return footprintList;
163 }
164 
166  /* If the peakCatalogs are not the same length the Footprints can't be equal */
167  if (getPeaks().size() != other.getPeaks().size()) {
168  return false;
169  }
170  /* Check that for every peak in the PeakCatalog there is a corresponding peak
171  * in the other, and if not return false
172  */
173  for (auto const& selfPeak : getPeaks()) {
174  bool match = false;
175  for (auto const& otherPeak : other.getPeaks()) {
176  if (selfPeak.getI() == otherPeak.getI() && selfPeak.getF() == otherPeak.getF() &&
177  selfPeak.getPeakValue() == otherPeak.getPeakValue()) {
178  match = true;
179  break;
180  }
181  }
182  if (!match) {
183  return false;
184  }
185  }
186  /* At this point the PeakCatalogs have evaluated true, compare the SpanSets
187  */
188  return *(getSpans()) == *(other.getSpans());
189 }
190 
191 namespace {
192 std::string getFootprintPersistenceName() { return "Footprint"; }
193 
194 class LegacyFootprintPersistenceHelper {
195 public:
196  table::Schema spanSchema;
197  table::Key<int> spanY;
198  table::Key<int> spanX0;
199  table::Key<int> spanX1;
200 
201  static LegacyFootprintPersistenceHelper const& get() {
202  static LegacyFootprintPersistenceHelper instance;
203  return instance;
204  }
205 
206  // No copying
207  LegacyFootprintPersistenceHelper(const LegacyFootprintPersistenceHelper&) = delete;
208  LegacyFootprintPersistenceHelper& operator=(const LegacyFootprintPersistenceHelper&) = delete;
209 
210  // No moving
211  LegacyFootprintPersistenceHelper(LegacyFootprintPersistenceHelper&&) = delete;
212  LegacyFootprintPersistenceHelper& operator=(LegacyFootprintPersistenceHelper&&) = delete;
213 
214 private:
215  LegacyFootprintPersistenceHelper()
216  : spanSchema(),
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();
221  }
222 };
223 
224 std::pair<afw::table::Schema&, table::Key<int>&> spanSetPersistenceHelper() {
225  static afw::table::Schema spanSetIdSchema;
226  static int initialize = true;
227  static table::Key<int> idKey;
228  if (initialize) {
229  idKey = spanSetIdSchema.addField<int>("id", "id of the SpanSet catalog");
230  initialize = false;
231  spanSetIdSchema.getCitizen().markPersistent();
232  }
233  std::pair<afw::table::Schema&, table::Key<int>&> returnPair(spanSetIdSchema, idKey);
234  return returnPair;
235 }
236 } // end anonymous namespace
237 
239 public:
241  afw::table::io::InputArchive const& archive,
242  afw::table::io::CatalogVector const& catalogs) const override {
243  // Verify there are two catalogs
244  LSST_ARCHIVE_ASSERT(catalogs.size() == 2u);
245  std::shared_ptr<Footprint> loadedFootprint =
246  detection::Footprint::readSpanSet(catalogs.front(), archive);
247  // Now read in the PeakCatalog records
248  detection::Footprint::readPeaks(catalogs.back(), *loadedFootprint);
249  return loadedFootprint;
250  }
251 
252  explicit FootprintFactory(std::string const& name) : afw::table::io::PersistableFactory(name) {}
253 };
254 
255 namespace {
256 // Insert the factory into the registry (instantiating an instance is sufficient, because the
257 // the code that does the work is in the base class ctor)
258 FootprintFactory registration(getFootprintPersistenceName());
259 } // end anonymous namespace
260 
261 std::string Footprint::getPersistenceName() const { return getFootprintPersistenceName(); }
262 
264  // get the span schema and key
265  auto const keys = spanSetPersistenceHelper();
266  // create the output catalog
267  afw::table::BaseCatalog spanSetCat = handle.makeCatalog(keys.first);
268  // create a record that will hold the ID of the recursively saved SpanSet
269  auto record = spanSetCat.addNew();
270  record->set(keys.second, handle.put(getSpans()));
271  handle.saveCatalog(spanSetCat);
272  // save the peaks into a catalog
273  afw::table::BaseCatalog peakCat = handle.makeCatalog(getPeaks().getSchema());
274  peakCat.insert(peakCat.end(), getPeaks().begin(), getPeaks().end(), true);
275  handle.saveCatalog(peakCat);
276 }
277 
279  afw::table::io::InputArchive const& archive) {
280  int fieldCount = catalog.getSchema().getFieldCount();
281  LSST_ARCHIVE_ASSERT(fieldCount == 1 || fieldCount == 3);
282  std::shared_ptr<geom::SpanSet> loadedSpanSet;
283  if (fieldCount == 1) {
284  // This is a new style footprint with a SpanSet as a member, treat accordingly
285  auto const schemaAndKey = spanSetPersistenceHelper();
286  int persistedSpanSetId = catalog.front().get(schemaAndKey.second);
287  loadedSpanSet = std::dynamic_pointer_cast<geom::SpanSet>(archive.get(persistedSpanSetId));
288  } else {
289  // This block is for an old style footprint load.
290  auto const& keys = LegacyFootprintPersistenceHelper::get();
291  std::vector<geom::Span> tempVec;
292  tempVec.reserve(catalog.size());
293  for (auto const& val : catalog) {
294  tempVec.push_back(geom::Span(val.get(keys.spanY), val.get(keys.spanX0), val.get(keys.spanX1)));
295  }
296  loadedSpanSet = std::make_shared<geom::SpanSet>(std::move(tempVec));
297  }
298  auto loadedFootprint = std::unique_ptr<Footprint>(new Footprint(loadedSpanSet));
299  return loadedFootprint;
300 }
301 
302 void Footprint::readPeaks(afw::table::BaseCatalog const& peakCat, Footprint& loadedFootprint) {
303  using namespace std::string_literals;
304  if (!peakCat.getSchema().contains(PeakTable::makeMinimalSchema())) {
305  // need to handle an older form of Peak persistence for backwards compatibility
307  mapper.addMinimalSchema(PeakTable::makeMinimalSchema());
308  afw::table::Key<float> oldX = peakCat.getSchema()["x"];
309  afw::table::Key<float> oldY = peakCat.getSchema()["y"];
310  afw::table::Key<float> oldPeakValue = peakCat.getSchema()["value"];
311  mapper.addMapping(oldX, "f.x"s);
312  mapper.addMapping(oldY, "f.y"s);
313  mapper.addMapping(oldPeakValue, "peakValue"s);
314  loadedFootprint.setPeakSchema(mapper.getOutputSchema());
315  auto peaks = loadedFootprint.getPeaks();
316  peaks.reserve(peakCat.size());
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()));
322  }
323  return;
324  }
325  loadedFootprint.setPeakSchema(peakCat.getSchema());
326  auto& peaks = loadedFootprint.getPeaks();
327  peaks.reserve(peakCat.size());
328  for (auto const& peak : peakCat) {
329  peaks.addNew()->assign(peak);
330  }
331 }
332 
333 std::shared_ptr<Footprint> mergeFootprints(Footprint const& footprint1, Footprint const& footprint2) {
334  // Bail out early if the schemas are not the same
335  if (footprint1.getPeaks().getSchema() != footprint2.getPeaks().getSchema()) {
337  "Cannot merge Footprints with different Schemas");
338  }
339 
340  // Merge the SpanSets
341  auto unionedSpanSet = footprint1.getSpans()->union_(*(footprint2.getSpans()));
342 
343  // Construct merged Footprint
344  auto mergedFootprint = std::make_shared<Footprint>(unionedSpanSet, footprint1.getPeaks().getSchema());
345  // Copy over the peaks from both footprints
346  mergedFootprint->setPeakCatalog(PeakCatalog(footprint1.getPeaks().getTable()));
347  PeakCatalog& peaks = mergedFootprint->getPeaks();
348  peaks.reserve(footprint1.getPeaks().size() + footprint2.getPeaks().size());
349  peaks.insert(peaks.end(), footprint1.getPeaks().begin(), footprint1.getPeaks().end(), true);
350  peaks.insert(peaks.end(), footprint2.getPeaks().begin(), footprint2.getPeaks().end(), true);
351 
352  // Sort the PeaksCatalog according to value
353  mergedFootprint->sortPeaks();
354 
355  return mergedFootprint;
356 }
357 
359  typedef std::uint16_t PixelT;
360  lsst::geom::Box2I fpBBox = footprint.getBBox();
362  *idImage = 0;
363  int const height = fpBBox.getHeight();
364  lsst::geom::Extent2I shift(fpBBox.getMinX(), fpBBox.getMinY());
365  footprint.getSpans()->setImage(*idImage, static_cast<PixelT>(1), fpBBox, true);
366 
368  /*
369  * Our strategy is to find a row of pixels in the Footprint and interpret it as the first
370  * row of a rectangular set of pixels. We then extend this rectangle upwards as far as it
371  * will go, and define that as a BBox. We clear all those pixels, and repeat until there
372  * are none left. I.e. a Footprint will get cut up like this:
373  *
374  * .555...
375  * 22.3314
376  * 22.331.
377  * .000.1.
378  * (as shown in Footprint_1.py)
379  */
380 
381  int y0 = 0; // the first row with non-zero pixels in it
382  while (y0 < height) {
383  lsst::geom::Box2I bbox; // our next BBox
384  for (int y = y0; y != height; ++y) {
385  // Look for a set pixel in this row
386  image::Image<PixelT>::x_iterator begin = idImage->row_begin(y), end = idImage->row_end(y);
388 
389  if (first != end) { // A pixel is set in this row
390  image::Image<PixelT>::x_iterator last = std::find(first, end, 0) - 1;
391  int const x0 = first - begin;
392  int const x1 = last - begin;
393 
394  std::fill(first, last + 1, 0); // clear pixels; we don't want to see them again
395 
396  bbox.include(lsst::geom::Point2I(x0, y)); // the LLC
397  bbox.include(lsst::geom::Point2I(x1, y)); // the LRC; initial guess for URC
398 
399  // we found at least one pixel so extend the BBox upwards
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)) {
402  break; // some pixels weren't set, so the BBox stops here, (actually in previous row)
403  }
404  std::fill(idImage->at(x0, y), idImage->at(x1 + 1, y), 0);
405 
406  bbox.include(lsst::geom::Point2I(x1, y)); // the new URC
407  }
408 
409  bbox.shift(shift);
410  bboxes.push_back(bbox);
411  } else {
412  y0 = y + 1;
413  }
414  break;
415  }
416  }
417 
418  return bboxes;
419 }
420 
422  setPeakCatalog(PeakCatalog(peakSchema));
423 }
424 
425 void Footprint::setPeakCatalog(PeakCatalog const& otherPeaks) {
426  if (!getPeaks().empty()) {
427  throw LSST_EXCEPT(pex::exceptions::LogicError, "Cannot change the PeakCatalog unless it is empty");
428  }
429  // this syntax doesn't work in Python, which is why this method has to exist
430  getPeaks() = otherPeaks;
431 }
432 } // namespace detection
433 } // namespace afw
434 } // namespace lsst
Defines the fields and offsets for a table.
Definition: Schema.h:50
ToPoint applyForward(FromPoint const &point) const
Transform one point in the forward direction ("from" to "to")
Definition: Transform.cc:79
Stencil
An enumeration class which describes the shapes.
Definition: SpanSet.h:66
std::vector< std::shared_ptr< Footprint > > split() const
Split a multi-component Footprint into a vector of contiguous Footprints.
Definition: Footprint.cc:148
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
Definition: Box.h:175
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.
Definition: Peak.h:137
An affine coordinate transformation consisting of a linear transformation and an offset.
T front(T... args)
A compact representation of a collection of pixels.
Definition: SpanSet.h:77
A mapping between the keys of two Schemas, used to copy data between them.
Definition: SchemaMapper.h:21
A range of pixels within one row of an Image.
Definition: Span.h:47
A base class for factory classes used to reconstruct objects from records.
Definition: Persistable.h:228
table::Key< int > b
std::shared_ptr< Table > getTable() const
Return the table associated with the catalog.
Definition: Catalog.h:114
Table class for Peaks in Footprints.
Definition: Peak.h:102
void setPeakSchema(afw::table::Schema const &peakSchema)
Set the Schema used by the PeakCatalog (will throw if PeakCatalog is not empty).
Definition: Footprint.cc:421
void sort(Key< T > const &key)
Sort the catalog in-place by the field with the given key.
Definition: Catalog.h:749
_view_t::x_iterator x_iterator
An iterator for traversing the pixels in a row.
Definition: ImageBase.h:134
int y
Definition: SpanSet.cc:49
table::Key< int > a
table::Key< int > spanX1
Definition: Footprint.cc:199
ImageT val
Definition: CR.cc:146
Schema getSchema() const
Return the schema associated with the catalog&#39;s table.
Definition: Catalog.h:117
static void readPeaks(afw::table::BaseCatalog const &, Footprint &)
Static method used to unpersist the PeakCatalog member of the Footprint class.
Definition: Footprint.cc:302
void insert(iterator pos, InputIterator first, InputIterator last, bool deep=false)
Insert an iterator range into the table.
Definition: Catalog.h:513
static afw::table::Key< float > getPeakValueKey()
Get keys for standard fields shared by all peaks.
Definition: Peak.h:169
Field< T >::Value get(Key< T > const &key) const
Return the value of a field for the given key.
Definition: BaseRecord.h:151
Footprint & operator=(Footprint const &other)=default
bool isValid() const noexcept
Return true if the key was initialized to valid offset.
Definition: Key.h:97
STL class.
lsst::geom::Box2I getBBox() const
Return the Footprint&#39;s bounding box.
Definition: Footprint.h:210
std::shared_ptr< Footprint > transform(std::shared_ptr< geom::SkyWcs > source, std::shared_ptr< geom::SkyWcs > target, lsst::geom::Box2I const &region, bool doClip=true) const
Transform the footprint from one WCS to another.
Definition: Footprint.cc:84
T push_back(T... args)
table::Key< int > spanX0
Definition: Footprint.cc:198
A base class for image defects.
afw::table::CatalogT< PeakRecord > PeakCatalog
Definition: Peak.h:244
reference front() const
Return the first record.
Definition: Catalog.h:453
void clipTo(lsst::geom::Box2I const &bbox)
Clip the Footprint such that all values lie inside the supplied Bounding Box.
Definition: Footprint.cc:77
int contains(Schema const &other, int flags=EQUAL_KEYS) const
Test whether the given schema is a subset of this.
Definition: Schema.cc:679
iterator end()
Iterator access.
Definition: Catalog.h:397
#define LSST_ARCHIVE_ASSERT(EXPR)
An assertion macro used to validate the structure of an InputArchive.
Definition: Persistable.h:48
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:278
void dilate(int r, geom::Stencil s=geom::Stencil::CIRCLE)
Dilate the Footprint with a defined kernel.
Definition: Footprint.cc:125
std::string getPersistenceName() const override
Return the name correspoinging ot the persistence type.
Definition: Footprint.cc:261
iterator erase(iterator pos)
Erase the record pointed to by pos, and return an iterator the next record.
Definition: Catalog.h:560
table::Key< int > spanY
Definition: Footprint.cc:197
std::shared_ptr< afw::table::io::Persistable > read(afw::table::io::InputArchive const &archive, afw::table::io::CatalogVector const &catalogs) const override
Construct a new object from the given InputArchive and vector of catalogs.
Definition: Footprint.cc:240
void setSpans(std::shared_ptr< geom::SpanSet > otherSpanSet)
Sets the shared pointer to the SpanSet in the Footprint.
Definition: Footprint.cc:48
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:333
bool contains(lsst::geom::Point2I const &pix) const
Tests if a pixel postion falls inside the Footprint.
Definition: Footprint.cc:82
const char * source()
Source function that allows astChannel to source from a Stream.
Definition: Stream.h:224
T dynamic_pointer_cast(T... args)
Reports errors in the logical structure of the program.
Definition: Runtime.h:46
table::Box2IKey bbox
Definition: Detector.cc:169
Key< Flag > const & target
solver_t * s
T move(T... args)
Class to describe the properties of a detected object from an image.
Definition: Footprint.h:62
void shift(int dx, int dy)
Shift a Footprint by (dx, dy)
Definition: Footprint.cc:67
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:358
int getFieldCount() const
The total number of fields.
Definition: Schema.h:151
BaseCatalog makeCatalog(Schema const &schema)
Return a new, empty catalog with the given schema.
void setPeakCatalog(PeakCatalog const &otherPeaks)
Set the peakCatalog to a copy of the supplied catalog.
Definition: Footprint.cc:425
void reserve(size_type n)
Increase the capacity of the catalog to the given size.
Definition: Catalog.h:428
int getMinX() const noexcept
Definition: Box.h:144
T find(T... args)
T size(T... args)
std::shared_ptr< TransformPoint2ToPoint2 > makeWcsPairTransform(SkyWcs const &src, SkyWcs const &dst)
A Transform obtained by putting two SkyWcs objects "back to back".
Definition: SkyWcs.cc:152
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
A vector of catalogs used by Persistable.
Definition: CatalogVector.h:29
STL class.
void write(OutputArchiveHandle &handle) const override
Write an instance of a Footprint to an output Archive.
Definition: Footprint.cc:263
STL class.
table::Schema spanSchema
Definition: Footprint.cc:196
Citizen(const std::type_info &)
Definition: Citizen.cc:163
Key< U > key
Definition: Schema.cc:281
void include(Point2I const &point)
Expand this to ensure that this->contains(point).
Definition: Box.cc:157
void shift(Extent2I const &offset)
Shift the position of the box by the given offset.
Definition: Box.cc:138
bool operator==(Footprint const &other) const
equality operator
Definition: Footprint.cc:165
lsst::afw::detection::Footprint Footprint
Definition: Source.h:61
T back(T... args)
Reports invalid arguments.
Definition: Runtime.h:66
void sortPeaks(afw::table::Key< float > const &key=afw::table::Key< float >())
Sort Peaks from most positive value to most negative.
Definition: Footprint.cc:60
std::shared_ptr< PeakRecord > addPeak(float fx, float fy, float value)
Convenience function to add a peak.
Definition: Footprint.cc:50
size_type size() const
Return the number of elements in the catalog.
Definition: Catalog.h:408
std::shared_ptr< geom::SpanSet > getSpans() const
Return a shared pointer to the SpanSet.
Definition: Footprint.h:117
ItemVariant const * other
Definition: Schema.cc:56
void removeOrphanPeaks()
Remove peaks from the PeakCatalog that fall outside the area of the Footprint.
Definition: Footprint.cc:139
void saveCatalog(BaseCatalog const &catalog)
Save a catalog in the archive.
T fill(T... args)
FootprintFactory(std::string const &name)
Definition: Footprint.cc:252
A multi-catalog archive object used to load table::io::Persistable objects.
Definition: InputArchive.h:31
iterator begin()
Iterator access.
Definition: Catalog.h:396
void erode(int r, geom::Stencil s=geom::Stencil::CIRCLE)
Erode the Footprint with a defined kernel.
Definition: Footprint.cc:129
Record class that represents a peak in a Footprint.
Definition: Peak.h:42
PeakCatalog & getPeaks()
Return the Peaks contained in this Footprint.
Definition: Footprint.h:131
An integer coordinate rectangle.
Definition: Box.h:54
A class to represent a 2-dimensional array of pixels.
Definition: Image.h:59
lsst::geom::Box2I getRegion() const
Return the corners of the MaskedImage the footprints live in.
Definition: Footprint.h:215
Footprint()
Constructor of a empty Footprint object.
Definition: Footprint.h:97
int end
int getMinY() const noexcept
Definition: Box.h:145
A 2D linear coordinate transformation.
Transform LSST spatial data, such as lsst::geom::Point2D and lsst::geom::SpherePoint, using an AST mapping.
Definition: Transform.h:67
std::shared_ptr< Persistable > get(int id) const
Load the Persistable with the given ID and return it.
std::shared_ptr< TransformPoint2ToPoint2 > makeTransform(lsst::geom::AffineTransform const &affine)
Wrap an lsst::geom::AffineTransform as a Transform.
SchemaMapper * mapper
Definition: SchemaMapper.cc:78
T reserve(T... args)
std::shared_ptr< RecordT > addNew()
Create a new record, add it to the end of the catalog, and return a pointer to it.
Definition: Catalog.h:485