Setting pixel values in Nvidia NPP ImageCPU objects?
- by solvingPuzzles
In the Nvidia Performance Primitives (NPP) image processing examples in the CUDA SDK distribution, images are typically stored on the CPU as ImageCPU objects, and images are stored on the GPU as ImageNPP objects.
boxFilterNPP.cpp is an example from the CUDA SDK that uses these ImageCPU and ImageNPP objects.
When using a filter (convolution) function like nppiFilter, it makes sense to define a filter as an ImageCPU object. However, I see no clear way setting the values of an ImageCPU object.
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
How can I manually put values into an ImageCPU object?
Notes:
I didn't actually use nppiFilter in the code snippet; I'm just mentioning nppiFilter as a motivating example for writing values into an ImageCPU object.
The boxFilterNPP.cpp example doesn't involve writing directly to an ImageCPU object, because nppiFilterBox is a special case of nppiFilter that uses a built-in gaussian smoothing filter (probably something like [1 1 1; 1 1 1; 1 1 1]).