Below is a C++ implementation of the fast distance transform algorithm described in the paper:
Distance Transforms of Sampled Functions
Pedro F. Felzenszwalb and Daniel P. Huttenlocher
Cornell Computing and Information Science TR2004-1963
ps.gz
pdf
The source code is available as a tgz file dt.tgz, or zip dt.zip (updated on 12/28/06).