This repository demonstrates how to use the NVIDIA Performance Primitives (NPP) library to compute Euclidean distance transforms and Voronoi diagrams on grayscale images using the GPU.
This example loads raw .raw grayscale images, performs the following operations using NPP:
- Truncated Euclidean Distance Transform (EDT)
- True (floating-point) Distance Transform
- Voronoi Diagram Generation
The results are saved as output raw files, and CUDA streams are used for efficient execution.
- GPU-accelerated distance transform using
nppiDistanceTransformPBA_*functions - Support for multiple output types:
16u,32f,16s - Batch processing and stream-based execution
- Demonstrates use of
NppStreamContext
DistanceTransformTrue_Dolphin1_319x319_16u.raw

- GPU Image Processing
- Distance Transform
- Voronoi Diagrams
- CUDA Streams
- Raw Image Format Handling
| Category | Support |
|---|---|
| GPU Architectures | SM 7.5, SM 8.0 and Above |
| OS | Linux, Windows |
| CPU Architecture | x86_64 |
| CUDA Toolkit | Requires CUDA 11.2+ |
$ mkdir build
$ cd build
$ cmake ..
$ make$ mkdir build
$ cd build
$ cmake -DCMAKE_GENERATOR_PLATFORM=x64 ..
# Open distanceTransform.sln in Visual Studio and build./distanceTransformExpected Output:
NPP Library Version 12.4.0
CUDA Driver Version: 12.9
CUDA Runtime Version: 12.9
Input file load succeeded.
Input file load succeeded.
Done!
- NPP Library
- CUDA Toolkit ≥ 11.x
- CMake
This sample is released under the NVIDIA Software License Agreement. Refer to the LICENSE file for more details.
