Problem with a slope
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
as hz
am 27 Okt. 2013
Kommentiert: Image Analyst
am 27 Okt. 2013
Hi,
Why does the slope result I get from these two points is opposite?
Code:
clc;
clear;
figure, imshow('pout.tif');
b1 = impoint(gca,[]);
b2 = impoint(gca,[]);
pos1 = getPosition(b1);
x1=pos1(1,1);
y1=pos1(1,2);
pos2 = getPosition(b2);
x2=pos2(1,1);
y2=pos2(1,2);
slope = (y2-y1)/(x2-x1);
plot([x1,x2 ],[y1,y2],'Color','r','LineWidth',2);
0 Kommentare
Akzeptierte Antwort
Azzi Abdelmalek
am 27 Okt. 2013
Maybe you should write
slope = ((y1-y2)/(x2-x1))
You can notice that the origin is not in the left bottom, but in the left top corner. check it with
x1
x2
y1
y2
1 Kommentar
Image Analyst
am 27 Okt. 2013
The direction can be changed with set(gca,'YDir','reverse'). Or maybe it already is since that's what imshow does. In that case, try set(gca,'YDir','normal').
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Title finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!