2

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.

4

This can be done with OpenCV and some custom code in C or python, (it is not a very common requirement).

The answers to this question do a great job of discussing how to go about this in C.

For a ready rolled solution you might wish to take a look at NEFI: enter image description here

2

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. – Kodiologist Nov 22 '18 at 16:01
  • @Kodiologist It is better to spell out the requirements to avoid confusion. Tags are for categorization first, not for communicating requirements. – Szabolcs Nov 22 '18 at 16:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.