Ask Your Question
3

What is the correct method for utilizing the gaussian filter function in the CUDA Npp library?

asked 2021-09-28 11:00:00 +0000

djk gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2021-07-22 08:00:00 +0000

david gravatar image

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).

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2021-09-28 11:00:00 +0000

Seen: 11 times

Last updated: Jul 22 '21