2017-04-10 48 views
-2

我有多個文件,其中有許多子圓圈圖像。 我的任務是自動檢測並提取圈出的圖像並保存爲單獨的文件。 任何人都可以使用Matlabs或任何其他軟件提供相同的示例或代碼。檢測並提取圖像中的圓圈

+0

燦你提供了一個樣本圖片? – m7913d

回答

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