39 std::shared_ptr<table::io::Persistable>
const&);
49 for (
int y = 0; y !=
image.getHeight(); ++y) {
50 for (XIter imPtr =
image.row_begin(y), imEnd =
image.row_end(y); imPtr != imEnd; ++imPtr) {
59 _sum = kernel.
computeImage(_image,
false, pos[0], pos[1]);
64 retPtr->setCtr(this->
getCtr());
69 if ((width <= 0) || (height <= 0)) {
71 os <<
"Cannot create FixedKernel with dimensions (" << width <<
", " << height <<
"). ";
76 os <<
"Cannot resize FixedKernel from (" <<
getWidth() <<
", " <<
getHeight() <<
") to (" << width
77 <<
", " << height <<
"), because at least one dimension would change by an odd value.";
88 bboxIntersect.clip(bboxNew);
97 bboxIntersect.getDimensions());
100 imNew->assign(imIntersect, bboxIntersect);
106 double multFactor = 1.0;
107 double imSum = this->_sum;
112 multFactor = 1.0 /
static_cast<double>(this->_sum);
118 for (
int y = 0; y != this->
getHeight(); ++y) {
119 for (XIter imPtr =
image.row_begin(y), imEnd =
image.row_end(y), kPtr = this->
_image.row_begin(y);
120 imPtr != imEnd; ++imPtr, ++kPtr) {
121 imPtr[0] = multFactor * kPtr[0];
130 os << prefix <<
"FixedKernel:" <<
std::endl;
131 os << prefix <<
"..sum: " << _sum <<
std::endl;
144 :
Kernel::PersistenceHelper(0),
145 image(schema.addField<
table::Array<
Kernel::Pixel>>(
"image",
"pixel values (row-major)",
146 dimensions.getX() * dimensions.getY())) {}
148 explicit FixedKernelPersistenceHelper(
table::Schema const& schema_)
149 : Kernel::PersistenceHelper(schema_),
image(schema[
"image"]) {}
160 FixedKernelPersistenceHelper
const keys(catalogs.
front().getSchema());
163 ndarray::flatten<1>(ndarray::static_dimension_cast<2>(
image.getArray())) = record[keys.image];
165 result->setCtr(record.
get(keys.center));
174std::string getFixedKernelPersistenceName() {
return "FixedKernel"; }
176FixedKernel::Factory registration(getFixedKernelPersistenceName());
185 (*record)[keys.image] = ndarray::flatten<1>(ndarray::copy(_image.getArray()));
#define LSST_EXCEPT(type,...)
#define LSST_ARCHIVE_ASSERT(EXPR)
An assertion macro used to validate the structure of an InputArchive.
typename _view_t::x_iterator x_iterator
An iterator for traversing the pixels in a row.
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)
std::string getPersistenceName() const override
Return the unique name used to persist this object and look up its factory.
std::shared_ptr< Kernel > clone() const override
Return a pointer to a deep copy of this kernel.
FixedKernel()
Construct an empty FixedKernel of size 0x0.
double doComputeImage(lsst::afw::image::Image< Pixel > &image, bool doNormalize) const override
Low-level version of computeImage.
std::shared_ptr< Kernel > resized(int width, int height) const override
Return a pointer to a clone with specified kernel dimensions.
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.
lsst::geom::Extent2I const getDimensions() const
Return the Kernel's dimensions (width, height)
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.
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.
Kernel()
Construct a null Kernel of size 0,0.
lsst::geom::Box2I getBBox() const
return parent bounding box, with XY0 = -center
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 class used as a handle to a particular field in a table.
Defines the fields and offsets for a table.
static std::shared_ptr< T > dynamicCast(std::shared_ptr< Persistable > const &ptr)
Dynamically cast a shared_ptr.
A base class for factory classes used to reconstruct objects from records.
io::CatalogVector CatalogVector
io::InputArchive InputArchive
PersistableFactory(std::string const &name)
Constructor for the factory.
io::OutputArchiveHandle OutputArchiveHandle
int getMinY() const noexcept
int getMinX() const noexcept
Point< double, 2 > Point2D
Extent< int, 2 > Extent2I