How Convert the 2D Binary Data to the Node-link Graph?

조회 수: 7 (최근 30일)
Changwoo Lee
Changwoo Lee 2023년 6월 22일
답변: Gourab 2023년 6월 23일
Hello, I have a 2D binary data as follows:
I = imread('threads.png');
Icomplement = imcomplement(I);
BW = imbinarize(Icomplement);
imshow(BW);
Then, I want to convert this 2D binary data to the Node-link Graph.
Finally, I want to detect where the disconnectivity of each link occurs.
Meanwhiles, I found the matlab code (skel2graph3D) on the link (https://kr.mathworks.com/matlabcentral/fileexchange/43527-skel2graph-3d)
However, this code might only support the conversion of 3D binary data to the node-link graph.
Therefore, my question is how to convert the 2D binary data to the node-link graph.
Is there any useful Matlab code library?
Your answers are of great help for me. Thank you very much.

답변 (1개)

Gourab
Gourab 2023년 6월 23일
Hi Changwoo,
After reading the question I get that you want to convert the 2D image to a node linked graph but you are unable to do it using "Skel2Graph3D” function.
You can use the “bwskel” function to convert the binary image BW to a skeleton and then using the “Skel2Graph3D” function plot it as a node-link graph.
Refer to the below code snippet.
% Read binary image
I = imread('threads.png');
% Invert image and binarize
BW = ~imbinarize(I);
% Compute skeleton using bwskel
skel = bwskel(BW);
% Convert skeleton to node-link graph
node_graph = Skel2Graph3D(skel,15);
% Plot node-link graph
figure;
h = plot(node_graph);
Refer to the below documentation links for more information.

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by