i am using this code: http://blogs.mathworks.com/steve/2010/07/30/visualizing-regionprops-ellipse-measurements/ to make an ellipse around an object. How can i find the angle that is created from the center of the ellipse to a vertical line that is in the middle of the image?
1 Answers
0
votes
The angle between the major axis of the ellipse and the x-axis is given by the Orientation
property of regionprops
.
The angle is given in degrees and will lie in the range between -90° and +90°.
I assume you are using exactly the mentioned code. There the Orientation
value is already calculated and used for drawing the ellipse.
You get thus get the value with
s(k).Orientation
If you want to get the angle from the major axis to a vertical line, you can simply add 90° to that angle. The result will then be in the range between 0° and 180°.
point
("the center of the ellipse") and a line ("vertical line in the middle of the image"). Reading the comment in hbaderts answer, it look like you are looking for the angle between "the major axis of the ellipse" and the "x-axis", (to then rotate the ellipse so it will be horizontal). You should edit your question to reflect that. – Hoki