I used to have the code online here, but there are some portability problems, so in order to have the code run properly you should e-mail me scottyb for more complete instructions.

Here is the code that performs the distance transform. This version takes as input < file > .pgm and outputs a < file > .pgm file or a < file > .ppm depending on whether you want grey-level, or color and the code that you compile.

I create my input .pgm files using xfig and xview that are supplied with my Linux installation. First I use xfig to create the actual shapes that I will use, then I use xview to translate these files to .pgm(ascii) files. This method is the quickest that I could come up with on my installation, short of performing the translation from xfig to .ppm directly with my code. This is not something that I wanted to do, so I have done it by hand.

In order to compile the source code. First download it from below to a file in your local directory, then use a typical gcc call like:

> gcc -O2 -o dist-trans dist-ppm.c

Once I have the everything ready to go, I just run my program with a call like:

> dist-trans -d infile.pgm outfile.pgm

Note here that only the infile.pgm need exist at this point, the executable creates the outfile.

My code reports the size of the file that it is working on, and seconds later it writes outfile.pgm to the current directory and voila I use xv to admire the output.

Enjoy. Here is the code:

Grey-Level Code

Color Code

Back To Main Page

APRIL 21, 1997