Drawing lines and perpendicular lines on a photo in MATLAB
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Misha Patel
el 11 de Jul. de 2017
Comentada: hadis ensafi
el 14 de Jun. de 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 comentarios
Respuesta aceptada
KSSV
el 11 de Jul. de 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 comentarios
KSSV
el 11 de Jul. de 2017
You can change L....instead of clicking you can use your coordinates, it is already shown in the code.
hadis ensafi
el 14 de Jun. de 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.
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!