Suppose I have a image
and I take its MorphologicalGraph by using the following code:
p1 = Binarize[ImagePad[image, ImageDimensions[image][]*0.05]]; p2 = Thinning[DeleteSmallComponents[ColorNegate[DeleteSmallComponents[p1, 300]], 300]]; p2 = Pruning[p2]; p2 = Thinning[p2]; img = p2; g = MorphologicalGraph[img, PlotRangePadding -> 2]
There are certain areas where multiple vertexes are practically on the same point, or near the same point, such as
Is there a way to merge multiple vertexes that are near each other within a certain distance into a single vertex? Or is there a good way to process this image so that this can be solved? I've tried to fit linear lines into the image, but it's not quite working. Any help is greatly appreciated!