NPP Dilate and Erode functions' examples

Hi fellas,

I’m trying to use nppiErode_8u_C1R and nppiDilate_8u_C1R functions from npp library. However, the functions always returns me a black screen. There is no error. I thought there is a mistake about sent parameters. I’m sending ROI 2 smaller than the actual size and kernel size of 3x3 and anchor point as (1,1).

Where is my error? can anybody help me? Or has anyone a working sample of nppiErode and nppiDilate functions?


Is there anybody to help me?


I don’t know if you fixed your problem but try to check the return code of the function it should be “NPP_NO_ERROR” return code 0
If you’ve got an “NPP_TEXTURE_BIND_ERROR” return code -24, it’s because the params you pass to the function are not all allocated on the device.

Hi Donos,

I’m running into the -24 error. How do I fix it?

//NPP Erode/Dilate
	NppiSize oMaskSize = {3, 3};
	// mask... is this the correct way to initialize the mask??
	Npp8u mask[9] = {0,1,0,
		// set anchor point inside the mask to (1, 1)
	NppiPoint oAnchor = {1, 1};
	NppiSize oSizeROI = {width - oMaskSize.width + 1, height - oMaskSize.height + 1};
		int c = nppiGraphcut_32f8u(d_terminals, d_left_transposed, d_right_transposed,
							d_top, d_bottom, step, transposed_step,
							size, d_label, pitch, pGraphcutState); //UNSTABLE WHY-because of edgeweights
		printf("GC error: %i \n", c);

		//// run erode
		NppStatus eStatusNPP;
		eStatusNPP = nppiErode_8u_C1R(d_label, pitch, derod_label, pitcherod, oSizeROI, mask, oMaskSize, oAnchor);
		printf("Erode error: %i \n", eStatusNPP);