在MATLAB中检测图像内的圆形

vvy*_*vvy 3 matlab image-processing shape

什么是在图像中检测这些圆形形状的最快方法?

要检测的红圈

半径始终在(80-100mm)之间.背景总是白色的.圆圈将永远在中心.

我尝试过Hough变换,但我无法真正开始工作.我对此很陌生,而且我感觉像Hough Transform对此有些过分.请建议我采取正确的方法来做到这一点. 在此输入图像描述


UPDATE

这是我应用霍夫变换后得到的.

我使用过这里提到的算法.

以下是较大算法的相关代码

% applying Hough Below
[accum, circen, cirrad] = ...
    CircularHough_Grd(gR, [89 93],...
    17.4, 13, 1);   % this executes in 0.72 sec

% Lets see what we got
imshow(gR);
hold on;
plot(circen(:,1), circen(:,2), 'r+');
for ii = 1 : size(circen, 1)
    rectangle('Position',[circen(ii,1) - cirrad(ii), circen(ii,2) - cirrad(ii), 2*cirrad(ii), 2*cirrad(ii)],...
        'Curvature', [1,1], 'edgecolor', 'b', 'linewidth', 1.5);
end
hold off;
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

有意义的圆圈是中间的圆圈.

Sha*_*hai 5

这就是我的建议:
1.转换为灰色图像,增强"与白色的区别"

gimg = min( img, [], 3 );
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述
2.去除白色区域的阈值

BW = im2bw( gimg, .4 ); 
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述
3.获取图像区域的区域和质心特性

st = regionprops( ~BW, 'Area', 'Centroid', 'PixelIdxList' );
Run Code Online (Sandbox Code Playgroud)

4.只选择足够大的区域

sel = [st.Area] > numel(BW)*0.025; % at least 2.5% of image size
st = st(sel);
Run Code Online (Sandbox Code Playgroud)

5.计算到图像中心的区域距离

cntr = .5 * [size(BW,2) size(BW,1)]; % X-Y coordinates and NOT Row/Col
d = sqrt( sum( bsxfun(@minus,vertcat( st.Centroid ), cntr ).^2, 2 ) );
Run Code Online (Sandbox Code Playgroud)

6.选择距离中心最近的区域

[mn idx] = min(d);
Run Code Online (Sandbox Code Playgroud)

7.创建一个面具

res = false(size(BW)); 
res( st(idx).PixelIdxList ) = true;
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

您还可以考虑使用其他区域属性(例如'Eccentricity')来更好地拒绝非圆形区域.