Fill in Surrouding data
24 views (last 30 days)
Show older comments
Pete sherer
on 1 Nov 2024 at 15:45
Commented: Pete sherer
on 1 Nov 2024 at 17:19
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 Comments
Accepted Answer
Dave B
on 1 Nov 2024 at 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)
More Answers (0)
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!