I have images like this:
and I want to convert those lines to 3D graphics so I can export it as OBJ or STL.
My best attempt has been by using MorphologicalGraph (following this post) and doing:
img=Import["map.png"] g=MorphologicalGraph[MorphologicalBinarize[img],VertexCoordinates->Automatic,EdgeWeight->Automatic]; edges = EdgeList[g]; vertices = Thread[Rule[VertexList[g], PropertyValue[g, VertexCoordinates]]]; lines = ((edges/.vertices)/.UndirectedEdge[a_, b_] :> Line[{a, b}]); lines3D = {Append[#[[1, 1]], 0], Append[#[[1, 2]], 0]} & /@ lines; Graphics3D[Line /@ lines3D] I do get a Graphics3D but it looks like this:
which is very different from the original image and, actually, if I export that to OBJ or STL, it doesn't work (3D viewers say the file is wrong). I got it working by using thin tubes, e.g.
Graphics3D[Tube[#,0.5]&/@(lines/. {x_?NumericQ,y_?NumericQ}:>{x,0,y})] In any case, I'm not getting what I want. I know there are programs like AutoCAD Raster Design that should be able to do this, but I want to do it with Wolfram Language.
Any ideas on how to preserve the original image and get it in 3D?








