How to find angle for a curve in an image??
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I want to find angle alpha that is showed in image name angle.png. This figure show the angle between the extruded part and base. I want to calculate angle for all extruded part with base boundary in an image which attached with this question (Original_image.jpg).
0 commentaires
Réponses (1)
Bjorn Gustavsson
le 17 Oct 2022
Since it is a bit unclear exactly how you're going about to select which points belong where you'll get a very general answer. Create a function angle_arrays.m:
function angle = angle_arrays(a,b)
% ANGLE_ARRAYS - angle between arrays
%
% Calling:
% angle = angle_arrays(a,b)
%
% copied from one major comp-sys-matlab-newsletter contributor.
angle = atan2(norm(cross(a,b)),dot(a,b));
Then you should be able to use ginput to manually select points at the base of the branching-point and at each arm, starting at the base:
[x3,y3] = ginput(3);
% then calculate the angle:
angle = angle_arrays([diff(x3(1:2)),diff(y3(1:2)),0],[diff(x3([1 3])),diff(y3([1 3])),0]);
Then you can put that snippet into a loop and save away the coordinates and angles as you see fit.
HTH
2 commentaires
Bjorn Gustavsson
le 17 Oct 2022
For that case you might be able to make linear fits to the coordinates of the identified red points "before" and "after" your green points. For that I'd use polyfit and then calculate the tangent-vectors for those 2 line-fits and then calculate the angle between those two using the above technique.
Voir également
Catégories
En savoir plus sur Geometric Transformation and Image Registration dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!