24 #include "boost/bind.hpp"
30 namespace lsst {
namespace afw {
namespace detection {
39 std::uint16_t bits = 0x1;
63 _source(sourceTable->makeRecord())
65 PTR(
Footprint) newFootprint = std::make_shared<Footprint>(*footprint);
72 iter != footprint->getPeaks().end();
76 newPeak->set(keys.
peak,
true);
77 newFootprint->getPeaks().push_back(newPeak);
79 _source->setFootprint(newFootprint);
110 float minNewPeakDist=-1.,
111 float maxSamePeakDist=-1.
117 maxSamePeakDist, NULL);
137 float minNewPeakDist=-1.,
138 float maxSamePeakDist=-1.
143 for (FilterMap::const_iterator i = keys.begin(); i != keys.end(); ++i) {
148 maxSamePeakDist, &keys);
184 float minNewPeakDist,
185 float maxSamePeakDist,
188 if (minNewPeakDist < 0 && maxSamePeakDist < 0)
return;
190 assert(peakSchemaMapper || filterMap);
196 float minNewPeakDist2 = minNewPeakDist*minNewPeakDist;
197 float maxSamePeakDist2 = maxSamePeakDist*maxSamePeakDist;
199 otherIter != otherPeaks.
end(); ++otherIter) {
201 float minDist2 = std::numeric_limits<float>::infinity();
204 currentIter != currentPeaks.
end(); ++currentIter) {
205 float dist2 = otherIter->getI().distanceSquared(currentIter->getI());
207 if (dist2 < minDist2) {
209 nearestPeak = currentIter;
213 if (minDist2 < maxSamePeakDist2 && nearestPeak && maxSamePeakDist > 0) {
214 if (peakSchemaMapper) {
215 nearestPeak->set(keys->
peak,
true);
217 for (FilterMap::const_iterator i = filterMap->begin(); i != filterMap->end(); ++i) {
219 nearestPeak->set(flagKey, nearestPeak->get(flagKey) || otherIter->get(flagKey));
222 }
else if (minDist2 > minNewPeakDist2 && !(minNewPeakDist < 0)) {
223 if (peakSchemaMapper) {
225 newPeak->assign(*otherIter, *peakSchemaMapper);
226 newPeak->set(keys->
peak,
true);
228 newPeaks.push_back(otherIter);
235 newPeaks.begin(), newPeaks.end(),
246 afw::table::Schema & sourceSchema,
247 std::vector<std::
string> const & filterList,
248 afw::table::Schema const & initialPeakSchema
249 ) : _peakSchemaMapper(initialPeakSchema) {
250 _initialize(sourceSchema, filterList);
255 std::vector<std::string>
const & filterList
256 ) : _peakSchemaMapper(
PeakTable::makeMinimalSchema()) {
262 std::vector<std::string>
const & filterList
267 std::vector<std::string>::const_iterator
iter=filterList.begin();
268 iter != filterList.end();
273 "merge_footprint_" + *
iter,
274 "Detection footprint overlapped with a detection from filter " + *
iter
277 "merge_peak_" + *
iter,
278 "Peak detected in filter " + *
iter
287 std::string
const & filter,
288 float minNewPeakDist,
bool doMerge,
float maxSamePeakDist
290 FilterMap::const_iterator keyIter =
_filterMap.find(filter);
293 pex::exceptions::LogicError,
294 (
boost::format(
"Filter %s not in original list") % filter).str()
299 bool checkForMatches = (
_mergeList.size() > 0);
305 if (srcIter->getParent() != 0)
continue;
313 if (checkForMatches) {
319 if (box.overlaps(foot->getBBox()) && (**iter).overlaps(*foot)) {
330 first->add(**iter,
_filterMap, minNewPeakDist, maxSamePeakDist);
342 std::make_shared<FootprintMerge>(
354 if (doNorm) (**iter).getMergedFootprint()->normalize();
355 outputCat.
push_back((**iter).getSource());
boost::shared_ptr< Table > getTable() const
Return the table associated with the catalog.
Defines the fields and offsets for a table.
void push_back(Record const &r)
Add a copy of the given record to the end of the catalog.
void include(Point2I const &point)
Expand this to ensure that this->contains(point).
A mapping between the keys of two Schemas, used to copy data between them.
Table class for Peaks in Footprints.
lsst::afw::detection::Footprint Footprint
static boost::shared_ptr< PeakTable > make(afw::table::Schema const &schema, bool forceNew=false)
Obtain a table that can be used to create records with given schema.
Use (pixels & (given mask))
void addMinimalSchema(Schema const &minimal, bool doMap=true)
Add the given minimal schema to the output schema.
An integer coordinate rectangle.
iterator begin()
Iterator access.
afw::table::CatalogT< PeakRecord > PeakCatalog
Custom catalog class for record/table subclasses that are guaranteed to have an ID, and should generally be sorted by that ID.
Represent a 2-dimensional array of bitmask pixels.
boost::shared_ptr< PeakRecord > copyRecord(afw::table::BaseRecord const &other)
Iterator class for CatalogT.
void grow(int buffer)
Increase the size of the box by the given buffer amount in all directions.
Schema const getOutputSchema() const
Return the output schema (copy-on-write).
Table class that contains measurements made on a single exposure.
#define LSST_EXCEPT(type,...)
Create an exception with a given type and message and optionally other arguments (dependent on the ty...
Schema & editOutputSchema()
Return a reference to the output schema that allows it to be modified in place.
iterator end()
Iterator access.
MaskT setMaskFromFootprint(lsst::afw::image::Mask< MaskT > *mask, Footprint const &footprint, MaskT const bitmask)
OR bitmask into all the Mask's pixels that are in the Footprint.
Key< T > addField(Field< T > const &field, bool doReplace=false)
Add a new field to the Schema, and return the associated Key.
Record class that contains measurements made on a single exposure.
Record class that represents a peak in a Footprint.
Schema const getInputSchema() const
Return the input schema (copy-on-write).