% Exact Euclidean Distance Transform % Uses MATLAB image processing toolbox function bwdist() with default % transform type % M J de Smith, 19/5/03 % Ref: Heinz Breu, Joseph Gil, David Kirkpatrick, and Michael Werman, % "Linear Time Euclidean Distance Transform Algorithms," % IEEE Transactions on Pattern Analysis and Machine Intelligence, % vol. 17, no. 5 May 1995, pp. 529-533. home;tic; bw = zeros(101,101); bw(50,50) = 1; D = bwdist(bw); % shaded contour plot whitebg([0 .4 .6]); rect = [100, 100, 650, 650]; figure(1); set(1,'Position',rect); str = datestr(now,0); contourf (D,8); colormap jet; alpha (.3); title([' Generated on: ',str]); xlabel('x-position'); ylabel ('y-position') toc