preddy5 / multi_implicit_fonts

25 stars 4 forks source link

Question about vectorizing the output #4

Closed thuliu-yt16 closed 2 years ago

thuliu-yt16 commented 2 years ago

The paper, A Multi-Implicit Neural Representation for Fonts, said that you have vectorized the zero-level-set of the SDF output in a piece-wise linear way in the caption of Figure 5. So in my understanding, the output of the SDF can be vectorized to the SVG format.

Could you explain how you do it specifically? Because it can save a lot of time by avoiding high-resolution queries of the SDF network and generate beautiful results simutaneously.

Please correct me if wrong, thank you!

preddy5 commented 2 years ago

Hey @thuliu-yt16 The solution is easier than you would imagine.

IMO there are two components to the question, 1) Saving a piece-wise linear shape as an SVG 2) Finding the zero level-set of a 2D SDF.

An easy way to save the piece-wise linear shape as an SVG is, once you have the 2D points of the zero level set you can use Excel, Illustrator, matplotlib, or any other tool to plot those points as a line plot and save the plot as an SVG.

Finding the zero-level set would require marching cubes, but there is an easier way to do this for 2D. You can use matplotlib.pyplot.contour function with levels=[0.0], colors='black' parameters and it would plot only the zero level-set. Then you can use savefig method in matplotlib to save the zero level-set plot as an SVG.

Hope that helps.

thuliu-yt16 commented 2 years ago

Thanks a lot!