Sobel Filter using NPP

Hi,

please help me with a Sobel Filter and the NPP.

my code so far:

NppiPoint Anchor1 = {1, 1};
Npp32s KernelSobelX = { -1, 0,1 ,
-2, 0,2 ,
-1, 0,1 };
NppiSize MaskSize3 = {3, 3};

npp::ImageCPU_8u_C1 oHostSrc;
npp::loadImage(sFilename, oHostSrc);
npp::ImageNPP_8u_C1 in_img(oHostSrc);

NppiSize SizeROI3 = {in_img.width() - MaskSize3.width + 1, in_img.height() - MaskSize3.height + 1};
npp::ImageNPP_8u_C1 gx_img(SizeROI3.width, SizeROI3.height);

eStatusNPP = nppiFilter_8u_C1R( in_img.data()+in_img.pitch()+1, in_img.pitch(),
gx_img.data()+in_img.pitch()+1, gx_img.pitch(),
SizeROI3, KernelSobelX, MaskSize3,
Anchor1, 1);

npp::ImageCPU_8u_C1 oHostDst(gx_img.size());
gx_img.copyTo(oHostDst.data(), oHostDst.pitch());
saveImage(sResultFilename, oHostDst);

The result is just a noisy picture with values either 0 or 255.

Please help me, I really dont know whats wrong with that code.
Using a Boxfilter (nppiFilterBox_8u_C1R) within the same code is no problem.

thx in advance

Today I bulid exactly the same code with the related IPP (Intel Performance Primitives) functions.
Its workin without any problems.

Are there Problems using NPP with any CUDA version?
Bugs at NPP?

You are not using a cuda device memory for the kernel !

Don’t forget to put some NPP_CHECK_NPP( … ) on your npp functions calling.

Maybe something like that will work better:

	NppiPoint anchor1 = { 1, 1 };

	Npp32s kernelSobelX[] = { -1, 0, 1,

							  -2, 0, 2,

							  -1, 0, 1 };

	NppiSize kernSize3 = { 3, 3 };

	NppiSize sizeROI3 = { in.width() - kernSize3.width + 1, in.height() - kernSize3.height + 1 };

	npp::ImageNPP_32s_C1 kernel( kernSize3.width, kernSize3.height );

	kernel.copyFrom( kernelSobelX, 3 * sizeof( Npp32s ) );

	NppStatus eStatusNPP = nppiFilter_8u_C1R( in.data() + in.pitch() + 1, in.pitch(),

									  sdx.data() + in.pitch() + 1, sdx.pitch(),

									  sizeROI3, kernel.data(), kernSize3,

									  anchor1, 1 );
  • Eloi du Bois