1. A method for generating a distance map from an image including a set of pixels arranged in a Euclidian n-space, the set of pixels including a subset of background pixels and a subset of foreground pixels, the distance map storing a distance value for every corresponding background pixel to a nearest foreground pixel, the method comprising the steps of: defining a set of scan lines having different directions; and scanning the set of pixel along each scan lines by moving from a current pixel to a next pixel along the scan line, the scanning for each scan line further comprising the steps of: making the next pixel the current pixel; initializing a counter to zero when the current pixel is one of the foreground pixels and the next pixel is one of the background pixels; incrementing the counter by one when the next pixel is one of the background pixels; and assigning the counter as the distance corresponding to the current pixel if the current pixel is one of the background pixels, and repeating beginning with the making step.