Drawing lines and perpendicular lines on a photo in MATLAB
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposta accettata
KSSV
il 11 Lug 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 Commenti
KSSV
il 11 Lug 2017
You can change L....instead of clicking you can use your coordinates, it is already shown in the code.
hadis ensafi
il 14 Giu 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.
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!