Find borders of a truth map
Show older comments
Hi,
I have an array
truth_map =
[0 0 0 0 0 0 0 0 1 1 ;
0 0 0 0 0 0 0 0 1 1 ;
0 0 0 0 0 0 0 1 1 1 ;
0 0 0 0 0 0 1 1 1 0 ;
0 0 0 0 0 1 1 1 1 0 ;
0 1 1 1 1 0 0 0 0 0 ;
1 1 1 1 1 0 0 0 0 0 ;
1 1 1 1 1 0 0 0 0 0 ;
1 1 1 1 0 0 0 0 0 0 ;
1 1 1 0 0 0 0 0 0 0 ; ]

Which I want to make look like this:
truth_map =
[0 0 0 0 0 0 0 0 1 0 ;
0 0 0 0 0 0 0 0 1 0 ;
0 0 0 0 0 0 0 1 0 1 ;
0 0 0 0 0 0 1 0 1 0 ;
0 0 0 0 0 1 1 1 1 0 ;
0 1 1 1 1 0 0 0 0 0 ;
1 0 0 0 1 0 0 0 0 0 ;
0 0 0 0 1 0 0 0 0 0 ;
0 0 0 1 0 0 0 0 0 0 ;
0 0 1 0 0 0 0 0 0 0 ; ]

This is trivial to do by hand for small arrays but my array is 1000x1000 and the area's are randomly shaped.
What would be a good way to just get an array of the borders?
Thanks, Daniel
Accepted Answer
More Answers (1)
Categories
Find more on Resizing and Reshaping Matrices 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!