23 #include "ndarray/eigen.h"
28 namespace lsst {
namespace meas {
namespace base {
32 std::array<FlagDefinition,NaiveCentroidAlgorithm::N_FLAGS>
const &
getFlagDefinitions() {
33 static std::array<FlagDefinition,NaiveCentroidAlgorithm::N_FLAGS>
const flagDefs = {{
34 {
"flag",
"general failure flag, set if anything went wrong"},
35 {
"flag_noCounts",
"Object to be centroided has no counts"},
36 {
"flag_edge",
"Object too close to edge"}
45 std::string
const &
name,
53 _centroidExtractor(schema, name, true),
54 _centroidChecker(schema, name, ctrl.doFootprintCheck, ctrl.maxDistToPeak)
65 result.
x = center.getX();
66 result.
y = center.getY();
72 int x = center.getX();
73 int y = center.getY();
78 if (x < 1 || x >= image.getWidth() - 1 || y < 1 || y >= image.getHeight() - 1) {
87 ImageT::xy_locator im = image.xy_at(x, y);
90 (im(-1, 1) + im( 0, 1) + im( 1, 1) +
91 im(-1, 0) + im( 0, 0) + im( 1, 0) +
92 im(-1, -1) + im( 0, -1) + im( 1, -1))
104 -im(-1, 1) + im( 1, 1) +
105 -im(-1, 0) + im( 1, 0) +
106 -im(-1, -1) + im( 1, -1);
108 (im(-1, 1) + im( 0, 1) + im( 1, 1)) -
109 (im(-1, -1) + im( 0, -1) + im( 1, -1));
124 std::string
const &
name,
130 mapper.
addMapping(mapper.getInputSchema().find<afw::table::Flag>(
131 mapper.getInputSchema().join(
name, flag->name)).key);
Defines the fields and offsets for a table.
virtual void measure(afw::table::SourceRecord &measRecord, afw::image::Exposure< float > const &exposure) const
Called to measure a single child source in an image.
NaiveCentroidAlgorithm(Control const &ctrl, std::string const &name, afw::table::Schema &schema)
virtual void fail(afw::table::SourceRecord &measRecord, MeasurementError *error=NULL) const
Handle an exception thrown by the current algorithm by setting flags in the given record...
CentroidChecker _centroidChecker
double indexToPosition(double ind)
Convert image index to image position.
table::Key< std::string > name
afw::table::Schema schema
A mapping between the keys of two Schemas, used to copy data between them.
A reusable struct for centroid measurements.
CentroidElement x
x (column) coordinate of the measured position
ImagePtr getImage(bool const noThrow=false) const
Return a (Ptr to) the MaskedImage's image.
std::array< FlagDefinition, BlendednessAlgorithm::N_FLAGS > const & getFlagDefinitions()
Exception to be thrown when a measurement algorithm experiences a known failure mode.
void set(Key< T > const &key, U const &value)
Set value of a field for the given key.
FlagDefinition getDefinition(std::size_t i) const
Return the FlagDefinition object that corresponds to a particular enum value.
table::Key< table::Array< Kernel::Pixel > > image
SafeCentroidExtractor _centroidExtractor
Utility class for handling flag fields that indicate the failure modes of an algorithm.
MaskedImageT getMaskedImage()
Return the MaskedImage.
if(width!=gim.getWidth()||height!=gim.getHeight()||x0!=gim.getX0()||y0!=gim.getY0())
CentroidResultKey _centroidKey
#define LSST_EXCEPT(type,...)
Create an exception with a given type and message and optionally other arguments (dependent on the ty...
Algorithm provides no uncertainy information at all.
double background
"Value to subtract from the image pixel values" ;
A FunctorKey for CentroidResult.
CentroidElement y
y (row) coordinate of the measured position
void handleFailure(afw::table::BaseRecord &record, MeasurementError const *error=NULL) const
Handle an expected or unexpected Exception thrown by a measurement algorithm.
A C++ control class to handle NaiveCentroidAlgorithm's configuration.
Record class that contains measurements made on a single exposure.
Key< T > addMapping(Key< T > const &inputKey, bool doReplace=false)
Add a new field to the output Schema that is a copy of a field in the input Schema.