フィルターのクリア

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 Center および File ExchangeGeometric 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