Template Function lsst::afw::math::warpImage(DestImageT&, geom::SkyWcs const&, SrcImageT const&, geom::SkyWcs const&, WarpingControl const&, typename DestImageT::SinglePixel)

Function Documentation

template<typename DestImageT, typename SrcImageT>
int lsst::afw::math::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. See also convenience function warpExposure() to warp an Exposure.

Parameters
  • destImage: remapped image

  • destWcs: WCS of remapped image

  • srcImage: source image

  • srcWcs: WCS of source image

  • control: control parameters

  • padValue: use this value for undefined (edge) pixels

Edge pixels are set to padValue; these are pixels that cannot be computed because they are too near the edge of srcImage or miss srcImage entirely.

Algorithm Without Interpolation:

Return

the number of valid pixels in destImage (those that are not edge pixels).

For each integer pixel position in the remapped Exposure:

  • The associated pixel position on srcImage is determined using the destination and source WCS

  • The warping kernel’s parameters are set based on the fractional part of the pixel position on srcImage

  • The warping kernel is applied to srcImage at the integer portion of the pixel position to compute the remapped pixel value

  • A flux-conservation factor is determined from the source and destination WCS and is applied to the remapped pixel

The scaling of intensity for relative area of source and destination uses two minor approximations:

  • The area of the sky marked out by a pixel on the destination image corresponds to a parallellogram on the source image.

  • The area varies slowly enough across the image that we can get away with computing the source area shifted by half a pixel up and to the left of the true area.

Algorithm With Interpolation:

Interpolation simply reduces the number of times WCS is used to map between destination and source pixel position. This computation is only made at a grid of points on the destination image, separated by interpLen pixels along rows and columns. All other source pixel positions are determined by linear interpolation between those grid points. Everything else remains the same.

Exceptions
  • lsst::pex::exceptions::InvalidParameterError: if destImage overlaps srcImage

  • std::bad_alloc: when allocation of CPU memory fails

Warning

The code that tests for image overlap is not guranteed to work correctly, based on the C++ standard. It is, in theory, possible for the code to report a “false positive”, meaning that it may claim that images overlap when they do not. We don’t believe that any of our current compilers have this problem. If, in the future, this becomes a problem then we will probably have to remove the test and rely on users being careful.