Azzera filtri
Azzera filtri

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

4 visualizzazioni (ultimi 30 giorni)
Hello, I have a 2D binary data as follows:
I = imread('threads.png');
Icomplement = imcomplement(I);
BW = imbinarize(Icomplement);
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 (
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.

Risposte (1)

Gourab il 23 Giu 2023
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
h = plot(node_graph);
Refer to the below documentation links for more information.




Community Treasure Hunt

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

Start Hunting!

Translated by