Here’s What Every President Would Look Like As a Jack-o-Lantern

2 minute read

A few weeks ago, I was at a data conference where the computer scientist Stephen Wolfram demonstrated how his software, Mathematica, now has an experimental function to identify specific facial features in a photo of a person, like eyebrows, noses and lips. My first thought was: huh, this is sort of like a computational Jack-o’-Lantern.

To test this premise, I conducted an experiment by running the function on images of all 44 presidents, which successfully identified all the prominent features in their faces — even for those venerable presidents who refused to make eye contact with the painter.

By overlaying the results on a pumpkin, I present a digital Jack-o’-Lantern of every commander in chief:

Heres How It Works

Benedict Cumberbatch will never be the President of the United States, but let’s use him as an example. Mathematica identifies eight features: Two eyes, two eyebrows, the nose, the lips and inner mouth, and the outline of the face along the chin.

Using these points, one can then convert them into polygons, excluding the chin and inner mouth.

As I found out the hard way, if you just stick these polygons on a pumpkin, pretty much everyone looks identical. So I cheated a little and converted the original image to orange and cut out the countenance to add to the final product.

From there, it’s pretty simple: You add the face to the pumpkin and cut out the polygons to get the final pumpkin mask:

And there you have it. Add a little flickering light in the background. And then do it 44 times.

Sources: All images used are public domain: The pumpkin comes from here, and all presidential images came from either Wikipedia or the Smithsonian’s collection of portraits.

Try It Yourself!

I’ve published the code to make these “Wolf-o’-Lanterns” to the Wolfram Cloud, so you can see exactly how it works and even run it yourself if you make an account.

More Must-Reads From TIME

Write to Chris Wilson at chris.wilson@time.com