I would like to plot a line along the major axis of an object. For example, given:
A = [ 0 0 0 0 0; 0 0 0 0 0; 0 0 1 0 0; 0 1 0 0 0; 0 0 0 0 0;];imshow(A); hold on;props = regionprops(A,'Orientation','Centroid');c = props.Centroid;
Creates an image with an object that has a major axis at 45 degrees to the X axis. Regioprops agrees:
>> props.Orientationans = 45
If I understand my trigonometry:
x = c(1) + 10 * cosd(props.Orientation);y = c(2) + 10 * sind(props.Orientation);line([c(1) x],[c(2) y])
should produce a line along the Major Axis of the object. Instead it produces a line perpendicular to the major axis. Why is the line not along the Major Axis of the object?
Best Answer