在CUDA SDK 发行版中的Nvidia Performance Primitives (NPP)图像处理示例中,图像通常作为对象存储在 CPU 上,而图像作为对象存储在 GPU 上。ImageCPU
ImageNPP
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