timholy/Images.jl — pull request #99 by wkearn (2014-05-29 23:14:30+00:00)
Title: Euclidean Distance Transform

I needed a Euclidean Distance Transform for something I'm working on, so I wrote up the algorithm from [Maurer et al. 2003](http://ieeexplore.ieee.org/xpl/login.jsp?tp=&arnumber=1177156&url=http%3A%2F%2Fieeexplore.ieee.org%2Fstamp%2Fstamp.jsp%3Ftp%3D%26arnumber%3D1177156) Matlab uses for its `bwdist` function (but I wrote this from scratch after puzzling out the Maurer et al. pseudocode).

This solves #65

Calling `(F,D) = bwdist(I)` where `I` is some binary image returns two results. F is the feature transform (i.e. the closest feature pixel given as a vector of its indices in I). D is the Euclidean Distance Transform calculated from F by computing the Euclidean distance from the pixel of interest to its feature pixel.

I'm fairly confident that it works on 2D images, but it should also work on multi-dimensional ones as well. The rudimentary tests that I've done on images of various dimensions seem to hold up. Let me know if you encounter any cases where it doesn't behave as expected.

Current problems: This is written using Base.Cartesian, so it won't work in 0.2. I had a bit of trouble getting the Cartesian.jl version of `@ngenerate` to work. I'll revisit that later (or someone with a bit more Cartesian-fu can take a crack at it :wink:), but until then, I've left it in a separate file rather than merging it with algorithms.jl.