Nvidia Performance Primitives(NPP)提供了nppiFilter将用户提供的图像与用户提供的内核进行卷积的功能.对于1D卷积内核,nppiFilter可以正常工作.但是,nppiFilter正在为2D内核生成垃圾图像.
我使用典型的Lena图像作为输入:

这是我使用1D卷积内核的实验,它可以产生良好的输出.
#include <npp.h> // provided in CUDA SDK
#include <ImagesCPU.h> // these image libraries are also in CUDA SDK
#include <ImagesNPP.h>
#include <ImageIO.h>
void test_nppiFilter()
{
npp::ImageCPU_8u_C1 oHostSrc;
npp::loadImage("Lena.pgm", oHostSrc);
npp::ImageNPP_8u_C1 oDeviceSrc(oHostSrc); // malloc and memcpy to GPU
NppiSize kernelSize = {3, 1}; // dimensions of convolution kernel (filter)
NppiSize oSizeROI = {oHostSrc.width() - kernelSize.width + 1, oHostSrc.height() - kernelSize.height + 1};
npp::ImageNPP_8u_C1 oDeviceDst(oSizeROI.width, oSizeROI.height); // allocate …Run Code Online (Sandbox Code Playgroud)