Drawing lines and perpendicular lines on a photo in MATLAB

3 ビュー (過去 30 日間)
Misha Patel
Misha Patel 2017 年 7 月 11 日
コメント済み: hadis ensafi 2022 年 6 月 14 日
I have a photo on MATLAB and I am using image processing. I have used circle detection to identify markers in a photo. I need to draw a line (e.g. line 1) to connect certain markers. I would then like to create a perpendicular line (e.g. line 2) at the mid section of line 1. Is it possible to do this on MATLAB?
I know there is the function 'imdistline' which can tell you the distance. I'm looking for something similar to this which can create a perpendicular.
Thank you

採用された回答

KSSV
KSSV 2017 年 7 月 11 日
YOu can draw perpendicular line for a given line as below:
%%Marker locations
x = rand(1,2);
y = rand(1,2);
line(x,y) % draw line
%%Dra wpependicular line
% Slope of current line
m = (diff(y)/diff(x));
% Slope of new line
minv = -1/m;
line([mean(x) mean(x)+0.5],[mean(y) mean(y)+0.5*minv],'Color','red')
axis equal
  7 件のコメント
KSSV
KSSV 2017 年 7 月 11 日
You can change L....instead of clicking you can use your coordinates, it is already shown in the code.
hadis ensafi
hadis ensafi 2022 年 6 月 14 日
Hello.. thanks for your code.. I have this problem in 3D space! how can I calculate a perpendicular of a line in 3D space and in Specified plane? thanks a lot.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeComputer Vision with Simulink についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by