An algorithm for computing the Euclidean distance from the boundary of a given digitized shape is presented. The distance is calculated with sub-pixel accuracy. The algorithm is based on an equal distance contour evolution process. The moving contour is embedded as a level set in a time varying function of higher dimension. This representation of the evolving contour makes possible the use of an accurate and stable numerical scheme, due to Osher and Sethian.
Alfred M. Bruckstein,
"Subpixel distance maps and weighted distance transforms", Proc. SPIE 2031, Geometric Methods in Computer Vision II, (23 June 1993); doi: 10.1117/12.146631; https://doi.org/10.1117/12.146631