Fill in Surrouding data
24 次查看(过去 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,15:55
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!