change the range of angle for regionprops

Any idea, how can we change the range of angle for the orientation which we get from regionprops?
Currently, the regionprops returns the angles in [-90,90], but i need in [-180,180]. How can it be achieved?
Thanks

1 Comment

How would you distinguish between an orientation of -180 and 180?

Sign in to comment.

Answers (1)

'Orientation' Scalar; the angle (in degrees ranging from -90 to 90 degrees) between the x-axis and the major axis of the ellipse that has the same second-moments as the region. This property is supported only for 2-D input label matrices.
But take note that the major axis of an ellipse is not oriented, so it is not possible to tell the difference between (say) "up and right-wards" and "down and left-wards" as would be required to distinguish a full 360 degree range. An ellipse rotated by 180 degrees around its center is exactly the same as the unrotated ellipse.
If you have information such as an arrowhead that gives direction, then you will need to work that out some other way.

5 Comments

Thanks for the comment. I actually need to look at the orientation of major axis of the ellipse as you say like up and right-wards or down and left wards. Currently, I have the centroid of each blob in each frame and looking at the angle between of displacement vector, i was trying to get a clue if the orientation of major axis can be determined(i.e if it is going up or down). But the atan2 which i was using , gives the result in -180 to 180 range. So i was a bit hooked up with these angles stuff. Any suggestions and comments would be highly appreciated.
Thanks
Sorry, for any given blob, as far as regionprops() is concerned, the blob just is, static, no history of what it was before. You need the previous location of the centroid to determine which direction the blob headed from the previous frame. You may also need to do additional analysis if you want to figure out which direction the blob is "facing" (e.g., did the car back up or did it turn around)
Thanks for the comment, but could you please help me in detecting the correct orientation? I am stuck at this. I have information regarding the displacement vector, and the orientation of the major axis of ellipse. But that does not help in detecting the correct orientation.i.e if it is going up or down?
PLease help Thanks
Matt J
Matt J on 14 Nov 2012
Edited: Matt J on 14 Nov 2012
Suppose you have the major axis of the of the bounding ellipse and suppose, just as an example, that it is horizontal. How do you decide whether the axis is pointing to the left or to the right? What is the criterion you would use to say which of 2 possible orientations a given axis has?
With the information you have provided, I do not understand why you do not just atan2() the displacement vector? Whether a blob is going up or down is independent of which way the blob is "facing".

Sign in to comment.

Asked:

on 13 Nov 2012

Community Treasure Hunt

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

Start Hunting!