フィルターのクリア

How to find nearby labels?

1 回表示 (過去 30 日間)
faran
faran 2019 年 6 月 25 日
コメント済み: faten Ahmed 2021 年 6 月 21 日
I have matrix I and I want to show that region with label 1 is neighbours with regions with label 2 and 4. Or region with label 2 is neighbour with region 1,4,5,and 3.
I =
1 1 1 2 3 3
1 1 2 2 3 3
4 4 4 5 5 3
4 4 4 4 5 5

採用された回答

Andrei Bobrov
Andrei Bobrov 2019 年 6 月 25 日
編集済み: Andrei Bobrov 2019 年 6 月 25 日
I =[...
1 1 1 2 3 3
1 1 2 2 3 3
4 4 4 5 5 3
4 4 4 4 5 5];
N = unique(I);
n = numel(N);
out = cell(n,2);
for ii = 1:n
out(ii,:) = {ii, unique(I(bwdist(I == ii,'chessboard')==1))};
end
or
N = unique(I);
n = numel(N);
out = cell(n,2);
o3 = ones(3);
for ii = 1:n
lo = I == ii;
out(ii,:) = {ii, unique(I(imdilate(lo,o3) + lo == 1))};
end
out_as_table = cell2table(out,'v',{'number','neighbours'})
  1 件のコメント
faten Ahmed
faten Ahmed 2021 年 6 月 21 日
Hi, Mr Andrei
I want to know the means of the functions on the above code. For example:
rgb2lab means Covert RGB to CIE 1967 L*a*b*
nume1 means ..........................
o3 means ...................
ones (3) means ...............................
cell(n,2); means .............
ii means ............
Io means ..............
I(imdilate(lo,o3) means .....................

サインインしてコメントする。

その他の回答 (0 件)

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by