在CUDA SDK 发行版中的Nvidia Performance Primitives (NPP)图像处理示例中,图像通常作为对象存储在 CPU 上,而图像作为对象存储在 GPU 上。ImageCPUImageNPP
boxFilterNPP.cpp是 CUDA SDK 中使用这些ImageCPU和ImageNPP对象的示例。
当使用类似的过滤器(卷积)函数nppiFilter时,将过滤器定义为对象是有意义的ImageCPU。但是,我看不到设置对象值的明确方法ImageCPU。
npp::ImageCPU_32f_C1 hostKernel(3,3); //allocate space for 3x3 convolution kernel
//want to set hostKernel to [-1 0 1; -1 0 1; -1 0 1]
hostKernel[0][0] = -1; //this doesn't compile
hostKernel(0,0) = -1; //this doesn't compile
hostKernel.at(0,0) = -1; //this doesn't compile
如何手动将值放入ImageCPU对象中?
笔记:
- 我实际上并没有
nppiFilter在代码片段中使用;我只是提到nppiFilter一个将值写入ImageCPU对象的激励示例。 - boxFilterNPP.cpp示例不涉及直接写入对象
ImageCPU,因为它是使用内置高斯平滑滤波器的nppiFilterBox一种特殊情况(可能类似于 [1 1 1; 1 1 1; 1 1 1])。nppiFilter