finding adjacent value in a matrix

1 visualización (últimos 30 días)
Mohammad Golam Kibria
Mohammad Golam Kibria el 14 de Jun. de 2011
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

Respuesta aceptada

Walter Roberson
Walter Roberson el 14 de Jun. de 2011
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".

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by