【问题标题】:Find the circle on the experimental image (Matlab)在实验图像上找到圆圈(Matlab)
【发布时间】:2017-11-06 15:12:46
【问题描述】:

我有一系列实验图像。为了处理它,首先,我需要确定感兴趣的区域。该区域位于两个同心圆之间。这些圆圈在每张图像上可能略有不同(例如,中心可以移动一小段距离)。

为了找到这些圆圈,我将图像转换为二进制图像。现在看起来像这样:

我对最大的圆圈和最大后的圆圈感兴趣(参见图片上的注释)。有谁知道可以找到它的快速算法?用尽搜索似乎是一个糟糕的选择。我知道,在每张图像中,这些圆圈的位置和半径只能改变一点点。这是 .mat 文件的链接,我附上了图片link

谢谢,

【问题讨论】:

  • 谢谢,这很有用。试图实现它
  • 它确实有效。唯一的事情是我想找到“内半径”,而不是外半径(我的圆圈宽度有限)。但我想我可以自己解决这个问题。
  • @MikhailGenkin 请考虑自己创建一个答案。它可能对其他有类似问题的人有用。

标签: matlab image-processing


【解决方案1】:

即使不使用内置函数 imfindcircles,您也可以完成此任务。我遵循以下方法。使用 find 获取所有非零像素。现在你有了所有的点,我想将它们分类到不同的圈子中,为此我将使用 histogram。我可以在这里修复垃圾箱的数量(即圈数)。一旦我把所有的点分开,我就会沿着一个圆圈分散点......有了这些点,我将沿着这些点拟合一个圆圈。您可以查看以下代码:

load Sample.mat ;
I = Immm ;
[y,x] = find(I) ;
%% Get Bounding box
x0 = min(x) ; x1 = max(x) ;
y0 = min(y) ; y1 = max(y) ;
% length and breadth 
L = abs(x1-x0) ;
B = abs(y1-y0) ;
% center bounding box
C = [x0+B/2 y0+L/2] ;
%% Get distances of the points from center of bounding box
data = repmat(C,[length(x),1])-[x,y] ;
dist = sqrt(data(:,1).^2+data(:,2).^2);
%% Classify the points into circles 
nbins = 4 ;   % number of circles you want
[N,edges,bin] = histcounts(dist,nbins) ;
% plot the classified circle points for check 
figure(1)
imshow(I)
hold on
for i = 1:nbins
    plot((x(bin==i)),y(bin==i),'.','color',rand(1,3)) ;
end

%% Circle's radii and center 
Circ = cell(nbins,1) ;
for i = 1:nbins 
    [xc1,yc1,R] = circfit(x(bin==i),y(bin==i)) ;
    Circ{i} = [xc1 yc1 R] ;
end
figure(2)
imshow(I)
hold on
th = linspace(0,2*pi) ;
for i = 1:nbins
    xc = Circ{i}(1)+Circ{i}(3)*cos(th) ;
    yc = Circ{i}(2)+Circ{i}(3)*sin(th) ;
    plot(xc,yc,'color',rand(1,3),'linewidth',3) ;
end

Circ 是圆的圆心和半径的单元格。您可以从以下链接下载函数 circfithttp://matlab.wikia.com/wiki/FAQ#How_can_I_fit_a_circle_to_a_set_of_XY_data.3F

【讨论】:

  • 这是一个很好的方法,但是圆的中心不需要正好在中心(虽然很接近)
猜你喜欢
  • 2014-10-27
  • 1970-01-01
  • 1970-01-01
  • 2010-12-24
  • 1970-01-01
  • 2017-11-23
  • 1970-01-01
  • 2013-05-05
  • 2015-06-15
相关资源
最近更新 更多