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
댓글 수: 0
채택된 답변
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
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!