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();
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),
119 pixel(table::PointKey<
int>::addFields(
schema,
"pixel",
"position of nonzero pixel",
"pixel")) {}
130 DeltaFunctionKernelPersistenceHelper
const&
keys = DeltaFunctionKernelPersistenceHelper::get();
145std::string getDeltaFunctionKernelPersistenceName() {
return "DeltaFunctionKernel"; }
152 return getDeltaFunctionKernelPersistenceName();
156 DeltaFunctionKernelPersistenceHelper
const&
keys = DeltaFunctionKernelPersistenceHelper::get();
158 record->set(
keys.pixel, _pixel);
table::Key< std::string > name
table::PointKey< int > pixel
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
#define LSST_ARCHIVE_ASSERT(EXPR)
An assertion macro used to validate the structure of an InputArchive.
A class to represent a 2-dimensional array of pixels.
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.
Factory(std::string const &name)
DeltaFunctionKernel(int width, int height, lsst::geom::Point2I const &point)
Construct a spatially invariant DeltaFunctionKernel.
std::shared_ptr< Kernel > resized(int width, int height) const override
Return a pointer to a clone with specified kernel dimensions.
std::shared_ptr< Kernel > clone() const override
Return a pointer to a deep copy of this kernel.
double doComputeImage(lsst::afw::image::Image< Pixel > &image, bool doNormalize) const override
Low-level version of computeImage.
lsst::geom::Point2I getPixel() const
std::string getPersistenceName() const override
Return the unique name used to persist this object and look up its factory.
std::string toString(std::string const &prefix="") const override
Return a string representation of the kernel.
void write(OutputArchiveHandle &handle) const override
Write the object to one or more catalogs.
Kernels are used for convolution with MaskedImages and (eventually) Images.
int getHeight() const
Return the Kernel's height.
lsst::geom::Point2I getCtr() const
Return index of kernel's center.
virtual std::string toString(std::string const &prefix="") const
Return a string representation of the kernel.
int getWidth() const
Return the Kernel's width.
Base class for all records.
Field< T >::Value get(Key< T > const &key) const
Return the value of a field for the given key.
A vector of catalogs used by Persistable.
An object passed to Persistable::write to allow it to persist itself.
A base class for factory classes used to reconstruct objects from records.
PersistableFactory(std::string const &name)
Constructor for the factory.
Reports invalid arguments.
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
A base class for image defects.