30 namespace lsst {
namespace meas {
namespace algorithms {
34 inline double min4(
double a,
double b,
double c,
double d) {
38 inline double max4(
double a,
double b,
double c,
double d) {
45 int nx = im.getWidth();
46 int ny = im.getHeight();
49 out->setXY0(im.getX0()-xPad, im.getY0()-yPad);
57 afw::geom::Box2I computeBBoxFromTransform
58 (afw::geom::Box2I
const bbox,
59 afw::geom::AffineTransform
const &t
61 static const int dst_padding = 0;
63 afw::geom::AffineXYTransform xyTransform(t);
69 static const double maxTransformCoeff = 200.0;
71 if (t.getLinear().getMatrix().lpNorm<Eigen::Infinity>() > maxTransformCoeff) {
73 pex::exceptions::RangeError,
74 "Unexpectedly large transform passed to WarpedPsf");
78 int in_xlo = bbox.getMinX();
79 int in_xhi = bbox.getMinX() + bbox.getWidth() - 1;
80 int in_ylo = bbox.getMinY();
81 int in_yhi = bbox.getMinY() + bbox.getHeight() - 1;
92 int out_xlo =
floor(min4(c00.getX(), c01.getX(), c10.getX(), c11.getX())) - dst_padding;
93 int out_ylo =
floor(min4(c00.getY(), c01.getY(), c10.getY(), c11.getY())) - dst_padding;
94 int out_xhi =
ceil(max4(c00.getX(), c01.getX(), c10.getX(), c11.getX())) + dst_padding;
95 int out_yhi =
ceil(max4(c00.getY(), c01.getY(), c10.getY(), c11.getY())) + dst_padding;
115 afw::math::WarpingControl
const &wc
117 afw::geom::AffineXYTransform xyTransform(t);
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());
125 afw::geom::Box2I bbox = computeBBoxFromTransform(im.getBBox(), t);
144 _undistortedPsf(undistortedPsf),
145 _distortion(distortion),
146 _warpingControl(control)
160 _warpingControl(new afw::
math::WarpingControl(kernelName,
"", cache))
165 void WarpedPsf::_init()
170 "Undistorted Psf passed to WarpedPsf must not be None/NULL" 176 "XYTransform passed to WarpedPsf must not be None/NULL" 179 if (!_warpingControl) {
182 "WarpingControl passed to WarpedPsf must not be None/NULL" 211 PTR(afw::detection::Psf::Psf::Image) ret
214 double normFactor = 1.0;
220 for (
int y = 0;
y != ret->getHeight(); ++
y) {
223 normFactor += *imPtr;
226 if (normFactor == 0.0) {
WarpedPsf(boost::shared_ptr< afw::detection::Psf const > undistortedPsf, boost::shared_ptr< afw::geom::XYTransform const > distortion, boost::shared_ptr< afw::math::WarpingControl const > control)
Construct WarpedPsf from unwarped psf and distortion.
virtual afw::geom::Point2D getAveragePosition() const
Return the average of the positions of the stars that went into this Psf.
_view_t::x_iterator x_iterator
Extent< int, 2 > Extent2I
int warpImage(DestImageT &destImage, lsst::afw::image::Wcs const &destWcs, SrcImageT const &srcImage, lsst::afw::image::Wcs const &srcWcs, WarpingControl const &control, typename DestImageT::SinglePixel padValue=lsst::afw::math::edgePixel< DestImageT >(typename lsst::afw::image::detail::image_traits< DestImageT >::image_category()))
Point< double, 2 > Point2D
virtual boost::shared_ptr< afw::detection::Psf::Image > doComputeKernelImage(afw::geom::Point2D const &position, afw::image::Color const &color) const
virtual boost::shared_ptr< afw::detection::Psf > resized(int width, int height) const
Return a clone with specified kernel dimensions.
virtual boost::shared_ptr< afw::detection::Psf > clone() const
Polymorphic deep copy. Usually unnecessary, as Psfs are immutable.
#define LSST_EXCEPT(type,...)
afw::table::Key< double > b
An intermediate base class for Psfs that use an image representation.
boost::shared_ptr< afw::detection::Psf const > _undistortedPsf
image::Image< Pixel > Image
boost::shared_ptr< afw::geom::XYTransform const > _distortion