Created
February 28, 2014 00:43
-
-
Save alexstorer/9262886 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function [ d ] = measurepxdist( imloc ) | |
%MEASUREPXDIST Measure distance between pixels in an image | |
% Returns distance in pixels. | |
% Shows line between left-click and right-click. | |
imshow(imloc) | |
im = gcf(); | |
hold on | |
title('Click the two points, left click and right click, q to quit','FontSize',16) | |
q = 113; | |
button = 0; | |
p1 = [0 0]; | |
p2 = [0 0]; | |
while (button ~= q) | |
[x, y, button] = ginput(1); | |
if button==1 | |
p1 = [x y]; | |
elseif button==3 | |
p2 = [x y]; | |
end | |
d = sqrt(sum((p1-p2).^2)); | |
try | |
delete(g1) | |
end | |
g1 = plot([p1(1) p2(1)],[p1(2) p2(2)],'rx-'); | |
xlabel(['Distance is ' num2str(d)]) | |
end | |
close(im) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment