30 #include "lsst/afw/table/io/Persistable.cc" 43 :
Kernel(width, height, 0), _pixel(point) {
44 if (point.getX() < 0 || point.getX() >= width || point.getY() < 0 || point.getY() >= height) {
46 os <<
"point (" << point.getX() <<
", " << point.getY() <<
") lies outside " << width <<
"x" << height
55 retPtr->setCtr(this->
getCtr());
62 if ((padX % 2) || (padY % 2)) {
64 os <<
"Cannot resize DeltaFunctionKernel from (" <<
getWidth() <<
", " <<
getHeight() <<
") to (" 65 << width <<
", " << height <<
"), because at least one dimension would change by an odd value.";
68 int newPixelX =
getPixel().getX() + padX / 2;
69 int newPixelY =
getPixel().getY() + padY / 2;
71 std::make_shared<DeltaFunctionKernel>(width, height,
lsst::geom::Point2I(newPixelX, newPixelY));
76 const int pixelX =
getPixel().getX();
77 const int pixelY =
getPixel().getY();
80 os << prefix <<
"DeltaFunctionKernel:" <<
std::endl;
81 os << prefix <<
"Pixel (c,r) " << pixelX <<
"," << pixelY <<
")" <<
std::endl;
87 const int pixelX =
getPixel().getX();
88 const int pixelY =
getPixel().getY();
91 *image.
xy_at(pixelX, pixelY) = 1;
103 static DeltaFunctionKernelPersistenceHelper
const&
get() {
104 static DeltaFunctionKernelPersistenceHelper
const instance;
109 DeltaFunctionKernelPersistenceHelper(
const DeltaFunctionKernelPersistenceHelper&) =
delete;
110 DeltaFunctionKernelPersistenceHelper&
operator=(
const DeltaFunctionKernelPersistenceHelper&) =
delete;
113 DeltaFunctionKernelPersistenceHelper(DeltaFunctionKernelPersistenceHelper&&) =
delete;
114 DeltaFunctionKernelPersistenceHelper&
operator=(DeltaFunctionKernelPersistenceHelper&&) =
delete;
117 explicit DeltaFunctionKernelPersistenceHelper()
118 : Kernel::PersistenceHelper(0),
120 schema.getCitizen().markPersistent();
132 DeltaFunctionKernelPersistenceHelper
const&
keys = DeltaFunctionKernelPersistenceHelper::get();
137 record.get(keys.dimensions.getY()), record.get(keys.pixel)));
138 result->setCtr(record.get(keys.center));
147 std::string getDeltaFunctionKernelPersistenceName() {
return "DeltaFunctionKernel"; }
154 return getDeltaFunctionKernelPersistenceName();
158 DeltaFunctionKernelPersistenceHelper
const&
keys = DeltaFunctionKernelPersistenceHelper::get();
160 record->set(keys.pixel, _pixel);
std::string getPersistenceName() const override
Return the unique name used to persist this object and look up its factory.
int getHeight() const
Return the Kernel's height.
Factory(std::string const &name)
std::shared_ptr< Kernel > clone() const override
Return a pointer to a deep copy of this kernel.
An object passed to Persistable::write to allow it to persist itself.
A base class for factory classes used to reconstruct objects from records.
static PointKey addFields(Schema &schema, std::string const &name, std::string const &doc, std::string const &unit)
Add a pair of _x, _y fields to a Schema, and return a PointKey that points to them.
A base class for image defects.
void write(OutputArchiveHandle &handle) const override
Write the object to one or more catalogs.
std::string toString(std::string const &prefix="") const override
Return a string representation of the kernel.
lsst::geom::Point2I getCtr() const
Return index of kernel's center.
int getWidth() const
Return the Kernel's width.
#define LSST_EXCEPT(type,...)
Create an exception with a given 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.
Reports invalid arguments.
table::PointKey< int > pixel
std::shared_ptr< afw::table::io::Persistable > read(InputArchive const &archive, CatalogVector const &catalogs) const override
Construct a new object from the given InputArchive and vector of catalogs.
lsst::geom::Point2I getPixel() const
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects...
double doComputeImage(lsst::afw::image::Image< Pixel > &image, bool doNormalize) const override
Low-level version of computeImage.
DeltaFunctionKernel(int width, int height, lsst::geom::Point2I const &point)
Construct a spatially invariant DeltaFunctionKernel.
DeltaFunctionKernel & operator=(const DeltaFunctionKernel &)=delete
Kernels are used for convolution with MaskedImages and (eventually) Images.
xy_locator xy_at(int x, int y) const
Return an xy_locator at the point (x, y) in the image.
std::shared_ptr< Kernel > resized(int width, int height) const override
Return a pointer to a clone with specified kernel dimensions.
virtual std::string toString(std::string const &prefix="") const
Return a string representation of the kernel.