Implementation of "Distance Transforms of Sampled Functions" for matrices of arbitrary dimensions.
All the implementations I've seen so far have a different function for 2d matrices, another funciton for 3d matrices and so on.
I've implemented the generalized distance transform in a way that it works for any matrix regardless its dimensionality.