从图像中检测和提取圆圈

时间:2017-04-10 07:39:54

标签: matlab image-processing

我有多个文件,其中有许多子圆圈图像。 我的任务是自动检测并提取带圆圈的图像并另存为单独的文件。 任何人都可以使用Matlabs或任何其他软件提供相同的示例或代码。

1 个答案:

答案 0 :(得分:0)

MATLAB中的图像处理工具箱提供了imfindcircles函数,它可以完成你想要的工作。

通用代码示例:

[img] = imread('my_img.tiff');
radius_range = [10, 40] % range of radii from 10 to 40 pixels
[centres, radii] = imfindcircles(img, radius);

...或指定更多参数(参见doc

[centres, radii, metric] = imfindcircles(img, ....
     [10, 40], ...                  % range of radii from 10 to 40 pixels
     'ObjectPolarity','bright', ... % are objects bright or dark?
     'Method','TwoStage', ...       % algorithm: TwoStage or PhaseCode
     'Sensitivity', 0.96 ...        % the higher the more circular objects it'll find
);

要显示您可以执行的结果:

imshow(img); hold on;
plot(centres(:,1), centres(:,2), 'r*');         % plot circle centers
viscircles(centres, radii, 'EdgeColor', 'b');   % plot circles
相关问题