Group Abstract Group Abstract

Message Boards Message Boards

Creating a network graph from an image

Posted 7 years ago
POSTED BY: Szabolcs Horvát
10 Replies

This one is actually easy to find ... e.g. googling "image to matrix Mathematica" takes me straight to ImageData.

POSTED BY: Szabolcs Horvát
Posted 7 years ago

Hi, I could generate the right figures after upgrading to Mathematica 11.3. I would like to know how to obtain an output of the command,

skeleton = Pruning[Pruning@Thinning[bin], 15]

in the form of a matrix that stores the pixel information of the binary image. I am looking for this matrix to create a graph that can display the edges of the small branches(present at the junctions where there are multiple edges).

POSTED BY: Natash A
POSTED BY: Szabolcs Horvát

It seems that some image processing functions worked differently in version 9. You would have to tune the parameters manually to deal with these differences (e.g. binarize differently).

Some other software, e.g. Fiji, have a feature to remove tiny loops before pruning. I think Pruning does not have this feature.

ConnectedGraphComponents does not exist in 9, but you can use Subgraph[g, First@ConnectedComponents[g]] instead of First@ConnectedGraphComponents[g].

POSTED BY: Szabolcs Horvát
Posted 7 years ago
POSTED BY: Natash A

I included the last, missing command. If any of the commands I showed give a different output than what I show, let me know along with your Mathematica version.

First@ConnectedGraphComponents[g] can never output what you show (i.e. a non-connected graph).

POSTED BY: Szabolcs Horvát
Posted 7 years ago
POSTED BY: Natash A
POSTED BY: Szabolcs Horvát
POSTED BY: EDITORIAL BOARD
Posted 7 years ago
POSTED BY: Natash A
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard