Graph visualizers, such as Graphviz, can take a formal representation of the nodes and edges of a graph and produce an image from them. What's a program or programming library that can do the reverse; that is, recognize an image of a graph and produce a formal representation? I would be interested in software for recognizing a bitmap as well as the easier case of recognizing a graph from an SVG that follows a standard structure. Either way, restrictions on the graph's appearance are okay. Also, I require only the extraction of node-and-edge relationships, not other things like text labels of nodes.
2 Answers
Mathematica has a built-in function called MorphologicalGraph.
The open source image analysis software Fiji can do this too. The rough steps are:
- Smoothen the image if needed
- Threshold the image to make it binary
- Process -> Binary -> Skeletonize
- Analyze -> Skeleton -> Analyze Skeleton, tick Show Detailed Info. When a table comes up, save it as CSV.
-
Mathematica is closed-source and hence doesn't match the open-source tag, but Fiji looks like a good suggestion. Commented Nov 22, 2018 at 16:01
-
@Kodiologist It is better to spell out the requirements to avoid confusion. Tags are for categorization first, not for communicating requirements.– SzabolcsCommented Nov 22, 2018 at 16:09