Fri 15 Sep 2017 07:18:41 AM UTC, original submission:
I just installed Octave 4.2.1 and tried this example code that uses Image Processing package to visualize the ellipse-based measurements produced by regionprops
(http://blogs.mathworks.com/steve/2010/07/30/visualizing-regionprops-ellipse-measurements/):
url='http://blogs.mathworks.com/images/steve/2010/rice_binary.png';
bw = imread(url);
imshow(bw)
hold on
pkg load image
s = regionprops(bw, 'Orientation', 'MajorAxisLength', ...
'MinorAxisLength', 'Eccentricity', 'Centroid');
phi = linspace(0,2*pi,50);
cosphi = cos(phi);
sinphi = sin(phi);
for k = 1:length(s)
xbar = s(k).Centroid(1);
ybar = s(k).Centroid(2);
a = s(k).MajorAxisLength/2;
b = s(k).MinorAxisLength/2;
theta = pi*s(k).Orientation/180;
R = [ cos(theta) sin(theta)
-sin(theta) cos(theta)];
xy = [acosphi; bsinphi];
xy = R*xy;
x = xy(1,:) + xbar;
y = xy(2,:) + ybar;
plot(x,y,'r','LineWidth',2);
end
hold off
The result I have obtained, shown in attached file ("wrong_result.JPG") - all ellipses are arranged horizontally.
"Orientation" does not work?
How it possible to workaround this problem?
|