5

まず、この質問の見た目に怖がらないでください ;)

私は Circular Blurred Shape Model と呼ばれる matlab で形状記述子を実装しようとしています。これの一部は、図 1d に見られるように、すべての放射状セグメントの最近傍のリストを取得することです)

私は MATLAB で単純明快な実装を行いましたが、アルゴリズムのステップ 5 と 6 で行き詰まっています。これは主に、定義に頭を悩ませることができないためです。

Xb{c,s} = {b1, ..., b{c*s}} as the sorted set of the elements in B* 
so that d(b*{c,s}, bi*) <= d(b*{c,s}, bj*), i<j

私にとって、これはカスケードソートのように聞こえます。最初に昇順の距離でソートし、次に昇順のインデックスでソートしますが、私が見つけた最近傍は論文によるものではありません。

円形 ぼやけた形状 モデル 説明 アルゴリズム

例として、セグメント b{4,1} について取得した最近傍を示します。これは、図 1d で「EX」とマークされているものです)

b{4,1} の最近傍の次のリストを取得します。b{3,2}, b{3,1}, b{3,8}, b{2,1}, b{2,8}

紙によると正しいのは次のとおりです。b{4,2}, b{4,8}, b{3,2}, b{3,1}, b{3,8}

しかし、私のポイントは実際にはユークリッド距離で測定された選択されたセグメントに最も近いセットです! 距離b{4,1} <=> b{2,1}が小さいb{4,1} <=> b{4,2}b{4,1} <=> b{4,8}...

ここに画像の説明を入力

そして、これが私の(醜い、しかし単純な)MATLABコードです:

width  = 734;
height = 734;

assert(width == height, 'Image must be square in size!');

% Radius of the correlogram
R = width;

% Number of circles in correlogram
C = 4;

% Number of sections in correlogram
S = 8;

% "width" of ring segments
d = R/C;

% angle of one segment in degrees
g = 360/S;

% set of bins for the circular description of I
B = zeros(C, S);

% centroid coordinates for bins
B_star = zeros(C,S,2);


% calculate centroids of bins
for c=1:C
    for s=1:S
        alpha = deg2rad(max(s-1, 0)*g + g/2);
        r     = d*max((c-1),0) + d/2;

        B_star(c,s,1) = r*cos(alpha);
        B_star(c,s,2) = r*sin(alpha);
    end
end

% create sorted list of bin numbers which fullfill
% d(b{c,s}*, bi*) <= d(b{c,s}, bj*) where i<j

% B_star_dists is a simple square distance matrix for getting
% the distance between two centroids c_i,s_i and c_j,s_j
B_star_dists = zeros(C*S, C*S);
for i=1:C*S
    [c_i, s_i] = ind2sub([C,S], i);
    % x,y centroid coordinates for point i
    b_star_i   = [B_star(c_i, s_i, 1), B_star(c_i, s_i, 2)];

    for j=1:C*S
        [c_j, s_j] = ind2sub([C,S], j);
        % x,y centroid coordinates for point j
        b_star_j   = [B_star(c_j, s_j, 1), B_star(c_j, s_j, 2)];

        % store the euclidean distance between these two centroids
        % in the distance matrix.
        B_star_dists(i,j) = norm(b_star_i - b_star_j);
    end
end

% calculate nearest neighbour "centroids" for each centroid
% B_NN is a cell array, B{idx} gives an array of indexes to the 
% nearest neighbour centroids. 

B_NN = cell(C*S, 1);
for i=1:C*S
    [c_i, s_i] = ind2sub([C,S], i);

    % get a (C*S)x2 matrix of all distances, the first column are the array
    % indexes and the second column are the distances e.g
    % 1   d1
    % 2   d2
    % ..  ..
    % CS  d{c,s}

    dists = [transpose(1:C*S), B_star_dists(:, i)];

    % sort ascending by the distances first (e.g second column) then
    % sort ascending by the array index (e.g first column)
    dists = sortrows(dists, [2,1]);

    % middle section has nine neighbours, set as default
    neighbour_count = 9;

    if c_i == 1
        % inner region has S+3 neighbours
        neighbour_count = S+3;
    elseif c_i == C
        % outer most ring has 6 neighbours
        neighbour_count = 6;
    end

    B_NN{i} = dists(1:neighbour_count,1);
