|
|
| dist_on_image_saptha.m |
i = imread('onion.png');
figure;
imshow(i);
pt = ginput(4);% the function ginput is used to get the input from the mouse click
x1 = pt(1,1);
y1 = pt(1,2);
x2 = pt(2,1);
y2 = pt(2,2);
x = [x1 x2];
y = [y1 y2];
line(x,y);
x3 = pt(3,1);
y3 = pt(3,2);
x4 = pt(4,1);
y4 = pt(4,2);
x = [x2 x3];
y = [y2 y3];
line(x,y);
x = [x3 x4];
y = [y3 y4];
line(x,y);
x = [x4 x1];
y = [y4 y1];
line(x,y);
d1 = sqrt((x2-x1)^2 + (y2-y1)^2)
d2 = sqrt((x3-x2)^2 + (y3-y2)^2)
d3 = sqrt((x4-x3)^2 + (y4-y3)^2)
d4 = sqrt((x1-x4)^2 + (y1-y4)^2)
|
|
Contact us at files@mathworks.com