finding adjacent value in a matrix

1 次查看(过去 30 天)
Hi, I have a portion of a matrix as follows:
I =
0 1 0 0 1 0
0 0 0 1 0 0
0 0 0 0 0 0
0 0 1 1 0 0
0 1 0 0 1 0
1 0 0 0 0 1
I know the position of two 1s i.e (6,1) and (6,6). I need to know whether this two 1s are connected and if connected the positions of all 1s from first 1 to last 1. connected means any of eight neighbor of 1st 1 has 1,any of eight neighbor of 1st 1's neighbor has value 1 and it ends at 1 at (6,6) Here (1,2) and (1,5) is not connected but (6,1) and (6,6) are connected

采纳的回答

Walter Roberson
Walter Roberson 2011-6-14
bwlabel() and then regionprops . If the labels differ for the two positions then they are not connected; if they are connected, then the pixel list from regionprops will show the path, provided there are no "spurs".

更多回答(0 个)

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by