Sample code for using nppiSignedDistanceTransformPBA_32f_C1R_Ctx() function to calculate signed distance

I have tried to use nppiSignedDistanceTransformPBA_32f_C1R_Ctx() in my code but it is giving negative values at all pixels whether it is inside/outside or on the shape edge.

Please if any one can provide a code sample to use the same and tell what should be the input given to this function.

To get help on your current code/issue, you really need to post a reproducer.

You can also check out CUDALibrarySamples/NPP at master · NVIDIA/CUDALibrarySamples · GitHub for examples.

CUDALibrarySamples/NPP at master · NVIDIA/CUDALibrarySamples · GitHub does not use the nppiSignedDistanceTransformPBA_32f_C1R_Ctx() function.

The reproducer code is :

//Converting 4-Channel BGRA unsigned 8-bit input data to 4-Channel BGRA float 32-bit data
nppStatus = nppiConvert_8u32f_C4R((Npp8u*)_Texture_2DIn._CudaMemory._LinearMemory, _Texture_2DIn._CudaMemory._Pitch, (Npp32f*)_DataIn32._LinearMemory, _DataIn32._Pitch, _DataIn32._ROI);

//Converting 4-Channel BGRA float 32-bit data to single channel 32-bit Gray data
nppStatus = nppiRGBToGray_32f_AC4C1R((Npp32f*)_DataIn32._LinearMemory, _DataIn32._Pitch, (Npp32f*)_DataIn._LinearMemory, _DataIn._Pitch, _DataIn._ROI);
getLastCudaError(L"RGB to Gray (cuda_texture_2d_Out) failed");

//Normalizing gray color data from 0-1
nppStatus = nppiMulC_32f_C1IR(1/255.0f, (Npp32f*)_DataIn._LinearMemory, _DataIn._Pitch, _DataIn._ROI);

//Getting the output array from the registered texture
cudaArray* cuArrayOut = NULL;
cudaError = cudaGraphicsSubResourceGetMappedArray(&cuArrayOut, _Texture_2DOut._CudaResource, 0, 0);
getLastCudaError(L"cudaGraphicsSubResourceGetMappedArray (cuda_texture_2d_Out) failed");

//Calculating signed distance which gives all negative values in output texture and returns no_error
nppStatus = nppiSignedDistanceTransformPBA_32f_C1R_Ctx((Npp32f*)_DataIn._LinearMemory, _DataIn._Pitch, 0, 0, 0, 0, 0, 0, 0, 0, 0, Npp32f*)_Texture_2DOut._CudaMemory._LinearMemory, _Texture_2DOut._CudaMemory._Pitch, _Texture_2DOut._CudaMemory._ROI, _DeviceBuffer, _NPPStreamCtx);