Skip to content

louismullie/watershed-cuda

Repository files navigation

Parallel Watershed Segmentation of Medical Images on GPUs

Contents

This package contains:

  • A CUDA implementation of an order-variant watershed algorithm (ws_gpu.py and kernels.cu), based on [1-4]. A serial version of the parallel algorithm can be found in ws_parallel.py.
  • An more efficient serial implementation of the order-variant watershed algorithm (ws_serial.py).
  • An MPI implementation of a master/slave scheduler that allows distributed computation of the watershed transform (ws_mpi.py)
  • A set of utilities to read the DICOM format for medical images (heavily inspired from [7]), preprocess the images for the watershed algorithm, and display the results of the watershed transform (ws_utils.py).
  • A sample DCM image of a thorax CT, obtained from the Cancer Imaging Archive (test.dcm) [8].

Running on one image

The programs ws_gpu.py, ws_serial.py and ws_parallel.py can be run on an individual DCM image by supplying the image file as an argument. For example,

python ws_gpu.py test.dcm
python ws_serial.py test.dcm

The result will be displayed in a matplotlib popup box.

N.B.: The serial implementation of the GPU algorithm (ws_parallel.py) is inherently inefficient and will take several minutes to run on the test image. It is provided only for reference. The ws_serial.py version uses path compression with a reference list for pixel labelling and is much more efficient.

Running on several images

The program ws_mpi.py can be run on multiple DCM images by supplying the input directory (with a trailing slash) as a parameter. For example,

# Download a sample DCM data set.
wget louismullie.com/dump/dcm.zip
mkdir data && mv dcm.zip data/
cd data && unzip dcm.zip && cd ..

# Run the distributed computation.
mpirun -n 3 python ws_mpi.py data/

The resulting images will be output as PNG files in the supplied directory. The images that will be saved to disk correspond to the superposition of the watershed lines with the original frame.

References

[1] Vitor B, Körbes A. Fast image segmentation by watershed transform on graphical hardware. In: Proceedings of the 17th International Conference on Systems, Signals and Image Processing, pp. 376-379, Rio de Janeiro, Brazil.

[2] Körbes A et al. 2009. A proposal for a parallel watershed transform algorithm for real-time segmentation. In: V Workshop de Visão Computacional, São Paulo, Brazil.

[3] Körbes A et al. 2010. Analysis of a step-by-step watershed algorithm using CUDA. International Journal of Natural Computing Research. 1:16-28.

[4] Körbes A et al. 2011. Advances on Watershed Processing on GPU Architectures. In: 10th International Symposium on Mathematical Morphology, Lake Maggiore, Italy.

[5] Reference for DICOM reader script.

[6] Cancer Imaging Archive.

About

An implementation of the watershed algorithm in CUDA.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages