% distance transform main program
clear
x=[0 0 0 0 0 0 0 0;
0  0 0 0 0 1 0 0;
0 0 0 0 1 1 0 0;
0 0 0 0 0 1 1 0;
0 0 0 0 0 1 1 0;
0 0 0 1 1 1 0 0;
0 0 0 0 0 1 0 0;
0 0 0 0 0 0 0 0] % input image
D=bwdist(x)
mask1=[Inf 1 Inf;1 0 Inf;Inf Inf Inf]; % mask 1
mask2=[4 3 4;3 0 Inf;Inf Inf Inf]; % mask 2
mask3=[Inf 11 Inf 11 Inf;...
11 7 5 7 11;...
Inf 5 0 Inf Inf;...
Inf Inf Inf Inf Inf;...
Inf Inf Inf Inf Inf] % mask 3
D=disttrans(x,mask1)