Rotate an object based on regionprops Orientation - explanation
4 次查看(过去 30 天)
显示 更早的评论
Hi,
Based on this question (https://www.mathworks.com/matlabcentral/answers/2034614-rotate-an-object-based-on-regionprops-orientation-minferet-and-maxferet-angles), can someone please explain me or give me a reference to understand the orientation based calculation:
hlen = st.MajorAxisLength/2;
xCentre = st.Centroid(1);
yCentre = st.Centroid(2);
cosOrient = cosd(st.Orientation);
sinOrient = sind(st.Orientation);
xcoords = xCentre + hlen * [cosOrient -cosOrient];
ycoords = yCentre + hlen * [-sinOrient sinOrient];
Furthermore, why hlen (MajorAxisLength/2) is needed to draw the line ? Is there a way to do it without MajorAxisLength?
Thanks
0 个评论
回答(1 个)
Image Analyst
2023-11-6
The "angle" of an irregularly shaped object is not a clear cut definition. As you can imagine, the angle you get from the max Feret distance could be different than you'd get from regionprops, which fits the boundary to an ellipse and returns the angle of the ellipse in degrees.
The major axis length is the length from one end to the other, hence it encompasses the centroid. If you want to plot the fitted ellipse that was found, you need to draw it from the origin/centroid. As you know from the simple example of drawing a circle, you use the radius (half the max diameter), not the full diameter.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Segmentation and Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!