I have this image of London's road networks.
img = Image[ Import["https://maps.googleapis.com/maps/api/staticmap?center=+51.5+\ -0.116667&zoom=10&size=600x600&scale=2&style=feature:road.highway%\ 7Ccolor:0x000000%7Cweight:1%7Cvisibility:on"], ImageSize -> Medium]
After Binarize and ColorNegate:
I want to take out:
a) The text, without disrupting the edge connectivity.
b) The rectangles, again, without breaking edges.
How can I do this?
After binarizing and negating the image, I tried using MorphologicalGraph
Image[MorphologicalGraph[blackLondon, EdgeStyle -> Black, VertexStyle -> White]]
and got this unsatisfactory result:
I also tried binarizing from 0 (the roads that I care about are pure black) and got this:
binarizedLondon2= Binarize[img, 0]
At this image, I applied morphological closing with a DiskMatrix, and managed to identify the rectangular elements.
rectangularElementsMask3 = ColorNegate[Closing[binarized2, DiskMatrix]]
I clean it up with an Opening.
rectangularElementsMask4 = Opening[rectangularElementsMask3, DiskMatrix]
then Inpaint, on the binarized image
and get this result, which is still disconnected.