
この画像があり、(X、Y)の各円の中心を取得したいとします。
MatLabでそうするためのアルゴリズムはありますか?
これは、 regionpropsを1回呼び出すだけで可能です。
img = imread('KxJEJ.jpg');                      % read the image
imgbw = ~im2bw(img,graythresh(img));            % convert to grayscale
stats  = regionprops(bwlabel(imgbw), 'centroid','area'); % call regionprops to find centroid and area of all connected objects
area = [stats.Area];                            % extract area
centre = cat(1,stats.Centroid);                 % extract centroids
centre = centre(area>10,:);                     % filter out dust specks in the image
centreこれで配列が含まれます。Nx2最初の列はx位置、2番目の列は中心のy位置です。
centre =
   289.82       451.73
   661.41       461.21
   1000.8       478.01
   1346.7       482.98
これは、人工円をフィルターとして相互相関を使用した結果です。結果は左上隅から[行、列]です。
>> disp(centers)
         483        1347
         460         662
         478        1001
         451         290
詳細なコメントはありませんので、必要に応じてお願いします。
im = rgb2gray(im2double(imread('D:/temp/circles.jpg')));
r = 117; % define radius of circles
thres_factor = 0.9; % see usage
%%
[x, y] = meshgrid(-r : r);
f = sqrt(x .^ 2 + y .^ 2) >= r;
%%
im = im - mean(im(:));
im = im / std(im(:));
f = f - mean(f(:));
f = f / std(f(:)) / numel(f);
imf_orig = imfilter(im, f, 'replicate');
%% search local maximas
imf = imf_orig;
[n_idx, m_idx] = meshgrid(1 : size(imf, 2), 1 : size(imf, 1));
threshold = thres_factor * max(imf(:));
centers = []; % this is the result
while true
    if max(imf(:)) < threshold
        break;
    end
    [m, n] = find(imf == max(imf(:)), 1, 'first');
    centers = cat(1, centers, [m, n]);
    % now set this area to NaN to skip it in the next iteration
    idx_nan = sqrt((n_idx - n) .^ 2 + (m_idx - m) .^ 2) <= r;
    imf(idx_nan) = nan;
end

何年も前に大学でそれをしたことを覚えています!
私たちがしたことは、しきい値を適用し、すべてを白黒にすることでした。次に、白い領域(非円)をブロブアウトして、円に広げました。
彼らが消え始めたとき、私たちはコーディネートを持っていました。
また、円周で2つのポイントを選択し、それらの間の線の正確な中央を見つけて、そのポイントを通る垂線を引くこともできます。新しい線の真ん中が円の中心である場合。