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.
![](https://api.time.com/wp-content/uploads/2018/10/bc2.png?w=2400&quality=75)
Using these points, one can then convert them into polygons, excluding the chin and inner mouth.
![](https://api.time.com/wp-content/uploads/2018/10/bc3.png?w=2400&quality=75)
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.
![](https://api.time.com/wp-content/uploads/2018/10/bc6.png?w=2400&quality=75)
From there, it’s pretty simple: You add the face to the pumpkin and cut out the polygons to get the final pumpkin mask:
![](https://api.time.com/wp-content/uploads/2018/10/bc5.png?w=2400&quality=75)
And there you have it. Add a little flickering light in the background. And then do it 44 times.
![](https://api.time.com/wp-content/uploads/2018/10/bc.gif?w=2400&quality=75)
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
- Why Biden Dropped Out
- Ukraine’s Plan to Survive Trump
- The Rise of a New Kind of Parenting Guru
- The Chaos and Commotion of the RNC in Photos
- Why We All Have a Stake in Twisters’ Success
- 8 Eating Habits That Actually Improve Your Sleep
- Welcome to the Noah Lyles Olympics
- Get Our Paris Olympics Newsletter in Your Inbox
Write to Chris Wilson at chris.wilson@time.com