This project demonstrates Image Segmentation using the Watershed Algorithm using the Nvidia Performance Primitives (NPP+) library. The watershed algorithm divides an image into regions based on intensity gradients, making it useful for tasks such as object detection and image processing. This implementation follows the technique described in "Efficient 2D and 3D Watershed on Graphics Processing Unit: Block-Asynchronous Approaches Based on Cellular Automata" by Pablo Quesada-Barriuso and others.
- Watershed-based Image Segmentation: This technique segments an image into distinct regions based on variations in pixel intensities. It is commonly used in image processing for object detection and boundary extraction.
This example is optimized for the following Nvidia GPU architectures:
- Linux
- Windows
- x86_64
To start using NPP+ for image segmentation, download the latest version of the library and install it on a machine equipped with an Nvidia GPU.
This example utilizes the following key functions from the NPP+ library for efficient GPU-accelerated image processing.
This project includes the following main component:
- Watershed Segmentation: Performs image segmentation based on intensity gradients using the watershed algorithm.
Before building and running the example, make sure that your system meets the following requirements:
- A Linux or Windows system with an Nvidia GPU.
- The latest NVIDIA drivers.
- CUDA 12.0 Toolkit and above installed.
$ mkdir build
$ cd build
$ cmake .. -DNPP_PLUS_PATH=/usr/lib/x86_64-linux-gnu
$ make
$ mkdir build
$ cd build
$ cmake -DCMAKE_GENERATOR_PLATFORM=x64 ..
$ Open watershedSegmentation.sln project in Visual Studio 15 2017 and build
./watershedSegmentation -h
Usage: ./watershedSegmentation [-b number-of-batch]
Parameters:
number-of-batch : Use number of batch to process [default 3]
Sample Output:
$ ./watershedSegmentation -b 3
./watershedSegmentation
NPP Library Version 0.9.0 CUDA Driver Version: 12.7 CUDA Runtime Version: 12.6
Input file load succeeded. CT_Skull_Segments_8Way_512x512_8u succeeded. CT_Skull_CompressedSegmentLabels_8Way_512x512_32u succeeded. CT_Skull_SegmentBoundaries_8Way_512x512_8u succeeded. CT_Skull_SegmentsWithContrastingBoundaries_8Way_512x512_8u succeeded. Input file load succeeded. Rocks_Segments_8Way_512x512_8u succeeded. Rocks_CompressedSegmentLabels_8Way_512x512_32u succeeded. Rocks_SegmentBoundaries_8Way_512x512_8u succeeded. Rocks_SegmentsWithContrastingBoundaries_8Way_512x512_8u succeeded. Input file load succeeded. Corn_Segments_8Way_614x461_8u succeeded. Corn_CompressedSegmentLabels_8Way_614x461_32u succeeded. Corn_SegmentBoundaries_8Way_614x461_8u succeeded. Corn_SegmentsWithContrastingBoundaries_8Way_614x461_8u succeeded.