Drawing lines and perpendicular lines on a photo in MATLAB
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Misha Patel
am 11 Jul. 2017
Kommentiert: hadis ensafi
am 14 Jun. 2022
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 Kommentare
Akzeptierte Antwort
KSSV
am 11 Jul. 2017
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 Kommentare
KSSV
am 11 Jul. 2017
You can change L....instead of clicking you can use your coordinates, it is already shown in the code.
hadis ensafi
am 14 Jun. 2022
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.
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!