23 #include "ndarray/eigen.h" 31 FlagDefinitionList flagDefinitions;
36 flagDefinitions.add(
"flag_noCounts",
"Object to be centroided has no counts");
38 flagDefinitions.add(
"flag_edge",
"Object too close to edge");
45 _centroidKey(
CentroidResultKey::addFields(schema, name,
"centroid from Naive Centroid algorithm",
48 _centroidExtractor(schema, name, true),
49 _centroidChecker(schema, name, ctrl.doFootprintCheck, ctrl.maxDistToPeak) {}
53 geom::Point2D center = _centroidExtractor(measRecord, _flagHandler);
55 result.
x = center.getX();
56 result.
y = center.getY();
57 measRecord.
set(_centroidKey, result);
62 int x = center.getX();
63 int y = center.getY();
68 if (x < 1 || x >= image.getWidth() - 1 || y < 1 || y >= image.getHeight() - 1) {
72 ImageT::xy_locator im = image.xy_at(x, y);
74 double const sum = (im(-1, 1) + im(0, 1) + im(1, 1) + im(-1, 0) + im(0, 0) + im(1, 0) + im(-1, -1) +
75 im(0, -1) + im(1, -1)) -
82 double const sum_x = -im(-1, 1) + im(1, 1) + -im(-1, 0) + im(1, 0) + -im(-1, -1) + im(1, -1);
83 double const sum_y = (im(-1, 1) + im(0, 1) + im(1, 1)) - (im(-1, -1) + im(0, -1) + im(1, -1));
87 measRecord.
set(_centroidKey, result);
88 _centroidChecker(measRecord);
100 if (flag == NaiveCentroidAlgorithm::FAILURE)
continue;
101 if (
mapper.getInputSchema().getNames().count(
mapper.getInputSchema().join(
name, flag.
name)) == 0)
104 mapper.getInputSchema().find<afw::table::Flag>(
name +
"_" + flag.
name).key;
std::size_t size() const
return the current size (number of defined elements) of the collection
Defines the fields and offsets for a table.
NaiveCentroidAlgorithm(Control const &ctrl, std::string const &name, afw::table::Schema &schema)
double indexToPosition(double ind)
Convert image index to image position.
A mapping between the keys of two Schemas, used to copy data between them.
Simple class used to define and document flags The name and doc constitute the identity of the FlagDe...
A reusable struct for centroid measurements.
static FlagDefinition const EDGE
CentroidElement x
x (column) coordinate of the measured position
Exception to be thrown when a measurement algorithm experiences a known failure mode.
ImagePtr getImage() const
Return a (shared_ptr to) the MaskedImage's image.
Utility class for handling flag fields that indicate the failure modes of an algorithm.
virtual void fail(afw::table::SourceRecord &measRecord, MeasurementError *error=nullptr) const
Handle an exception thrown by the current algorithm by setting flags in the given record...
virtual void measure(afw::table::SourceRecord &measRecord, afw::image::Exposure< float > const &exposure) const
Called to measure a single child source in an image.
A base class for image defects.
MaskedImageT getMaskedImage()
Return the MaskedImage.
static FlagDefinitionList const & getFlagDefinitions()
static FlagDefinition const NO_COUNTS
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Algorithm provides no uncertainy information at all.
double background
"Value to subtract from the image pixel values" ;
void handleFailure(afw::table::BaseRecord &record, MeasurementError const *error=nullptr) const
Handle an expected or unexpected Exception thrown by a measurement algorithm.
A FunctorKey for CentroidResult.
void set(Key< T > const &key, U const &value)
Set value of a field for the given key.
CentroidElement y
y (row) coordinate of the measured position
A C++ control class to handle NaiveCentroidAlgorithm's configuration.
Record class that contains measurements made on a single exposure.
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects...
vector-type utility class to build a collection of FlagDefinitions
static FlagDefinition const FAILURE
A class to represent a 2-dimensional array of pixels.