gpt4 book ai didi

c++ - 在 Nvidia NPP ImageCPU 对象中设置像素值?

转载 作者:太空狗 更新时间:2023-10-29 21:47:43 25 4
gpt4 key购买 nike

Nvidia Performance Primitives (NPP) CUDA SDK distribution中的图像处理实例,图像通常作为 ImageCPU 对象存储在 CPU 上,图像通常作为 ImageNPP 对象存储在 GPU 上。

boxFilterNPP.cpp是来自使用这些 ImageCPUImageNPP 对象的 CUDA SDK 的示例。

当使用像 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 是使用内置高斯平滑滤波器的 nppiFilter 的特例(可能类似于 [1 1 1; 1 1 1; 1 1 1])。

最佳答案

给像素/矩阵赋值:

hostKernel.pixels(0,0)[0].x = -1;

关于c++ - 在 Nvidia NPP ImageCPU 对象中设置像素值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12633614/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com