Nppi Label Markers labeling regions same ID.

When I run nppiLabelMarkers_16u_C1IR, some regions are labbeled same ID.

///
Npp16u host_src[16 * 16]
{
0, 0, 0, 0, 0, 0, 0, 0,255, 0, 0, 0, 0, 0, 0, 0,
0, 255,255,255, 0, 0,255,255,255, 0, 0, 0, 0, 0, 0, 0,
0, 255,255,255, 0, 0,255,255,255, 0, 0, 0, 0, 0, 0, 0,
0, 255,255,255, 0, 0,255,255,255,255, 0, 0,255, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,255,255,255, 0, 0, 0,255,255,255,
0, 0, 0, 0, 0, 0, 0, 0,255, 0, 0, 0, 0,255,255,255,
0, 0, 0,255, 0, 0, 0, 0, 0, 0, 0, 0, 0,255,255,255,
0, 255,255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 255,255,255, 0, 0, 0, 0,255, 0, 0, 0, 0, 0, 0, 0,
0, 255,255,255,255, 0, 0,255,255,255, 0, 0, 0, 0, 0, 0,
0, 0,255,255,255, 0,255,255,255,255,255, 0, 0, 0, 0, 0,
0, 0, 0,255, 0, 0, 0,255,255,255, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,255, 0, 0, 0, 0,255,255,255,
0, 255,255,255, 0, 0, 0, 0, 0, 0, 0, 0, 0,255,255,255,
0, 255,255,255, 0, 0, 0, 0, 0, 0, 0, 0, 0,255,255,255,
0, 255,255,255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};

Npp16u * device_src;
cudaMalloc((void**)&device_src, sizeof(Npp16u) * WIDTH * HEIGHT);
cudaMemcpy(device_src, host_src, sizeof(Npp16u) * WIDTH * HEIGHT, cudaMemcpyHostToDevice);

int buffer_size;
NppiSize source_roi = { WIDTH, HEIGHT };
nppiLabelMarkersGetBufferSize_16u_C1R(source_roi, &buffer_size);

Npp8u * buffer;
cudaMalloc((void**)&buffer, buffer_size);

int max;
nppiLabelMarkers_16u_C1IR(device_src, sizeof(Npp16u) * WIDTH, source_roi, 0, nppiNormInf, &max, buffer);

Npp16u *dst = new Npp16u[WIDTH * HEIGHT];
cudaMemcpy(dst, device_src, sizeof(Npp16u) * WIDTH * HEIGHT, cudaMemcpyDeviceToHost);

for (int i = 0; i < HEIGHT; i++)
{
	for (int j = 0; j < WIDTH; j++)
	{
		printf("%3hd", dst[i * WIDTH + j]);
	}
	printf("\n");
}
printf("%d\n", max);

///

this is my source and result is :

///
0 0 0 0 0 0 0 0 5 0 0 0 0 0 0 0
0 1 1 1 0 0 5 5 5 0 0 0 0 0 0 0
0 1 1 1 0 0 5 5 5 0 0 0 0 0 0 0
0 1 1 1 0 0 5 5 5 5 0 0 8 0 0 0
0 0 0 0 0 0 0 5 5 5 0 0 0 8 8 8
0 0 0 0 0 0 0 0 5 0 0 0 0 8 8 8
0 0 0 1 0 0 0 0 0 0 0 0 0 8 8 8
0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0
0 1 1 1 0 0 0 0 5 0 0 0 0 0 0 0
0 1 1 1 1 0 0 5 5 5 0 0 0 0 0 0
0 0 1 1 1 0 5 5 5 5 5 0 0 0 0 0
0 0 0 1 0 0 0 5 5 5 0 0 0 0 0 0
0 0 0 0 0 0 0 0 5 0 0 0 0 9 9 9
0 1 1 1 0 0 0 0 0 0 0 0 0 9 9 9
0 1 1 1 0 0 0 0 0 0 0 0 0 9 9 9
0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0

10
///
How can i solve this problem?

Thanks for reporting. At the moment, it appears to be a defect in the npp library. Our development team is taking a look, but I don’t have any further information at this time.

This issue should be fixed in the current CUDA 10.1U1 release (10.1 Update 1, 10.1.168)