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 Ansichten (letzte 30 Tage)
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 Kommentare
Maher Mehro
Maher Mehro am 19 Feb. 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..

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Image Analyst
Image Analyst am 22 Feb. 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

Noch keine Tags eingegeben.

Community Treasure Hunt

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

Start Hunting!

Translated by