end

% FROM HERE ON JUST VISUALIZATION CODE

figure(1);
hold on;
for c=1:C
    % plot circles
    r = c*d;
    plot(r*cos(0:pi/50:2*pi), r*sin(0:pi/50:2*pi), 'k:');
end

for s=1:S
    % plot lines

    line_len = C*d;
    alpha    = deg2rad(s*g); 

    start_pt = [0, 0];
    end_pt   = start_pt + line_len.*[cos(alpha), sin(alpha)];

    plot([start_pt(1), end_pt(1)], [start_pt(2), end_pt(2)], 'k-');
end

for c=1:C
    % plot centroids of segments
    for s=1:S
        segment_centroid = B_star(c,s, :);
        plot(segment_centroid(1), segment_centroid(2), '.k');
    end
end

% plot some nearest neighbours
% list of [C;S] 
plot_nn = [4;1];

for i = 1:size(plot_nn,2) 
   start_c = plot_nn(1,i);
   start_s = plot_nn(2,i);

   start_pt = [B_star(start_c, start_s,1), B_star(start_c, start_s,2)];
   start_idx = sub2ind([C, S], start_c, start_s);

   plot(start_pt(1), start_pt(2), 'xb');

   nn_idx_list = B_NN{start_idx};

   for j = 1:length(nn_idx_list)
      nn_idx = nn_idx_list(j); 
      [nn_c, nn_s] = ind2sub([C, S], nn_idx);
      nn_pt = [B_star(nn_c, nn_s,1), B_star(nn_c, nn_s,2)];

      plot(nn_pt(1), nn_pt(2), 'xr');
   end
end

論文全文はこちら

4

3 に答える 3

2

この論文は「地域の隣人」について語っています。これらがユークリッド距離の意味での「最近傍」であるという解釈は正しくありません。それらは単に特定の領域に隣接する領域であり、それらを見つける方法は簡単です。

領域には 2 つの座標があります: (c,s) ここで、c は、中心の 1 から端の C までの同心円の一部を示し、s は、角度から始まる 1 から、領域がどのセクターの一部であるかを示します。角度 360° で終わる 0° から S。

c および s 座標が領域の座標と最大で 1 異なるすべての領域は、隣接領域です (セグメント番号は S から 1 にラップアラウンドします)。領域の位置に応じて、次の 3 つのケースがあります。 1d)

  • 領域は中間領域(マーク MI) で、例: 領域 b(2,4)
    2 つの隣接する円と 2 つの隣接するセクターがあるため、合計で 9 つの領域:
    円 1、2 または 3 およびセクター 3、4 または 5 のすべての領域:
    b(1,3), b(2,3), b(3,3), b(1,4), b(2,4), b(3,4), b(1,5), b(2,5), b(3,5)

  • 領域は内側の領域(IN とマーク) 例: 領域 b(1,8)
    1 つの隣接する円と 2 つの隣接するセクターしかありませんが、すべての内側の領域が隣接しているため、合計で S + 3 つの領域:
    円 2 のすべての領域およびセクター 7、8、または 1:
    b(2,7), b(2,8), b(2,1)
    および内側の円のすべての領域:
    b(1,1), b(1,2), b(1,3), b(1,4), b(1,5), b(1,6), b(1,7), b(1,8)

  • 領域は外部領域(EX とマーク) で、例: 領域 b(3,1)
    1 つの隣接する円と 2 つの隣接するセクターしかないため、合計で 6 つの領域があります:
    円 2 または 3 およびセクター 8、1 または 2 内のすべての領域:
    b(2,8), b(2,1), b(2,2), b(3,8), b(3,1), b(3,2)

于 2015-10-11T03:48:05.170 に答える