Setting pixel values in Nvidia NPP ImageCPU objects?
        Posted  
        
            by 
                solvingPuzzles
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by solvingPuzzles
        
        
        
        Published on 2012-09-28T04:32:36Z
        Indexed on 
            2012/10/20
            5:03 UTC
        
        
        Read the original article
        Hit count: 218
        
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 nppiFilterin the code snippet; I'm just mentioningnppiFilteras a motivating example for writing values into anImageCPUobject.
- The boxFilterNPP.cpp example doesn't involve writing directly to an ImageCPUobject, becausenppiFilterBoxis a special case ofnppiFilterthat uses a built-in gaussian smoothing filter (probably something like [1 1 1; 1 1 1; 1 1 1]).
© Stack Overflow or respective owner