27 #include "lsst/pex/exceptions.h"
31 namespace pexExcept = lsst::pex::exceptions;
38 :
Kernel(width, height, 0), _pixel(point) {
39 if (point.getX() < 0 || point.getX() >= width || point.getY() < 0 || point.getY() >= height) {
40 std::ostringstream os;
41 os <<
"point (" << point.getX() <<
", " << point.getY() <<
") lies outside " << width <<
"x" << height
43 throw LSST_EXCEPT(pexExcept::InvalidParameterError, os.str());
48 std::shared_ptr<Kernel> retPtr(
50 retPtr->setCtr(this->
getCtr());
55 const int pixelX =
getPixel().getX();
56 const int pixelY =
getPixel().getY();
58 std::ostringstream os;
59 os << prefix <<
"DeltaFunctionKernel:" << std::endl;
60 os << prefix <<
"Pixel (c,r) " << pixelX <<
"," << pixelY <<
")" << std::endl;
66 const int pixelX =
getPixel().getX();
67 const int pixelY =
getPixel().getY();
70 *image.
xy_at(pixelX, pixelY) = 1;
82 static DeltaFunctionKernelPersistenceHelper
const&
get() {
83 static DeltaFunctionKernelPersistenceHelper
const instance;
88 DeltaFunctionKernelPersistenceHelper(
const DeltaFunctionKernelPersistenceHelper&) =
delete;
89 DeltaFunctionKernelPersistenceHelper& operator=(
const DeltaFunctionKernelPersistenceHelper&) =
delete;
92 DeltaFunctionKernelPersistenceHelper(DeltaFunctionKernelPersistenceHelper&&) =
delete;
93 DeltaFunctionKernelPersistenceHelper& operator=(DeltaFunctionKernelPersistenceHelper&&) =
delete;
96 explicit DeltaFunctionKernelPersistenceHelper()
97 : Kernel::PersistenceHelper(0),
98 pixel(table::PointKey<int>::addFields(
schema,
"pixel",
"position of nonzero pixel",
"pixel")) {
99 schema.getCitizen().markPersistent();
111 DeltaFunctionKernelPersistenceHelper
const& keys = DeltaFunctionKernelPersistenceHelper::get();
114 std::shared_ptr<DeltaFunctionKernel>
result(
116 record.get(keys.dimensions.getY()), record.get(keys.pixel)));
117 result->setCtr(record.get(keys.center));
126 std::string getDeltaFunctionKernelPersistenceName() {
return "DeltaFunctionKernel"; }
128 DeltaFunctionKernel::Factory registration(getDeltaFunctionKernelPersistenceName());
133 return getDeltaFunctionKernelPersistenceName();
137 DeltaFunctionKernelPersistenceHelper
const& keys = DeltaFunctionKernelPersistenceHelper::get();
138 std::shared_ptr<afw::table::BaseRecord> record = keys.write(handle, *
this);
139 record->set(keys.pixel, _pixel);
virtual std::shared_ptr< Kernel > clone() const
Return a pointer to a deep copy of this kernel.
Factory(std::string const &name)
PersistableFactory(std::string const &name)
Constructor for the factory.
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.
#define LSST_ARCHIVE_ASSERT(EXPR)
An assertion macro used to validate the structure of an InputArchive.
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::shared_ptr< afw::table::io::Persistable > read(InputArchive const &archive, CatalogVector const &catalogs) const
Construct a new object from the given InputArchive and vector of catalogs.
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.
int getHeight() const
Return the Kernel's height.
int getWidth() const
Return the Kernel's width.
virtual double doComputeImage(lsst::afw::image::Image< Pixel > &image, bool doNormalize) const
Low-level version of computeImage.
table::Key< std::string > name
virtual void write(OutputArchiveHandle &handle) const
Write the object to one or more catalogs.
lsst::afw::geom::Point2I getCtr() const
Return index of kernel's center.
A vector of catalogs used by Persistable.
lsst::afw::geom::Point2I getPixel() const
Base class for all records.
table::PointKey< int > pixel
xy_locator xy_at(int x, int y) const
Return an xy_locator at the point (x, y) in the image.
Kernels are used for convolution with MaskedImages and (eventually) Images.
afw::table::Schema schema