{"by":"tsanummy","descendants":8,"id":46685064,"kids":[46729625,46730381,46730129,46731260,46730018,46729470,46741209],"score":35,"text":"I’ve been working on a project to bridge the gap between AI generation and my AxiDraw, and I think I finally have a workflow that avoids the usual headaches.<p>If you’ve tried plotting AI-generated images, you probably know the struggle: generic tracing tools (like Potrace) trace the <i>outline</i> of a line, resulting in double-strokes that ruin the look and take twice as long to plot.<p>What I tried previously:<p>- Potrace &#x2F; Inkscape Trace: Great for filled shapes, but results in &quot;hollow&quot; lines for line art.<p>- Canny Edge Detection: Often too messy; it picks up noise and creates jittery paths.<p>- Standard SDXL: Struggled with geometric coherence, often breaking lines or hallucinating perspective.<p>- A bunch of projects that claimed to be txt2svg but which produced extremely poor results, at least for pen plotting. (Chat2SVG, StarVector, OmniSVG, DeepSVG, SVG-VAE, VectorFusion, DiffSketcher, SVGDreamer, SVGDreamer++, NeuralSVG, SVGFusion, VectorWeaver, SwiftSketch, CLIPasso, CLIPDraw, InternSVG)<p>My Approach:<p>I ended up writing a Python tool that combines a few specific technologies to get a true &quot;centerline&quot; vector:<p>1. Prompt Engineering: An LLM rewrites the prompt to enforce a &quot;Technical Drawing&quot; style optimized for the generator.<p>2. Generation: I&#x27;m using Flux.2-dev (4-bit). It seems significantly better than SDXL at maintaining straight lines and coherent geometry.<p>3. Skeletonization: This is the key part. Instead of tracing contours, I use Lee’s Method (via scikit-image) to erode the image down to a 1-pixel wide skeleton. This recovers the actual stroke path.<p>4. Graph Conversion: The pixel skeleton is converted into a graph to identify nodes and edges, pruning out small artifacts&#x2F;noise.<p>5. Optimization: Finally, I feed it into vpype to merge segments and sort the paths (TSP) so the plotter isn&#x27;t jumping around constantly.<p>You can see the results in the examples inside the Github repo.<p>The project is currently quite barebones, but it produces better results than other options I&#x27;ve tested so I&#x27;m publishing it. I&#x27;m interested in implementing better pre&#x2F;post processing, API-based generation, and identifying shapes for cross-hatching.","time":1768859823,"title":"Show HN: Txt2plotter – True centerline vectors from Flux.2 for pen plotters","type":"story","url":"https://github.com/malvarezcastillo/txt2plotter"}