Fill in Surrouding data
1 回表示 (過去 30 日間)
古いコメントを表示
Hi,
I have a matrix with bit mask [0, 1]. Is there are quick way to fill surrounding 1 data with value 1.
For example, with
ttmp =
[0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 1 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 1 0 0 0
0 0 0 1 0 1 0 0 0 0
];
I want to turn in into
ttmp2=
[0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 1 0 0 0 0
0 0 0 0 1 1 1 0 0 0
0 0 0 0 0 1 0 0 0 0
0 0 0 0 0 0 1 0 0 0
0 0 0 1 0 1 1 1 0 0
0 0 1 1 1 1 1 0 0 0]
Thanks much
0 件のコメント
採用された回答
Dave B
2024 年 11 月 1 日
ttmp = [0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 1 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 1 0 0 0
0 0 0 1 0 1 0 0 0 0]
tconv = conv2(ttmp,[0 1 0;1 1 1;0 1 0],'same')
ttmp2 = double(tconv>0)
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!