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 回表示 (過去 30 日間)
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 件のコメント
Maher Mehro
Maher Mehro 2020 年 2 月 19 日
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..

サインインしてコメントする。

回答 (1 件)

Image Analyst
Image Analyst 2020 年 2 月 22 日
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?

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by