Drawing lines and perpendicular lines on a photo in MATLAB
2 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
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
2017-7-11
You can change L....instead of clicking you can use your coordinates, it is already shown in the code.
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 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!