The distance transform uses the following iterative algorithm :
U(m,n) : original image.
This image contains only two gray levels, 0 for the background, and
any other value for the objects.
Uk(i,j): image after k iterations.
U0(m,n)= U(m,n), and for k= 1, 2, 3, ...
Uk(m,n)= U0(m,n)+min{Uk-1(i,j);((i,j):dist(m,n;i,j)<= 1)},
dist(m,n;i,j) is the distance between (m,n) and (i,j).
dist(i,j-1;i,j) = dist(i,j+1;i,j) =dist(i-1,j;i,j) =dist(i+1,j;i,j) = 1.
dist(i-1,j-1;i,j) = dist(i+1,j-1;i,j) =dist(i-1,j+1;i,j) =dist(i+1,j+1;i,j) = 2.
The transform is completed when k equals the maximum thickness of the region. That is, when Uk+1 equals Uk.
The distance image can be used to extract edges or the medial axis
(form of skeleton).
Set of functions that can be used with vdistance:
vmediaxis Customizes the medial axis from the distance image.
\fBkthresh Generate a binary image.
ADVICE:
For this routine, the image must be a byte binary image,
with the gray-level value 0 for the background.
It is advisable to perform a threshold operation prior to using vdistance.
vdistance -i image1 -o image2
Computes the distance from the nearest boundary point.
For this routine, the image has to be a byte binary image, with the gray-level value 0 for the background. So it is strongly advisable to perform thresholding before running vdistance.