I wouldn't use ginput() or pdist(). I'd use the function improfile() in the Image Processing Toolbox. It's a lot easier to use than imdistline(). Here's a snippet:
grayImage = imread('moon.tif');
imshow(grayImage);
title('Left click, then right click');
[x, y, grayLevels] = improfile();
line([x(1), x(end)], [y(1), y(end)]);
dist = sqrt((x(end)-x(1))^2 + (y(end)-y(1))^2)
Best Answer