I'm using MorphologicalGraph to convert images to graph. This is my source image:
Following this and this, I tried
i = Thinning[Binarize@Import["https://i.stack.imgur.com/WfVsG.png"],
3, Method -> "MedialAxis"];
g = MorphologicalGraph[i,
EdgeStyle -> Directive[Orange, Opacity[.5], Thickness[.01]],
GraphStyle -> "ThickEdge"];
Show[Dilation[i, 1], g]
Below is the output, some edges are not detected while some are detected wrongly
.
Could anyone help me with this? Is this caused by the image quality?
MorphologicalGraph, a "vertex" is a branching point. The "corner" in the lower left of the image is not a branching point, so it will not be a vertex in the result. This is not incorrect behaviour. If you want that point detected, as a first step you would need to come up with a clear definition of what you consider a vertex. – Szabolcs Jul 10 '21 at 10:55MorphologicalGraphdoes not support multi-edges at this point. This is an unfortunate limitation. I have requested this feature from Wolfram multiple times. They are more likely to add it if more people request it. – Szabolcs Jul 10 '21 at 10:55