- #1
farful
- 57
- 1
I'm working in matlab, and looking for help on how to do the following. (answers in any language or pseudocode will be fine)
I have an nxn matrix, with each cell containing a 1 or a 0. The border cells are all 1's.
Is there an efficient algorithm to determine if there are any "islands" of 1's? That is, any 1's not connected to the border.
For example, if my matrix is:
1 1 1 1 1 1
1 0 0 0 1 1
1 0 1 0 0 1
1 0 1 1 0 1
1 0 0 0 0 1
1 1 1 1 1 1
I'd like to be able to identify the island of the three 1's (and eliminate them).
Thanks!
I have an nxn matrix, with each cell containing a 1 or a 0. The border cells are all 1's.
Is there an efficient algorithm to determine if there are any "islands" of 1's? That is, any 1's not connected to the border.
For example, if my matrix is:
1 1 1 1 1 1
1 0 0 0 1 1
1 0 1 0 0 1
1 0 1 1 0 1
1 0 0 0 0 1
1 1 1 1 1 1
I'd like to be able to identify the island of the three 1's (and eliminate them).
Thanks!