31 namespace pexExcept = lsst::pex::exceptions;
32 namespace afwMath = lsst::afw::math;
34 namespace afwGeom = lsst::afw::geom;
44 if (point.getX() < 0 || point.getX() >= width || point.getY() < 0 || point.getY() >= height) {
45 std::ostringstream os;
46 os <<
"point (" << point.getX() <<
", " << point.getY() <<
") lies outside "
47 << width <<
"x" << height <<
" sized kernel";
48 throw LSST_EXCEPT(pexExcept::InvalidParameterError, os.str());
55 retPtr->setCtr(this->getCtr());
60 const int pixelX = getPixel().getX();
61 const int pixelY = getPixel().getY();
63 std::ostringstream os;
64 os << prefix <<
"DeltaFunctionKernel:" << std::endl;
65 os << prefix <<
"Pixel (c,r) " << pixelX <<
"," << pixelY <<
")" << std::endl;
74 const int pixelX = getPixel().getX();
75 const int pixelY = getPixel().getY();
78 *image.
xy_at(pixelX, pixelY) = 1;
85 namespace lsst {
namespace afw {
namespace math {
92 static DeltaFunctionKernelPersistenceHelper
const &
get() {
93 static DeltaFunctionKernelPersistenceHelper
const instance;
98 DeltaFunctionKernelPersistenceHelper (
const DeltaFunctionKernelPersistenceHelper&) =
delete;
99 DeltaFunctionKernelPersistenceHelper& operator=(
const DeltaFunctionKernelPersistenceHelper&) =
delete;
102 DeltaFunctionKernelPersistenceHelper (DeltaFunctionKernelPersistenceHelper&&) =
delete;
103 DeltaFunctionKernelPersistenceHelper& operator=(DeltaFunctionKernelPersistenceHelper&&) =
delete;
107 explicit DeltaFunctionKernelPersistenceHelper() :
108 Kernel::PersistenceHelper(0),
109 pixel(table::PointKey<int>::addFields(
schema,
"pixel",
"position of nonzero pixel",
"pixel"))
111 schema.getCitizen().markPersistent();
125 DeltaFunctionKernelPersistenceHelper
const & keys = DeltaFunctionKernelPersistenceHelper::get();
129 new DeltaFunctionKernel(record.get(keys.dimensions.getX()), record.get(keys.dimensions.getY()),
130 record.get(keys.pixel))
132 result->setCtr(record.get(keys.center));
141 std::string getDeltaFunctionKernelPersistenceName() {
return "DeltaFunctionKernel"; }
143 DeltaFunctionKernel::Factory registration(getDeltaFunctionKernelPersistenceName());
148 return getDeltaFunctionKernelPersistenceName();
152 DeltaFunctionKernelPersistenceHelper
const & keys = DeltaFunctionKernelPersistenceHelper::get();
154 record->set(keys.pixel, _pixel);
Declare the Kernel class and subclasses.
Factory(std::string const &name)
table::Key< std::string > name
An object passed to Persistable::write to allow it to persist itself.
DeltaFunctionKernel(int width, int height, lsst::afw::geom::Point2I const &point)
Construct a spatially invariant DeltaFunctionKernel.
afw::table::Schema schema
A base class for factory classes used to reconstruct objects from records.
virtual std::string toString(std::string const &prefix="") const
Return a string representation of the kernel.
virtual std::string toString(std::string const &prefix="") const
Return a string representation of the kernel.
virtual std::string getPersistenceName() const
Return the unique name used to persist this object and look up its factory.
std::map< Citizen const *, CitizenInfo > table
table::Key< table::Array< Kernel::Pixel > > image
A base class for objects that can be persisted via afw::table::io Archive classes.
virtual double doComputeImage(lsst::afw::image::Image< Pixel > &image, bool doNormalize) const
Low-level version of computeImage.
virtual void write(OutputArchiveHandle &handle) const
Write the object to one or more catalogs.
#define LSST_EXCEPT(type,...)
A vector of catalogs used by Persistable.
Base class for all records.
#define LSST_ARCHIVE_ASSERT(EXPR)
An assertion macro used to validate the structure of an InputArchive.
table::PointKey< int > pixel
xy_locator xy_at(int x, int y) const
Include files required for standard LSST Exception handling.
Kernels are used for convolution with MaskedImages and (eventually) Images.
A kernel that has only one non-zero pixel (of value 1)