visualizing regionprops ellipse measurements problem
1 view (last 30 days)
Show older comments
I have tried the ellipse measurement process like in : http://blogs.mathworks.com/steve/2010/07/30/visualizing-regionprops-ellipse-measurements/
using my own data : https://imageshack.com/i/0l2ewhj
the output of
s = regionprops(bw, 'Orientation', 'MajorAxisLength', ...
'MinorAxisLength', 'Eccentricity')
is
s =
255x1 struct array with fields:
MajorAxisLength
MinorAxisLength
Eccentricity
Orientation
whereas in my data there are only 4 objects in it.
and then I continue the process like on the reference with
s = regionprops(bw, 'Orientation', 'MajorAxisLength', ...
'MinorAxisLength', 'Eccentricity', 'Centroid');
imshow(bw)
hold on
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 = [a*cosphi; b*sinphi];
xy = R*xy;
x = xy(1,:) + xbar;
y = xy(2,:) + ybar;
plot(x,y,'r','LineWidth',2);
end
hold off
it shown like this picture : https://imageshack.com/i/07xk67j
many irregular red line and not surround any object like in this picture : https://imageshack.com/i/mvs4umpz
if there is something wrong with my object so that the results are not as expected?
I'm new in elliptical objects, pls help..
0 Comments
Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!