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?