|
template<typename OutImageT , typename InImageT > |
void | assertDimensionsOK (OutImageT const &convolvedImage, InImageT const &inImage, lsst::afw::math::Kernel const &kernel) |
|
template<typename OutImageT , typename InImageT > |
void | basicConvolve (OutImageT &convolvedImage, InImageT const &inImage, lsst::afw::math::Kernel const &kernel, lsst::afw::math::ConvolutionControl const &convolutionControl) |
| Low-level convolution function that does not set edge pixels. More...
|
|
template<typename OutImageT , typename InImageT > |
void | basicConvolve (OutImageT &convolvedImage, InImageT const &inImage, lsst::afw::math::DeltaFunctionKernel const &kernel, lsst::afw::math::ConvolutionControl const &) |
| A version of basicConvolve that should be used when convolving delta function kernels. More...
|
|
template<typename OutImageT , typename InImageT > |
void | basicConvolve (OutImageT &convolvedImage, InImageT const &inImage, lsst::afw::math::LinearCombinationKernel const &kernel, lsst::afw::math::ConvolutionControl const &convolutionControl) |
| A version of basicConvolve that should be used when convolving a LinearCombinationKernel. More...
|
|
template<typename OutImageT , typename InImageT > |
void | basicConvolve (OutImageT &convolvedImage, InImageT const &inImage, lsst::afw::math::SeparableKernel const &kernel, lsst::afw::math::ConvolutionControl const &convolutionControl) |
| A version of basicConvolve that should be used when convolving separable kernels. More...
|
|
template<typename OutImageT , typename InImageT > |
void | convolveWithBruteForce (OutImageT &convolvedImage, InImageT const &inImage, lsst::afw::math::Kernel const &kernel, lsst::afw::math::ConvolutionControl const &convolutionControl) |
| Convolve an Image or MaskedImage with a Kernel by computing the kernel image at every point. (If the kernel is not spatially varying then only compute it once). More...
|
|
template<typename OutImageT , typename InImageT > |
void | convolveWithInterpolation (OutImageT &outImage, InImageT const &inImage, lsst::afw::math::Kernel const &kernel, ConvolutionControl const &convolutionControl) |
| Convolve an Image or MaskedImage with a spatially varying Kernel using linear interpolation. More...
|
|
template<typename OutImageT , typename InImageT > |
void | convolveRegionWithInterpolation (OutImageT &outImage, InImageT const &inImage, KernelImagesForRegion const ®ion, ConvolveWithInterpolationWorkingImages &workingImages) |
| Convolve a region of an Image or MaskedImage with a spatially varying Kernel using interpolation. More...
|
|
template<typename OutImageT , typename InImageT > |
ConvolveGpuStatus::ReturnCode | basicConvolveGPU (OutImageT &convolvedImage, InImageT const &inImage, lsst::afw::math::Kernel const &kernel, lsst::afw::math::ConvolutionControl const &convolutionControl) |
|
template<typename OutPixelT , typename InPixelT > |
ConvolveGpuStatus::ReturnCode | convolveLinearCombinationGPU (lsst::afw::image::MaskedImage< OutPixelT, lsst::afw::image::MaskPixel, lsst::afw::image::VariancePixel > &convolvedImage, lsst::afw::image::MaskedImage< InPixelT, lsst::afw::image::MaskPixel, lsst::afw::image::VariancePixel > const &inImage, lsst::afw::math::LinearCombinationKernel const &kernel, lsst::afw::math::ConvolutionControl const &convolutionControl) |
|
template<typename OutPixelT , typename InPixelT > |
ConvolveGpuStatus::ReturnCode | convolveLinearCombinationGPU (lsst::afw::image::Image< OutPixelT > &convolvedImage, lsst::afw::image::Image< InPixelT > const &inImage, lsst::afw::math::LinearCombinationKernel const &kernel, lsst::afw::math::ConvolutionControl const &convolutionControl) |
|
template<typename OutPixelT , typename InPixelT > |
ConvolveGpuStatus::ReturnCode | convolveSpatiallyInvariantGPU (lsst::afw::image::MaskedImage< OutPixelT, lsst::afw::image::MaskPixel, lsst::afw::image::VariancePixel > &convolvedImage, lsst::afw::image::MaskedImage< InPixelT, lsst::afw::image::MaskPixel, lsst::afw::image::VariancePixel > const &inImage, lsst::afw::math::Kernel const &kernel, lsst::afw::math::ConvolutionControl const &convolutionControl) |
|
template<typename OutPixelT , typename InPixelT > |
ConvolveGpuStatus::ReturnCode | convolveSpatiallyInvariantGPU (lsst::afw::image::Image< OutPixelT > &convolvedImage, lsst::afw::image::Image< InPixelT > const &inImage, lsst::afw::math::Kernel const &kernel, lsst::afw::math::ConvolutionControl const &convolutionControl) |
|
bool | IsSufficientSharedMemoryAvailable_ForImgBlock (int filterW, int filterH, int pixSize) |
|
bool | IsSufficientSharedMemoryAvailable_ForImgAndMaskBlock (int filterW, int filterH, int pixSize) |
|
bool | IsSufficientSharedMemoryAvailable_ForSfn (int order, int kernelN) |
|
template<typename DestImageT , typename SrcImageT > |
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. More...
|
|
void | TestGpuKernel (int &ret1, int &ret2) |
|
template<typename DestImageT , typename SrcImageT >
GPU accelerated image warping using Lanczos resampling.
- Returns
- a std::pair<int,WarpImageGpuStatus::ReturnValue> containing: 1) the number of valid pixels in destImage (those that are not edge pixels). 2) whether the warping was performed successfully, or error code (if not OK, then the first value is not defined)
This function requires a Lanczos warping kernel to perform the source value estimation.
This function will not perform the warping if kernel size is too large. (currently, when the order of the Lanczos kernel is >50) If warping is not performed, the second elemnt of return value will not equal OK. If forceProcessing is true:
- this function will throw exceptions if a GPU device cannot be selected or used If forceProcessing is false:
- the warping will not be performed if the GPU code path is estimated to be slower than the CPU code path. That might happen if interpLength is too small (less than 3).
- the warping will not be performed if a GPU device cannot be selected or used
- Precondition
- maskWarpingKernel must not be greater in size than warpingKernel
Also see lsst::afw::math::warpImage()
Implementation: Calculates values of the coordinate transform function at some points, which are spaced by interpLength intervals. Calls CalculateInterpolationData() to calculate interpolation data from values of coordinate transformation fn. Calls WarpImageGpuWrapper() to perform the wapring.
- Exceptions
-
lsst::pex::exceptions::InvalidParameterError | if interpLength < 1 |
lsst::pex::exceptions::InvalidParameterError | if maskWarpingKernel is neither Lanczos, bilinear nor nearest neighbor |
lsst::pex::exceptions::MemoryError | when allocation of CPU memory fails |
lsst::afw::gpu::GpuMemoryError | when allocation or transfer to/from GPU memory fails |
lsst::afw::gpu::GpuRuntimeError | when GPU code run fails |
- Parameters
-
destImage | remapped image |
srcImage | source image |
warpingKernel | warping kernel |
maskWarpingKernel | mask warping kernel (can be the same as warping kernel) |
computeSrcPos | Functor to compute source position |
interpLength | Distance over which WCS can be linearily interpolated must be >0 |
padValue | value to use for undefined pixels |
forceProcessing | if true, this function will perform the warping even when it is slower then the CPU code path |
Definition at line 395 of file cudaLanczosWrapper.cc.
406 if (interpLength < 1) {
407 throw LSST_EXCEPT(pexExcept::InvalidParameterError,
408 "GPU accelerated warping must use interpolation");
411 int const srcWidth = srcImage.getWidth();
412 int const srcHeight = srcImage.getHeight();
413 pexLog::TTrace<3>(
"lsst.afw.math.warp",
"(GPU) source image width=%d; height=%d", srcWidth, srcHeight);
416 throw LSST_EXCEPT(afwGpu::GpuRuntimeError,
"Afw not compiled with GPU support");
422 if (dynamic_cast<afwMath::LanczosWarpingKernel const*>(&maskWarpingKernel)) {
424 }
else if (dynamic_cast<afwMath::BilinearWarpingKernel const*>(&maskWarpingKernel)) {
426 }
else if (dynamic_cast<afwMath::NearestWarpingKernel const*>(&maskWarpingKernel)) {
429 throw LSST_EXCEPT(pexExcept::InvalidParameterError,
"unknown type of mask warping kernel");
438 int const mainKernelSize = 2 * lanczosKernel.getOrder();
445 if (!forceProcessing && interpLength < 3) {
449 int const destWidth = destImage.getWidth();
450 int const destHeight = destImage.getHeight();
451 pexLog::TTrace<3>(
"lsst.afw.math.warp",
"(GPU) remap image width=%d; height=%d", destWidth, destHeight);
453 int const maxCol = destWidth - 1;
454 int const maxRow = destHeight - 1;
461 int const interpBlkNX = InterpBlkN(destWidth , interpLength);
462 int const interpBlkNY = InterpBlkN(destHeight, interpLength);
467 for (
int rowBand = 0; rowBand < interpBlkNY; rowBand++) {
468 int row = min(maxRow, (rowBand * interpLength - 1));
469 for (
int colBand = 0; colBand < interpBlkNX; colBand++) {
470 int col = min(maxCol, (colBand * interpLength - 1));
473 sSrcPos =
MovePoint(sSrcPos,
SVec2(-srcImage.getX0(), -srcImage.getY0()));
474 srcPosInterp.Pixel(colBand, rowBand).o = sSrcPos;
478 CalculateInterpolationData(srcPosInterp, interpLength, destWidth, destHeight);
480 int numGoodPixels = 0;
482 pexLog::TTrace<3>(
"lsst.afw.math.warp",
"using GPU acceleration, remapping masked image");
491 numGoodPixels = WarpImageGpuWrapper(destImage,
497 srcPosInterp, interpLength, padValue
Class for representing an image or 2D array in general)
SPoint2 MovePoint(SPoint2 p, SVec2 v)
bool TryToSelectCudaDevice(bool noExceptions, bool reselect=false)
int const SIZE_MAX_WARPING_KERNEL
An integer coordinate rectangle.
Simple 2D point (suitable for use on a GPU)
bool isGpuBuild()
Inline function which returns true only when GPU_BUILD macro is defined.
Simple 2D vector (suitable for use on a GPU)
#define LSST_EXCEPT(type,...)
Lanczos warping: accurate but slow and can introduce ringing artifacts.