Improve Ellipse Fit around a Binary Image

3 ビュー (過去 30 日間)
N.B.
N.B. 2013 年 5 月 21 日
コメント済み: Priya Natarajan 2013 年 12 月 20 日
Hello all,
The attached image shows a binary edge detection of a bean (shown in white.) In red is an ellipse for which I have attempted to fit to this bean.
My goal is to more precisely fit this ellipse to the bean, instead of the ellipse poorly encompassing the bean. How can I do this? Are there any lines that I can edit to improve this?
The code for which I am applying the ellipse is as follows (where the variable, isolatedBean is used as the binary image input):
s = regionprops (isolatedBean, 'Orientation', 'MajorAxisLength','MinorAxisLength', 'Eccentricity', 'Centroid');
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
Thanks for your help!
  1 件のコメント
Priya Natarajan
Priya Natarajan 2013 年 12 月 20 日
Try edge-based active contour model.... it worked for me... the source code could be found at http://www.mathworks.de/matlabcentral/fileexchange/12711-level-set-for-image-segmentation/all_files

サインインしてコメントする。

回答 (2 件)

Image Analyst
Image Analyst 2013 年 5 月 21 日
編集済み: Image Analyst 2013 年 5 月 22 日
Why not just take the convex hull?
If you really want an true ellipse fit, it's not so easy. But there is a paper on it:
"Least-squares orthogonal distances fitting of circle, sphere, ellipse, hyperbola, and parabola"
by Sung Joon Ahn*, Wolfgang Rauh, Hans-JuK rgen Warnecke,
Fraunhofer Institute for Manufacturing Engineering and Automation (IPA), Nobelstr. 12, 70569 Stuttgart, Germany Fraunhofer Society, Leonrodstr. 54, 80636 Munich, Germany Received 16 June 2000; accepted 12 September 2000
Pattern Recognition 34 (2001) 2283}2303
  1 件のコメント
N.B.
N.B. 2013 年 5 月 21 日
My end goal is to graph the different radii of each bean. Can I extract radius data from the bwconvhull function?

サインインしてコメントする。


Matt Kindig
Matt Kindig 2013 年 5 月 21 日
編集済み: Matt Kindig 2013 年 5 月 21 日
To build on Image Analyst's point, you can do something like this.
outline = bwmorph( isolatedBean, 'skel'); %convert to thin borderline
[r,c]=find(outline); %find locations where outline=1 (i.e. outline of bean)
I would then use one of the ellipse fitting functions on the File Exchange, such as http://www.mathworks.com/matlabcentral/fileexchange/15125-fitellipse-m to actually fit the ellipse.
  1 件のコメント
Image Analyst
Image Analyst 2013 年 5 月 22 日
Seems like an excellent plan.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeIntroduction to Installation and Licensing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by