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

3 vues (au cours des 30 derniers jours)
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 commentaires
Maher Mehro
Maher Mehro le 19 Fév 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..

Connectez-vous pour commenter.

Réponses (1)

Image Analyst
Image Analyst le 22 Fév 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?

Tags

Aucun tag saisi pour le moment.

Community Treasure Hunt

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

Start Hunting!

Translated by