28 namespace lsst {
namespace meas {
namespace base {
32 boost::array<FlagDefinition,NaiveCentroidAlgorithm::N_FLAGS>
const & getFlagDefinitions() {
33 static boost::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,
51 _centroidExtractor(schema, name, true)
54 getFlagDefinitions().begin(), getFlagDefinitions().end());
64 result.
x = center.getX();
65 result.
y = center.getY();
71 int x = center.getX();
72 int y = center.getY();
77 if (x < 1 || x >= image.getWidth() - 1 || y < 1 || y >= image.getHeight() - 1) {
86 ImageT::xy_locator im = image.xy_at(x, y);
89 (im(-1, 1) + im( 0, 1) + im( 1, 1) +
90 im(-1, 0) + im( 0, 0) + im( 1, 0) +
91 im(-1, -1) + im( 0, -1) + im( 1, -1))
103 -im(-1, 1) + im( 1, 1) +
104 -im(-1, 0) + im( 1, 0) +
105 -im(-1, -1) + im( 1, -1);
107 (im(-1, 1) + im( 0, 1) + im( 1, 1)) -
108 (im(-1, -1) + im( 0, -1) + im( 1, -1));
123 std::string
const &
name,
128 for (
auto flag = getFlagDefinitions().begin() + 1; flag < getFlagDefinitions().end(); ++flag) {
129 mapper.
addMapping(mapper.getInputSchema().find<afw::table::Flag>(
130 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
NaiveCentroidAlgorithm(Control const &ctrl, std::string const &name, afw::table::Schema &schema)
virtual void fail(afw::table::SourceRecord &measRecord, MeasurementError *error=NULL) const
double indexToPosition(double ind)
Convert image index to image position.
table::Key< std::string > name
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.
Eigen matrix objects that present a view into an ndarray::Array.
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.
Exception to be thrown when a measurement algorithm experiences a known failure mode.
boost::enable_if< typename ExpressionTraits< Scalar >::IsScalar, Scalar >::type sum(Scalar const &scalar)
table::Key< table::Array< Kernel::Pixel > > image
SafeCentroidExtractor _centroidExtractor
FlagDefinition getDefinition(int i) const
MaskedImageT getMaskedImage()
Return the MaskedImage.
if(width!=gim.getWidth()||height!=gim.getHeight()||x0!=gim.getX0()||y0!=gim.getY0())
void setValue(afw::table::BaseRecord &record, int i, bool value) const
CentroidResultKey _centroidKey
#define LSST_EXCEPT(type,...)
Algorithm provides no uncertainy information at all.
double background
"Value to subtract from the image pixel values" ;
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
void handleFailure(afw::table::BaseRecord &record, MeasurementError const *error=NULL) const
A C++ control class to handle NaiveCentroidAlgorithm's configuration.
Record class that contains measurements made on a single exposure.
static FlagHandler addFields(afw::table::Schema &schema, std::string const &prefix, FlagDefinition const *begin, FlagDefinition const *end)