clear all, clc;

% img = imread('q.jpg');
% img = im2bw(img, graythresh(img));

img = zeros(201, 201);
img(101, 101) = 1;
figure,imshow(img);
img = ~img;

imgDist = -bwdist(~img,'cityblock');
figure, imshow(imgDist, [])
% figure, imcontour(imgDist)

dist0 = imgDist + abs(min(min(imgDist)));
dist = uint8 (dist0 .* 255 / max(max(dist0)));
figure, image(dist, 'CDataMapping','scaled'); hold all; imcontour(imgDist)
% axis off

