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;
99 explicit DeltaFunctionKernelPersistenceHelper() :
100 Kernel::PersistenceHelper(0),
101 pixel(table::PointKey<int>::addFields(
schema,
"pixel",
"position of nonzero pixel",
"pixels"))
103 schema.getCitizen().markPersistent();
117 DeltaFunctionKernelPersistenceHelper
const & keys = DeltaFunctionKernelPersistenceHelper::get();
121 new DeltaFunctionKernel(record.get(keys.dimensions.getX()), record.get(keys.dimensions.getY()),
122 record.get(keys.pixel))
124 result->setCtr(record.get(keys.center));
133 std::string getDeltaFunctionKernelPersistenceName() {
return "DeltaFunctionKernel"; }
135 DeltaFunctionKernel::Factory registration(getDeltaFunctionKernelPersistenceName());
140 return getDeltaFunctionKernelPersistenceName();
144 DeltaFunctionKernelPersistenceHelper
const & keys = DeltaFunctionKernelPersistenceHelper::get();
146 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
Include files required for standard LSST Exception handling.
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.
void ImageT ImageT int float saturatedPixelValue int const width
virtual void write(OutputArchiveHandle &handle) const
Write the object to one or more catalogs.
#define LSST_ARCHIVE_ASSERT(EXPR)
An assertion macro used to validate the structure of an InputArchive.
void ImageT ImageT int float saturatedPixelValue int const height
#define LSST_EXCEPT(type,...)
A vector of catalogs used by Persistable.
Base class for all records.
table::PointKey< int > pixel
xy_locator xy_at(int x, int y) const
Kernels are used for convolution with MaskedImages and (eventually) Images.
A kernel that has only one non-zero pixel (of value 1)