필터 지우기
필터 지우기

Problem with a slope

조회 수: 4 (최근 30일)
as hz
as hz 2013년 10월 27일
댓글: Image Analyst 2013년 10월 27일
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);

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 10월 27일
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
Image Analyst
Image Analyst 2013년 10월 27일
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').

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by