22 #include "boost/bind.hpp"
28 namespace lsst {
namespace afw {
namespace detection {
37 boost::uint16_t bits = 0x1;
61 _source(sourceTable->makeRecord())
63 PTR(
Footprint) newFootprint = boost::make_shared<Footprint>(*footprint);
70 iter != footprint->getPeaks().end();
74 newPeak->set(keys.
peak,
true);
75 newFootprint->getPeaks().push_back(newPeak);
77 _source->setFootprint(newFootprint);
104 float minNewPeakDist=-1.,
105 float maxSamePeakDist=-1.
110 _addPeaks(footprint->
getPeaks(), &peakSchemaMapper, &keys, minNewPeakDist, maxSamePeakDist);
126 float minNewPeakDist=-1.,
127 float maxSamePeakDist=-1.
132 for (FilterMap::const_iterator i = keys.begin(); i != keys.end(); ++i) {
163 float minNewPeakDist,
164 float maxSamePeakDist
166 if (minNewPeakDist < 0 && maxSamePeakDist < 0)
return;
172 float minNewPeakDist2 = minNewPeakDist*minNewPeakDist;
173 float maxSamePeakDist2 = maxSamePeakDist*maxSamePeakDist;
175 otherIter != otherPeaks.
end(); ++otherIter) {
177 float minDist2 = std::numeric_limits<float>::infinity();
180 currentIter != currentPeaks.
end(); ++currentIter) {
181 float dist2 = otherIter->getI().distanceSquared(currentIter->getI());
183 if (dist2 < minDist2) {
185 nearestPeak = currentIter;
189 if (minDist2 < maxSamePeakDist2 && nearestPeak && keys && maxSamePeakDist > 0) {
190 nearestPeak->set(keys->
peak,
true);
191 }
else if (minDist2 > minNewPeakDist2 && !(minNewPeakDist < 0)) {
192 if (peakSchemaMapper) {
194 newPeak->assign(*otherIter, *peakSchemaMapper);
195 newPeak->set(keys->
peak,
true);
197 newPeaks.push_back(otherIter);
205 newPeaks.begin(), newPeaks.end(),
216 afw::table::Schema & sourceSchema,
217 std::vector<std::
string> const & filterList,
218 afw::table::Schema const & initialPeakSchema
219 ) : _peakSchemaMapper(initialPeakSchema) {
220 _initialize(sourceSchema, filterList);
225 std::vector<std::string>
const & filterList
226 ) : _peakSchemaMapper(
PeakTable::makeMinimalSchema()) {
232 std::vector<std::string>
const & filterList
237 std::vector<std::string>::const_iterator
iter=filterList.begin();
238 iter != filterList.end();
243 "merge_footprint_" + *
iter,
244 "Detection footprint overlapped with a detection from filter " + *
iter
247 "merge_peak_" + *
iter,
248 "Peak detected in filter " + *
iter
257 std::string
const & filter,
258 float minNewPeakDist,
bool doMerge,
float maxSamePeakDist
260 FilterMap::const_iterator keyIter =
_filterMap.find(filter);
263 pex::exceptions::LogicError,
264 (
boost::format(
"Filter %s not in original list") % filter).str()
269 bool checkForMatches = (
_mergeList.size() > 0);
275 if (srcIter->getParent() != 0)
continue;
283 if (checkForMatches) {
289 if (box.overlaps(foot->getBBox()) && (**iter).overlaps(*foot)) {
300 first->add(**iter,
_filterMap, minNewPeakDist, maxSamePeakDist);
312 boost::make_shared<FootprintMerge>(
324 if (doNorm) (**iter).getMergedFootprint()->normalize();
325 outputCat.
push_back((**iter).getSource());
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 addMinimalSchema(Schema const &minimal, bool doMap=true)
Add the given minimal schema to the output schema.
void grow(int buffer)
Increase the size of the box by the given buffer amount in all directions.
Schema & editOutputSchema()
Return a reference to the output schema that allows it to be modified in place.
Schema const getOutputSchema() const
Return the output schema (copy-on-write).
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
boost::shared_ptr< Table > getTable() const
Return the table associated with the catalog.
afw::table::CatalogT< PeakRecord > PeakCatalog
An integer coordinate rectangle.
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))
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.
Iterator class for CatalogT.
void include(Point2I const &point)
Expand this to ensure that this->contains(point).
Table class that contains measurements made on a single exposure.
#define LSST_EXCEPT(type,...)
Key< T > addField(Field< T > const &field, bool doReplace=false)
Add a new field to the Schema, and return the associated Key.
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.
boost::shared_ptr< PeakRecord > copyRecord(afw::table::BaseRecord const &other)
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).