Hilbert Portrait

Hilbert Portrait

The picture is drawn with a single line that never lifts, never crosses itself, and passes through every part of the sheet. The line is a Hilbert curve that's allowed to wiggle more finely where the picture is dark.

Split a square into four cells and walk them in an arch: in at the bottom-left, up, across, and down and out at the bottom-right. Now split each of those cells into four and replace it with a smaller arch, turned so that it ends right beside where the next one starts. Do it again, and again. After $n$ rounds the path visits all the cells of a $2^n \times 2^n$ grid, each exactly once, as one line that never crosses itself. Keep going forever and you get the Hilbert curve, which David Hilbert described in 1891.

 

the wide orange band is the round before

Each cell holds a piece of line about as long as the cell is wide. Halve the cell size and each cell holds half as much line, but four of them fit in the same space, so the patch carries twice the ink. How deep the curve goes sets how dark it looks: the finest cells are the darkest the pen can make, one level coarser is half as dark, then a quarter, an eighth, and so on.

the same area at five depths, each with half the ink of the last

So to draw a picture, the curve should go deep where the picture is dark and stay shallow where it's light. Can it do both and still be one line? Look at where each small arch starts and ends: in one corner, out the next corner along the same side, the same as the big one. So a quarter that stops early is still an arch with its doors in the right places, its neighbors still connect to it, and the whole thing is still one line.

Where a big cell meets a small one, their centers don't line up, and joining centers would put a diagonal there. So the line crosses each shared edge at the smaller cell's height and turns inside the bigger one instead. Every cell ends up holding either a straight run or a single right-angle turn, just like a cell of the plain curve.

That leaves five or six grays, and a picture has hundreds. Printing has it worse, with only ink and paper. Making every dot whichever of black or white is nearer loses the shading. Dithering mixes black and white dots so that, from a distance, they average out to the grays in between.

The curve can do the same with its cell sizes. Where the picture falls between two shades, it mixes cells of both sizes. Picking the nearest shade everywhere leaves flat bands, and mixing brings the shading back.

A Hilbert curve fills a square, and its entrance and exit sit on the same side, one at each corner. So squares placed side by side can be chained exit to entrance. A landscape picture becomes a row of squares, a portrait one a column, and it's still one line.

Allow camera access

to draw from your webcam live, or drop a photo here.

↓
drop the photo