Creating Pen Plotter Art with Julia

/home/rps/media/img/plotwork/kaiser-w-ball-orig.jpeg

This is Kaiser. I want to turn him into plotter art, so I need to convert this jpeg into something I can feed to my HP7475A from the 80s. That means HPGL but its no problem to get there from an SVG via Inkscape.

The actually-tricky constraints are:

I figure we’ll worry about color once we have something plot-able, so first we gotta translate this image into a vector of dots and lines.

Pseudofills: Stipples & Hatches

Google turns up two promising artistic techniques: stippling and hatching, which are dot and line-based fills, respectively. Here are some (human artist) examples–

TODO Add stipple / hatching images.

There is already an algorithmic stippler for the EggBot plotter called StippleGen. I fiddled with it but wanted more control, so let’s implement our own.

How?

First, notice that we can mimic shades of gray by varying either the density or size of the black dots that make up the stippling:

TODO Add stipple / halftone example.

Adrian Secord has a paper, “Weighted Voronoi Stippling,” that calculates the stippling’s dot distribution by generating a Voronoi diagram. It’s how StippleGen works, and has been covered by a few other writeups on the web. The paper’s examples look excellent:

TODO Add paper clippings.

What’s a Voronoi diagram? How does it work? Who cares! There’s a VoronoiDelaunay.jl package already–maybe it’ll do all the work for us and we won’t have to learn a thing.

using Pkg
Pkg.add("VoronoiDelaunay")
using VoronoiDelaunay
import Images: imread

function stipple(imgf)
  img = imread(imgf)
  tess = from_image(img, 25000)

  return tess
end

The JuliaImages package includes

function stipple(img)
end

You've read this far⁠—want more?

Subscribe and I'll e-mail you updates along with the ideas that I don't share anywhere else.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.