34 namespace algorithms {
38 inline double min4(
double a,
double b,
double c,
double d) {
42 inline double max4(
double a,
double b,
double c,
double d) {
49 int nx = im.getWidth();
50 int ny = im.getHeight();
53 out = std::make_shared<afw::detection::Psf::Image>(nx + 2 * xPad, ny + 2 * yPad);
54 out->setXY0(im.getX0() - xPad, im.getY0() - yPad);
63 static const int dst_padding = 0;
69 static const double maxTransformCoeff = 200.0;
72 throw LSST_EXCEPT(pex::exceptions::RangeError,
"Unexpectedly large transform passed to WarpedPsf");
76 int in_xlo =
bbox.getMinX();
77 int in_xhi =
bbox.getMinX() +
bbox.getWidth() - 1;
78 int in_ylo =
bbox.getMinY();
79 int in_yhi =
bbox.getMinY() +
bbox.getHeight() - 1;
90 int out_xlo =
floor(min4(c00.getX(), c01.getX(), c10.getX(), c11.getX())) - dst_padding;
91 int out_ylo =
floor(min4(c00.getY(), c01.getY(), c10.getY(), c11.getY())) - dst_padding;
92 int out_xhi =
ceil(max4(c00.getX(), c01.getX(), c10.getX(), c11.getX())) + dst_padding;
93 int out_yhi =
ceil(max4(c00.getY(), c01.getY(), c10.getY(), c11.getY())) + dst_padding;
115 afw::math::WarpingControl
const &wc) {
119 afw::math::SeparableKernel
const &kernel = *wc.getWarpingKernel();
121 int const xPad =
std::max(center.getX(), kernel.getWidth() - center.getX());
122 int const yPad =
std::max(center.getY(), kernel.getHeight() - center.getY());
142 _undistortedPsf(undistortedPsf),
143 _distortion(distortion),
144 _warpingControl(control) {
152 _undistortedPsf(undistortedPsf),
153 _distortion(distortion),
154 _warpingControl(new
afw::math::WarpingControl(kernelName,
"", cache)) {
158 void WarpedPsf::_init() {
161 "Undistorted Psf passed to WarpedPsf must not be None/NULL");
166 if (!_warpingControl) {
168 "WarpingControl passed to WarpedPsf must not be None/NULL");
192 PTR(
Image) im = _undistortedPsf->computeKernelImage(tp, color);
196 PTR(afw::detection::Psf::Psf::Image) ret = warpAffine(*im, srcToDest, *_warpingControl);
198 double normFactor = 1.0;
207 normFactor += *imPtr;
210 if (normFactor == 0.0) {
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
#define CONST_PTR(...)
A shared pointer to a const object.
A polymorphic base class for representing an image's Point Spread Function.
image::Image< Pixel > Image
Image type returned by computeImage.
Describe the colour of a source.
_view_t::x_iterator x_iterator
An iterator for traversing the pixels in a row.
Parameters to control convolution.
An integer coordinate rectangle.
int getHeight() const noexcept
An intermediate base class for Psfs that use an image representation.
A Psf class that maps an arbitrary Psf through a coordinate transformation.
boost::shared_ptr< afw::detection::Psf const > _undistortedPsf
boost::shared_ptr< afw::geom::TransformPoint2ToPoint2 const > _distortion
virtual geom::Box2I doComputeBBox(geom::Point2D const &position, afw::image::Color const &color) const
virtual boost::shared_ptr< afw::detection::Psf > clone() const
Polymorphic deep copy. Usually unnecessary, as Psfs are immutable.
WarpedPsf(boost::shared_ptr< afw::detection::Psf const > undistortedPsf, boost::shared_ptr< afw::geom::TransformPoint2ToPoint2 const > distortion, boost::shared_ptr< afw::math::WarpingControl const > control)
Construct WarpedPsf from unwarped psf and distortion.
virtual boost::shared_ptr< afw::detection::Psf > resized(int width, int height) const
Return a clone with specified kernel dimensions.
virtual geom::Point2D getAveragePosition() const
Return the average of the positions of the stars that went into this Psf.
Reports invalid arguments.
Reports errors in the logical structure of the program.
std::shared_ptr< TransformPoint2ToPoint2 > makeTransform(lsst::geom::AffineTransform const &affine)
Wrap an lsst::geom::AffineTransform as a Transform.
lsst::geom::AffineTransform linearizeTransform(TransformPoint2ToPoint2 const &original, lsst::geom::Point2D const &inPoint)
Approximate a Transform by its local linearization.
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
int warpImage(DestImageT &destImage, geom::SkyWcs const &destWcs, SrcImageT const &srcImage, geom::SkyWcs const &srcWcs, WarpingControl const &control, typename DestImageT::SinglePixel padValue=lsst::afw::math::edgePixel< DestImageT >(typename lsst::afw::image::detail::image_traits< DestImageT >::image_category()))
Warp an Image or MaskedImage to a new Wcs.
Extent< int, N > floor(Extent< double, N > const &input) noexcept
Return the component-wise floor (round towards more negative).
Point< double, 2 > Point2D
Extent< int, N > ceil(Extent< double, N > const &input) noexcept
Return the component-wise ceil (round towards more positive).
A base class for image defects.