42 #include "boost/shared_ptr.hpp"
43 #include "boost/pointer_cast.hpp"
44 #include "boost/cstdint.hpp"
45 #include "boost/regex.hpp"
62 namespace pexExcept = lsst::pex::exceptions;
63 namespace pexLog = lsst::pex::logging;
65 namespace afwGeom = lsst::afw::geom;
66 namespace afwCoord = lsst::afw::coord;
67 namespace afwMath = lsst::afw::math;
85 throw LSST_EXCEPT(pexExcept::InvalidParameterError,
"bad ind argument in WarpingKernel::setKernelParameter()");
87 int ctr = p->
getCtr()[ind];
90 if (ctr == (size-1)/2) {
91 if (value < -1e-6 || value > 1+1e-6) {
92 throw LSST_EXCEPT(pexExcept::InvalidParameterError,
"bad coordinate in WarpingKernel::setKernelParameter()");
94 }
else if (ctr == (size+1)/2) {
95 if (value < -1-1e-6 || value > 1e-6) {
96 throw LSST_EXCEPT(pexExcept::InvalidParameterError,
"bad coordinate in WarpingKernel::setKernelParameter()");
99 throw LSST_EXCEPT(pexExcept::InvalidParameterError,
"bad ctr value in WarpingKernel::setKernelParameter()");
117 checkWarpingKernelParameter(
this, ind, value);
146 return 0.5 + (1.0 - (2.0 * fabs(this->_params[0]))) * (0.5 - fabs(x));
151 checkWarpingKernelParameter(
this, ind, value);
158 std::string afwMath::BilinearWarpingKernel::BilinearFunction1::toString(std::string
const& prefix)
const {
159 std::ostringstream os;
160 os <<
"_BilinearFunction1: ";
161 os << Function1<Kernel::Pixel>::toString(prefix);
178 return static_cast<double>((fabs(this->_params[0]) < 0.5) == (fabs(x) < 0.5));
183 checkWarpingKernelParameter(
this, ind, value);
190 std::string afwMath::NearestWarpingKernel::NearestFunction1::toString(std::string
const& prefix)
const {
191 std::ostringstream os;
192 os <<
"_NearestFunction1: ";
193 os << Function1<Kernel::Pixel>::toString(prefix);
198 typedef boost::shared_ptr<afwMath::SeparableKernel> KernelPtr;
199 boost::cmatch matches;
200 static const boost::regex LanczosRE(
"lanczos(\\d+)");
201 if (name ==
"bilinear") {
203 }
else if (boost::regex_match(name.c_str(), matches, LanczosRE)) {
204 std::string orderStr(matches[1].first, matches[1].second);
206 std::istringstream(orderStr) >> order;
208 }
else if (name ==
"nearest") {
211 throw LSST_EXCEPT(pexExcept::InvalidParameterError,
212 "unknown warping kernel name: \"" + name +
"\"");
217 if (_warpingKernelPtr->getCacheSize() != _cacheSize) {
218 _warpingKernelPtr->computeCache(_cacheSize);
220 return _warpingKernelPtr;
227 setWarpingKernel(*warpingKernelPtr);
233 if (_maskWarpingKernelPtr) {
234 _testWarpingKernels(warpingKernel, *_maskWarpingKernelPtr);
237 _testDevicePreference(_devicePreference, warpingKernelPtr);
238 _warpingKernelPtr = warpingKernelPtr;
243 if (_maskWarpingKernelPtr) {
244 if (_maskWarpingKernelPtr->getCacheSize() != _cacheSize) {
245 _maskWarpingKernelPtr->computeCache(_cacheSize);
248 return _maskWarpingKernelPtr;
252 std::string
const &maskWarpingKernelName
254 if (!maskWarpingKernelName.empty()) {
256 setMaskWarpingKernel(*maskWarpingKernelPtr);
258 _maskWarpingKernelPtr.reset();
265 _testWarpingKernels(*_warpingKernelPtr, maskWarpingKernel);
282 if (!kernelBBox.
contains(maskKernelBBox)) {
283 throw LSST_EXCEPT(lsst::pex::exceptions::InvalidParameterError,
284 "warping kernel is smaller than mask warping kernel");
295 throw LSST_EXCEPT(lsst::pex::exceptions::InvalidParameterError,
296 "devicePreference = USE_GPU, but warping kernel not Lanczos");
302 template<
typename DestExposureT,
typename SrcExposureT>
304 DestExposureT &destExposure,
305 SrcExposureT
const &srcExposure,
307 typename DestExposureT::MaskedImageT::SinglePixel padValue
310 if (!destExposure.hasWcs()) {
311 throw LSST_EXCEPT(pexExcept::InvalidParameterError,
"destExposure has no Wcs");
313 if (!srcExposure.hasWcs()) {
314 throw LSST_EXCEPT(pexExcept::InvalidParameterError,
"srcExposure has no Wcs");
316 typename DestExposureT::MaskedImageT mi = destExposure.getMaskedImage();
317 boost::shared_ptr<afwImage::Calib> calibCopy(
new afwImage::Calib(*srcExposure.getCalib()));
318 destExposure.setCalib(calibCopy);
319 destExposure.setFilter(srcExposure.getFilter());
320 return warpImage(mi, *destExposure.getWcs(), srcExposure.getMaskedImage(), *srcExposure.getWcs(),
324 template<
typename DestExposureT,
typename SrcExposureT>
326 DestExposureT &destExposure,
327 SrcExposureT
const &srcExposure,
329 int const interpLength,
330 typename DestExposureT::MaskedImageT::SinglePixel padValue,
334 if (!destExposure.hasWcs()) {
335 throw LSST_EXCEPT(pexExcept::InvalidParameterError,
"destExposure has no Wcs");
337 if (!srcExposure.hasWcs()) {
338 throw LSST_EXCEPT(pexExcept::InvalidParameterError,
"srcExposure has no Wcs");
340 typename DestExposureT::MaskedImageT mi = destExposure.getMaskedImage();
341 boost::shared_ptr<afwImage::Calib> calibCopy(
new afwImage::Calib(*srcExposure.getCalib()));
342 destExposure.setCalib(calibCopy);
343 destExposure.setFilter(srcExposure.getFilter());
344 return warpImage(mi, *destExposure.getWcs(),
345 srcExposure.getMaskedImage(), *srcExposure.getWcs(), warpingKernel, interpLength,
368 inline double computeRelativeArea(
376 return std::abs(dSrcA.getX()*dSrcB.getY() - dSrcA.getY()*dSrcB.getX());
379 template<
typename DestImageT,
typename SrcImageT>
381 DestImageT &destImage,
382 SrcImageT
const &srcImage,
383 afwMath::detail::PositionFunctor
const &computeSrcPos,
385 typename DestImageT::SinglePixel padValue
388 throw LSST_EXCEPT(pexExcept::InvalidParameterError,
389 "destImage is srcImage; cannot warp in place");
397 warpingKernelPtr->shrinkBBox(srcImage.getBBox(afwImage::
LOCAL));
399 for (
int y = 0, height = destImage.getHeight();
y < height; ++
y) {
400 for (
typename DestImageT::x_iterator destPtr = destImage.row_begin(
y), end = destImage.row_end(
y);
401 destPtr != end; ++destPtr) {
408 int interpLength = control.getInterpLength();
411 boost::shared_ptr<afwMath::LanczosWarpingKernel const> const lanczosKernelPtr =
412 boost::dynamic_pointer_cast<afwMath::LanczosWarpingKernel>(warpingKernelPtr);
415 if(!lanczosKernelPtr) {
417 throw LSST_EXCEPT(pexExcept::InvalidParameterError,
"Gpu can process only Lanczos kernels");
421 if (control.getMaskWarpingKernel() )
422 maskWarpingKernelPtr = control.getMaskWarpingKernel();
425 std::pair<int, afwMath::detail::WarpImageGpuStatus::ReturnCode> result =
427 *lanczosKernelPtr, *maskWarpingKernelPtr,
428 computeSrcPos, interpLength, padValue,
false);
431 catch(lsst::afw::gpu::GpuMemoryError) { }
432 catch(pexExcept::MemoryError) { }
433 catch(lsst::afw::gpu::GpuRuntimeError) { }
435 std::pair<int, afwMath::detail::WarpImageGpuStatus::ReturnCode> result =
437 *lanczosKernelPtr, *maskWarpingKernelPtr,
438 computeSrcPos, interpLength, padValue,
443 "Gpu cannot perform this warp (kernel too big?)");
449 int numGoodPixels = 0;
452 int const srcWidth = srcImage.getWidth();
453 int const srcHeight = srcImage.getHeight();
454 pexLog::TTrace<3>(
"lsst.afw.math.warp",
"source image width=%d; height=%d", srcWidth, srcHeight);
456 int const destWidth = destImage.getWidth();
457 int const destHeight = destImage.getHeight();
459 pexLog::TTrace<3>(
"lsst.afw.math.warp",
"remap image width=%d; height=%d", destWidth, destHeight);
462 pexLog::TTrace<4>(
"lsst.afw.math.warp",
"Remapping masked image");
471 std::vector<afwGeom::Point2D> _srcPosList(1 + destWidth);
472 std::vector<afwGeom::Point2D>::iterator
const srcPosView = _srcPosList.begin() + 1;
474 int const maxCol = destWidth - 1;
475 int const maxRow = destHeight - 1;
477 afwMath::detail::WarpAtOnePoint<DestImageT, SrcImageT> warpAtOnePoint(srcImage, control, padValue);
479 if (interpLength > 0) {
484 int const numColEdges = 2 + ((destWidth - 1) / interpLength);
488 std::vector<int> edgeColList;
489 edgeColList.reserve(numColEdges);
493 std::vector<double> invWidthList;
494 invWidthList.reserve(numColEdges);
497 edgeColList.push_back(-1);
498 invWidthList.push_back(0.0);
499 for (
int prevEndCol = -1; prevEndCol < maxCol; prevEndCol += interpLength) {
500 int endCol = prevEndCol + interpLength;
501 if (endCol > maxCol) {
504 edgeColList.push_back(endCol);
505 assert(endCol - prevEndCol > 0);
506 invWidthList.push_back(1.0 / static_cast<double>(endCol - prevEndCol));
508 assert(edgeColList.back() == maxCol);
511 std::vector<afwGeom::Extent2D> yDeltaSrcPosList(edgeColList.size());
515 srcPosView[-1] = computeSrcPos(-1, -1);
516 for (
int colBand = 1, endBand = edgeColList.size(); colBand < endBand; ++colBand) {
517 int const prevEndCol = edgeColList[colBand-1];
518 int const endCol = edgeColList[colBand];
521 afwGeom::Extent2D xDeltaSrcPos = (rightSrcPos - leftSrcPos) * invWidthList[colBand];
523 for (
int col = prevEndCol + 1; col <= endCol; ++
col) {
524 srcPosView[
col] = srcPosView[col-1] + xDeltaSrcPos;
529 while (endRow < maxRow) {
532 int prevEndRow = endRow;
533 endRow = prevEndRow + interpLength;
534 if (endRow > maxRow) {
537 assert(endRow - prevEndRow > 0);
538 double interpInvHeight = 1.0 /
static_cast<double>(endRow - prevEndRow);
541 for (
int colBand = 0, endBand = edgeColList.size(); colBand < endBand; ++colBand) {
542 int endCol = edgeColList[colBand];
544 yDeltaSrcPosList[colBand] = (bottomSrcPos - srcPosView[endCol]) * interpInvHeight;
547 for (
int row = prevEndRow + 1; row <= endRow; ++
row) {
548 typename DestImageT::x_iterator destXIter = destImage.row_begin(row);
549 srcPosView[-1] += yDeltaSrcPosList[0];
550 for (
int colBand = 1, endBand = edgeColList.size(); colBand < endBand; ++colBand) {
553 int const prevEndCol = edgeColList[colBand-1];
554 int const endCol = edgeColList[colBand];
560 afwGeom::Point2D rightSrcPos = srcPosView[endCol] + yDeltaSrcPosList[colBand];
561 afwGeom::Extent2D xDeltaSrcPos = (rightSrcPos - leftSrcPos) * invWidthList[colBand];
563 for (
int col = prevEndCol + 1; col <= endCol; ++
col, ++destXIter) {
566 double relativeArea = computeRelativeArea(srcPos, leftSrcPos, srcPosView[col]);
568 srcPosView[
col] = srcPos;
570 if (warpAtOnePoint(destXIter, srcPos, relativeArea,
585 std::vector<afwGeom::Point2D>::iterator srcPosView = _srcPosList.begin() + 1;
586 for (
int col = -1; col < destWidth; ++
col) {
587 srcPosView[
col] = computeSrcPos(col, -1);
590 for (
int row = 0; row < destHeight; ++
row) {
591 typename DestImageT::x_iterator destXIter = destImage.row_begin(row);
593 srcPosView[-1] = computeSrcPos(-1, row);
595 for (
int col = 0; col < destWidth; ++
col, ++destXIter) {
597 double relativeArea = computeRelativeArea(srcPos, srcPosView[col-1], srcPosView[col]);
598 srcPosView[
col] = srcPos;
600 if (warpAtOnePoint(destXIter, srcPos, relativeArea,
608 return numGoodPixels;
613 template<
typename DestImageT,
typename SrcImageT>
615 DestImageT &destImage,
617 SrcImageT
const &srcImage,
620 typename DestImageT::SinglePixel padValue
623 afwMath::detail::WcsPositionFunctor
const computeSrcPos(destXY0, destWcs, srcWcs);
624 return doWarpImage(destImage, srcImage, computeSrcPos, control, padValue);
627 template<
typename DestImageT,
typename SrcImageT>
629 DestImageT &destImage,
631 SrcImageT
const &srcImage,
634 int const interpLength,
635 typename DestImageT::SinglePixel padValue,
639 afwMath::detail::WcsPositionFunctor
const computeSrcPos(destXY0, destWcs, srcWcs);
641 return doWarpImage(destImage, srcImage, computeSrcPos, control, padValue);
645 template<
typename DestImageT,
typename SrcImageT>
647 DestImageT &destImage,
648 SrcImageT
const &srcImage,
651 typename DestImageT::SinglePixel padValue
654 afwMath::detail::AffineTransformPositionFunctor
const computeSrcPos(destXY0, affineTransform);
655 return doWarpImage(destImage, srcImage, computeSrcPos, control, padValue);
659 template<
typename DestImageT,
typename SrcImageT>
661 DestImageT &destImage,
662 SrcImageT
const &srcImage,
665 int const interpLength,
666 typename DestImageT::SinglePixel padValue,
671 afwMath::detail::AffineTransformPositionFunctor
const computeSrcPos(destXY0, affineTransform);
673 return doWarpImage(destImage, srcImage, computeSrcPos, control, padValue);
677 template<
typename DestImageT,
typename SrcImageT>
679 DestImageT &destImage,
680 SrcImageT
const &srcImage,
684 typename DestImageT::SinglePixel padValue
688 (destImage.getWidth() != srcImage.getWidth()) ||
689 (destImage.getHeight() != srcImage.getHeight()) ||
690 (destImage.getXY0() != srcImage.getXY0())
692 std::ostringstream errStream;
693 errStream <<
"src and dest images must have same size and xy0.";
694 throw LSST_EXCEPT(pexExcept::InvalidParameterError, errStream.str());
698 SrcImageT srcImageCopy(srcImage,
true);
699 srcImageCopy.setXY0(0, 0);
700 destImage.setXY0(0, 0);
710 static float t = 0.0;
711 float t_before = 1.0*clock()/CLOCKS_PER_SEC;
712 int n =
warpImage(destImage, srcImageCopy, affTran, control, padValue);
713 float t_after = 1.0*clock()/CLOCKS_PER_SEC;
714 float dt = t_after - t_before;
716 std::cout <<srcImage.getWidth()<<
"x"<<srcImage.getHeight()<<
": "<< dt <<
" "<< t <<std::endl;
718 int n =
warpImage(destImage, srcImageCopy, affTran, control, padValue);
722 destImage.setXY0(srcImage.getXY0());
728 template<
typename DestImageT,
typename SrcImageT>
730 DestImageT &destImage,
731 SrcImageT
const &srcImage,
735 int const interpLength,
736 typename DestImageT::SinglePixel padValue,
740 return warpCenteredImage(destImage, srcImage, linearTransform, centerPosition, control, padValue);
749 #define EXPOSURE(PIXTYPE) afwImage::Exposure<PIXTYPE, afwImage::MaskPixel, afwImage::VariancePixel>
750 #define MASKEDIMAGE(PIXTYPE) afwImage::MaskedImage<PIXTYPE, afwImage::MaskPixel, afwImage::VariancePixel>
751 #define IMAGE(PIXTYPE) afwImage::Image<PIXTYPE>
754 #define INSTANTIATE(DESTIMAGEPIXELT, SRCIMAGEPIXELT) \
755 template int afwMath::warpCenteredImage( \
756 IMAGE(DESTIMAGEPIXELT) &destImage, \
757 IMAGE(SRCIMAGEPIXELT) const &srcImage, \
758 afwGeom::LinearTransform const &linearTransform, \
759 afwGeom::Point2D const ¢erPosition, \
760 afwMath::WarpingControl const &control, \
761 IMAGE(DESTIMAGEPIXELT)::SinglePixel padValue); NL \
762 template int afwMath::warpCenteredImage( \
763 MASKEDIMAGE(DESTIMAGEPIXELT) &destImage, \
764 MASKEDIMAGE(SRCIMAGEPIXELT) const &srcImage, \
765 afwGeom::LinearTransform const &linearTransform, \
766 afwGeom::Point2D const ¢erPosition, \
767 afwMath::WarpingControl const &control, \
768 MASKEDIMAGE(DESTIMAGEPIXELT)::SinglePixel padValue); NL \
769 template int afwMath::warpCenteredImage( \
770 IMAGE(DESTIMAGEPIXELT) &destImage, \
771 IMAGE(SRCIMAGEPIXELT) const &srcImage, \
772 afwMath::SeparableKernel &warpingKernel, \
773 afwGeom::LinearTransform const &linearTransform, \
774 afwGeom::Point2D const ¢erPosition, \
775 int const interpLength, \
776 IMAGE(DESTIMAGEPIXELT)::SinglePixel padValue, \
777 lsst::afw::gpu::DevicePreference devPref); NL \
778 template int afwMath::warpCenteredImage( \
779 MASKEDIMAGE(DESTIMAGEPIXELT) &destImage, \
780 MASKEDIMAGE(SRCIMAGEPIXELT) const &srcImage, \
781 afwMath::SeparableKernel &warpingKernel, \
782 afwGeom::LinearTransform const &linearTransform, \
783 afwGeom::Point2D const ¢erPosition, \
784 int const interpLength, \
785 MASKEDIMAGE(DESTIMAGEPIXELT)::SinglePixel padValue, \
786 lsst::afw::gpu::DevicePreference devPref); NL \
787 template int afwMath::warpImage( \
788 IMAGE(DESTIMAGEPIXELT) &destImage, \
789 IMAGE(SRCIMAGEPIXELT) const &srcImage, \
790 afwGeom::AffineTransform const &affineTransform, \
791 afwMath::WarpingControl const &control, \
792 IMAGE(DESTIMAGEPIXELT)::SinglePixel padValue); NL \
793 template int afwMath::warpImage( \
794 MASKEDIMAGE(DESTIMAGEPIXELT) &destImage, \
795 MASKEDIMAGE(SRCIMAGEPIXELT) const &srcImage, \
796 afwGeom::AffineTransform const &affineTransform, \
797 afwMath::WarpingControl const &control, \
798 MASKEDIMAGE(DESTIMAGEPIXELT)::SinglePixel padValue); NL \
799 template int afwMath::warpImage( \
800 IMAGE(DESTIMAGEPIXELT) &destImage, \
801 IMAGE(SRCIMAGEPIXELT) const &srcImage, \
802 afwMath::SeparableKernel &warpingKernel, \
803 afwGeom::AffineTransform const &affineTransform, \
804 int const interpLength, \
805 IMAGE(DESTIMAGEPIXELT)::SinglePixel padValue, \
806 lsst::afw::gpu::DevicePreference devPref); NL \
807 template int afwMath::warpImage( \
808 MASKEDIMAGE(DESTIMAGEPIXELT) &destImage, \
809 MASKEDIMAGE(SRCIMAGEPIXELT) const &srcImage, \
810 afwMath::SeparableKernel &warpingKernel, \
811 afwGeom::AffineTransform const &affineTransform, \
812 int const interpLength, \
813 MASKEDIMAGE(DESTIMAGEPIXELT)::SinglePixel padValue, \
814 lsst::afw::gpu::DevicePreference devPref); NL \
815 template int afwMath::warpImage( \
816 IMAGE(DESTIMAGEPIXELT) &destImage, \
817 afwImage::Wcs const &destWcs, \
818 IMAGE(SRCIMAGEPIXELT) const &srcImage, \
819 afwImage::Wcs const &srcWcs, \
820 afwMath::WarpingControl const &control, \
821 IMAGE(DESTIMAGEPIXELT)::SinglePixel padValue); NL \
822 template int afwMath::warpImage( \
823 MASKEDIMAGE(DESTIMAGEPIXELT) &destImage, \
824 afwImage::Wcs const &destWcs, \
825 MASKEDIMAGE(SRCIMAGEPIXELT) const &srcImage, \
826 afwImage::Wcs const &srcWcs, \
827 afwMath::WarpingControl const &control, \
828 MASKEDIMAGE(DESTIMAGEPIXELT)::SinglePixel padValue); NL \
829 template int afwMath::warpImage( \
830 IMAGE(DESTIMAGEPIXELT) &destImage, \
831 afwImage::Wcs const &destWcs, \
832 IMAGE(SRCIMAGEPIXELT) const &srcImage, \
833 afwImage::Wcs const &srcWcs, \
834 afwMath::SeparableKernel &warpingKernel, \
835 int const interpLength, \
836 IMAGE(DESTIMAGEPIXELT)::SinglePixel padValue, \
837 lsst::afw::gpu::DevicePreference devPref); NL \
838 template int afwMath::warpImage( \
839 MASKEDIMAGE(DESTIMAGEPIXELT) &destImage, \
840 afwImage::Wcs const &destWcs, \
841 MASKEDIMAGE(SRCIMAGEPIXELT) const &srcImage, \
842 afwImage::Wcs const &srcWcs, \
843 afwMath::SeparableKernel &warpingKernel, \
844 int const interpLength, \
845 MASKEDIMAGE(DESTIMAGEPIXELT)::SinglePixel padValue, \
846 lsst::afw::gpu::DevicePreference devPref); NL \
847 template int afwMath::warpExposure( \
848 EXPOSURE(DESTIMAGEPIXELT) &destExposure, \
849 EXPOSURE(SRCIMAGEPIXELT) const &srcExposure, \
850 afwMath::WarpingControl const &control,\
851 EXPOSURE(DESTIMAGEPIXELT)::MaskedImageT::SinglePixel padValue); NL \
852 template int afwMath::warpExposure( \
853 EXPOSURE(DESTIMAGEPIXELT) &destExposure, \
854 EXPOSURE(SRCIMAGEPIXELT) const &srcExposure, \
855 afwMath::SeparableKernel &warpingKernel, \
856 int const interpLength, \
857 EXPOSURE(DESTIMAGEPIXELT)::MaskedImageT::SinglePixel padValue, \
858 lsst::afw::gpu::DevicePreference devPref);
bool isGpuEnabled()
returns true if GPU acceleration is enabled
void setWarpingKernel(SeparableKernel const &warpingKernel)
set the warping kernel
GPU accelerared image warping.
An include file to include the header files for lsst::afw::geom.
Declare the Kernel class and subclasses.
int getWidth() const
Return the Kernel's width.
double indexToPosition(double ind)
Convert image index to image position.
virtual void setKernelParameter(unsigned int ind, double value) const
Set one kernel parameter.
table::Key< std::string > name
additional GPU exceptions
boost::shared_ptr< SeparableKernel > makeWarpingKernel(std::string name)
Return a warping kernel given its name.
Extent< double, 2 > Extent2D
geom::Point2D skyToPixel(geom::Angle sky1, geom::Angle sky2) const
Convert from sky coordinates (e.g. RA/dec) to pixel positions.
definition of the Trace messaging facilities
A kernel described by a pair of functions: func(x, y) = colFunc(x) * rowFunc(y)
Parameters to control convolution.
lsst::afw::geom::Point2I getCtr() const
Return index of kernel's center.
Implementation of the WCS standard for a any projection.
int warpCenteredImage(DestImageT &destImage, SrcImageT const &srcImage, lsst::afw::geom::LinearTransform const &linearTransform, lsst::afw::geom::Point2D const ¢erPosition, 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 with a LinearTranform about a specified point. This enables warping an image of e...
boost::shared_ptr< coord::Coord > pixelToSky(double pix1, double pix2) const
Convert from pixel position to sky coordinates (e.g. RA/dec)
DevicePreference
A type used to select whether to use CPU or GPU device.
An integer coordinate rectangle.
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()))
Warp an Image or MaskedImage to a new Wcs. See also convenience function warpExposure() to warp an Ex...
table::Key< table::Array< Kernel::Pixel > > image
virtual void setKernelParameter(unsigned int ind, double value) const
Set one kernel parameter.
int warpExposure(DestExposureT &destExposure, SrcExposureT const &srcExposure, WarpingControl const &control, typename DestExposureT::MaskedImageT::SinglePixel padValue=lsst::afw::math::edgePixel< typename DestExposureT::MaskedImageT >(typename lsst::afw::image::detail::image_traits< typename DestExposureT::MaskedImageT >::image_category()))
Warp (remap) one exposure to another.
void setMaskWarpingKernelName(std::string const &maskWarpingKernelName)
set or clear the mask warping kernel by name
ImageT::image_category image_category
int getOrder() const
get the order of the kernel
virtual boost::shared_ptr< Kernel > clone() const
Return a pointer to a deep copy of this kernel.
bool isSameObject(A const &, B const &)
void setWarpingKernelName(std::string const &warpingKernelName)
set the warping kernel by name
geom::Extent2I const getDimensions() const
Return the Kernel's dimensions (width, height)
bool isGpuBuild()
Inline function which returns true only when GPU_BUILD macro is defined.
if(width!=gim.getWidth()||height!=gim.getHeight()||x0!=gim.getX0()||y0!=gim.getY0())
Interface for CPU/GPU device selection.
bool contains(Point2I const &point) const
Return true if the box contains the point.
std::pair< int, WarpImageGpuStatus::ReturnCode > warpImageGPU(DestImageT &destImage, SrcImageT const &srcImage, lsst::afw::math::LanczosWarpingKernel const &warpingKernel, lsst::afw::math::SeparableKernel const &maskWarpingKernel, PositionFunctor const &computeSrcPos, int const interpLength, typename DestImageT::SinglePixel padValue, const bool forceProcessing=true)
GPU accelerated image warping using Lanczos resampling.
void _testDevicePreference(lsst::afw::gpu::DevicePreference const &devicePreference, boost::shared_ptr< SeparableKernel const > const &warpingKernelPtr) const
test if GPU device preference and main warping kernel are compatible
Bilinear warping: fast; good for undersampled data.
#define LSST_EXCEPT(type,...)
virtual void setKernelParameter(unsigned int ind, double value) const
Set one kernel parameter.
tbl::Key< std::string > warpingKernelName
void _testWarpingKernels(SeparableKernel const &warpingKernel, SeparableKernel const &maskWarpingKernel) const
Throw an exception if the two kernels are not compatible in shape.
Support for warping an image to a new WCS.
Nearest neighbor warping: fast; good for undersampled data.
Lanczos warping: accurate but slow and can introduce ringing artifacts.
GPU accelerared image warping.
virtual void setKernelParameter(unsigned int ind, double value) const
Set one kernel parameter.
Kernels are used for convolution with MaskedImages and (eventually) Images.
Include files required for standard LSST Exception handling.
A function to determine whether compiling for GPU is enabled.
void setMaskWarpingKernel(SeparableKernel const &maskWarpingKernel)
set the mask warping kernel
Functions to handle coordinates.