Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The correct method for utilizing the gaussian filter function in the CUDA Npp library is as follows:

  1. Include the necessary headers:
#include <npp.h>
#include <nppi_filtering_functions.h>
  1. Allocate and initialize the NPP image and set the ROI:
NppiSize sizeROI = { width, height };
NppiSize maskSize = { maskWidth, maskHeight };
int nBufferSize = 0;
Npp8u* pBuffer = 0;
Npp8u* pSrcDst = 0;
int nSrcDstStep = 0;
NppiPoint anchor = { maskWidth / 2, maskHeight / 2 };

nppiMalloc(&pSrcDst, nSrcDstStep * height);
nppiSet_8u_C1R(0, pSrcDst, nSrcDstStep, sizeROI);
  1. Calculate the size and allocate the buffer for the filter:
nppiFilterGaussBorderGetBufferSize(sizeROI, maskSize, &nBufferSize);
cudaMalloc(&pBuffer, nBufferSize);
  1. Apply the filter on the image:
nppiFilterGaussBorder_8u_C1R(pSrcDst, nSrcDstStep, sizeROI, maskSize, anchor, pBuffer);
  1. Free the memory:
cudaFree(pBuffer);
nppiFree(pSrcDst);

Note that the above code assumes that you have already defined the input and output size (width and height), mask size (maskWidth and maskHeight), and source/destination step (nSrcDstStep).