4 ms·
You might have some luck with OpenCV - it has a variety of edge detection features to turn an image into lines. Someone may have already pulled together a mech
by 9wzYQbTYsAIc 4y ago
You might have some luck with OpenCV - it has a variety of edge detection features to turn an image into lines. Someone may have already pulled together a mechanism to turn that output into an SVG.
Making it plottable might be tricky without manual intervention or implementing your own plotting transformation.
3d printer slicing software transforms 3d models down to stacked layers of “plottable” lines, so you might have some luck looking at projects in that space, too.
- mg 4y agoI can do the conversion into an SVG myself. For example, here is an SVG version of one of the illustrations made from only black paths: https://www.gibney.org/jonas-illu-as-paths.html https://www.gibney.org/jonas-illu-as-paths.html What I don't know is how to turn those filled paths into thin ziggy zaggy lines that fill the path area.
- 9wzYQbTYsAIc 4y agoAh, very nice. That should reduce the effort needed to something you might be able to make quick work of, yourself, with some thought about how to walk the vectors in a spiral or something like the zigzags. This website [1] recommends a tool called vpype [2] which might have an option to do what you need or might be able to be tweaked to do what you need. Apparently vpype makes some trade-offs in exactness of reproduction for better flexibility, but it does claim to try to honor stroke width. I’d have recommend digging into SuperSlicer’s code, but their algorithm relies on meshes, so it may not translate as readily. Nonethless, it is worth mentioning that 3d printer slicing software can handle around a dozen or so different patterns. Spirals, rectilinear, star shapes, etc. so you might find inspiration there. [1] https://www.acrylicode.com/svg-to-gcode-walkthrough/ https://www.acrylicode.com/svg-to-gcode-walkthrough/ [2] https://github.com/abey79/vpype https://github.com/abey79/vpype
- mg 4y agoThanks! From the description on GitHub, vpype looks very good. I will play around with it.
- 9wzYQbTYsAIc 4y agoYou’re welcome! I hope it goes well and that you make a Show HN next.
- mg 4y agoTried vpype and the hatched plugin now. Works, but is very basic. It fills black areas with lines without any regard to the shape of the area. The result looks very "rasterized". One could come up with way better algorithms that take the shape of the source into account when filling it with thin lines. Maybe I'll have to code my own solution.
- 9wzYQbTYsAIc 4y agoWell that is unfortunate. Hopefully vpype is written in a language that you are familiar with and you can make a pull request for an enhancement or two. Or perhaps there’s a different tool that will help save time. If not, I’m sure the plotting community would appreciate anything that you come up with. I’ll try to do some digging later today and let you know if I find anything else, as I’m now curious.