How I find 8-connectivity of a binary image like [1 0 0 0 ;0 1 0 0;0 0 1 0;0 0 0 1] with gry level 1..in matlab... I want to make code program in matlab

1 visualización (últimos 30 días)
How I find 8-connectivity of a binary image like [1 0 0 0 ;0 1 0 0;0 0 1 0;0 0 0 1] with gry level 1..in matlab... I want to make code program in matlab
  2 comentarios
Maher Mehro
Maher Mehro el 19 de Feb. de 2020
1 1 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 1 0 0 0 0 1 this is ka matrix with p=(1,1)and q=(5,5) and v={1} if there exist path between p and q... How I make code for checking connectivity between them.. Step by step... 4-connectivity 8-connectivity and m-connectivity..

Iniciar sesión para comentar.

Respuestas (1)

Image Analyst
Image Analyst el 22 de Feb. de 2020
Check the label:
[labeledImage, numberOfBlobs] = bwlabel(binaryImage, 8); % Label with 8-connectivity
if labeledImage(1,1) == labeledImage(5,5)
% They're the same label so there is a path connecting them.
uiwait(msgbox('Those points are connected.'))
else
% They're NOT the same label so there is NO path connecting them.
uiwait(msgbox('Those points are NOT connected.'))
end
%=================================================================================================
% Now the same but with 4-connectivity.
[labeledImage, numberOfBlobs] = bwlabel(binaryImage, 4); % Label with 4-connectivity
if labeledImage(1,1) == labeledImage(5,5)
% They're the same label so there is a path connecting them.
uiwait(msgbox('Those points are connected.'))
else
% They're NOT the same label so there is NO path connecting them.
uiwait(msgbox('Those points are NOT connected.'))
end
For "m" connectivity, you might have to write your own special labeling routine. I've never heard of this being needed. Why do you need it?

Etiquetas

Aún no se han introducido etiquetas.

Community Treasure Hunt

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

Start Hunting!

Translated by