필터 지우기
필터 지우기

How to find angle for a curve in an image??

조회 수: 2 (최근 30일)
Surendra Ratnu
Surendra Ratnu 2022년 10월 17일
댓글: Bjorn Gustavsson 2022년 10월 17일
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).

답변 (1개)

Bjorn Gustavsson
Bjorn Gustavsson 2022년 10월 17일
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
Surendra Ratnu
Surendra Ratnu 2022년 10월 17일
Thanks for your answer. I applied this function but i could not get desire result. and i have 100 images so it's hard to manually select points on the boundary. Can you give some suggestion regarding this. I attched a image and mat file of boundary in which i showed enlarge view of some extruded part. Green points on the red boundary are the exact point where i want to measure the angle.
Bjorn Gustavsson
Bjorn Gustavsson 2022년 10월 17일
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Geometric Transformation and Image Registration에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by