31 namespace pexExcept = lsst::pex::exceptions;
32 namespace afwGeom = lsst::afw::geom;
33 namespace afwMath = lsst::afw::math;
46 Kernel(image.getWidth(), image.getHeight(), 0),
53 for (XIter imPtr = image.
row_begin(
y), imEnd = image.
row_end(
y); imPtr != imEnd; ++imPtr) {
64 Kernel(kernel.getWidth(), kernel.getHeight(), 0),
65 _image(kernel.getDimensions()),
72 retPtr->setCtr(this->getCtr());
80 double multFactor = 1.0;
81 double imSum = this->
_sum;
84 throw LSST_EXCEPT(pexExcept::OverflowError,
"Cannot normalize; kernel sum is 0");
86 multFactor = 1.0/
static_cast<double>(this->
_sum);
92 for (
int y = 0;
y != this->getHeight(); ++
y) {
93 for (XIter imPtr = image.
row_begin(
y), imEnd = image.
row_end(
y), kPtr = this->_image.row_begin(
y);
94 imPtr != imEnd; ++imPtr, ++kPtr) {
95 imPtr[0] = multFactor*kPtr[0];
103 std::ostringstream os;
104 os << prefix <<
"FixedKernel:" << std::endl;
105 os << prefix <<
"..sum: " <<
_sum << std::endl;
112 namespace lsst {
namespace afw {
namespace math {
117 table::Key< table::Array<Kernel::Pixel> >
image;
120 Kernel::PersistenceHelper(0),
122 schema.addField< table::Array<Kernel::Pixel> >(
123 "image",
"pixel values (row-major)", dimensions.getX() * dimensions.getY()
128 explicit FixedKernelPersistenceHelper(table::Schema
const & schema_) :
129 Kernel::PersistenceHelper(schema_),
143 FixedKernelPersistenceHelper
const keys(catalogs.front().getSchema());
148 ) = record[keys.image];
150 result->setCtr(record.get(keys.center));
159 std::string getFixedKernelPersistenceName() {
return "FixedKernel"; }
161 FixedKernel::Factory registration(getFixedKernelPersistenceName());
168 FixedKernelPersistenceHelper
const keys(getDimensions());
170 (*record)[keys.image] = ndarray::flatten<1>(
ndarray::copy(_image.getArray()));
virtual std::string toString(std::string const &prefix="") const
Return a string representation of the kernel.
lsst::afw::image::Image< Pixel > _image
Declare the Kernel class and subclasses.
table::Key< std::string > name
x_iterator row_begin(int y) const
An object passed to Persistable::write to allow it to persist itself.
x_iterator row_end(int y) const
Return an x_iterator to the end of the y'th row.
#define LSST_ARCHIVE_ASSERT(EXPR)
An assertion macro used to validate the structure of an InputArchive.
virtual std::string toString(std::string const &prefix="") const
Return a string representation of the kernel.
A base class for factory classes used to reconstruct objects from records.
FixedKernel()
Construct an empty FixedKernel of size 0x0.
SelectEigenView< T >::Type copy(Eigen::EigenBase< T > const &other)
Copy an arbitrary Eigen expression into a new EigenView.
double doComputeImage(lsst::afw::image::Image< Pixel > &image, bool doNormalize) const
Low-level version of computeImage.
Factory(std::string const &name)
Array< T, N, C_ > static_dimension_cast(Array< T, N, C > const &array)
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 std::string getPersistenceName() const
Return the unique name used to persist this object and look up its factory.
afw::table::PointKey< int > dimensions
#define LSST_EXCEPT(type,...)
A vector of catalogs used by Persistable.
Base class for all records.
int getHeight() const
Return the number of rows in the image.
virtual void write(OutputArchiveHandle &handle) const
Write the object to one or more catalogs.
Kernels are used for convolution with MaskedImages and (eventually) Images.
A kernel created from an Image.
double computeImage(lsst::afw::image::Image< Pixel > &image, bool doNormalize, double x=0.0, double y=0.0) const
Compute an image (pixellized representation of the kernel) in place.
Include files required for standard LSST Exception handling.