Huffpost Science
THE BLOG

Featuring fresh takes and real-time analysis from HuffPost's signature lineup of contributors

Tim Chartier Headshot

Men in Pastel: Text With Math

Posted: Updated:
Print
Amblin
Amblin

Consider the Men in Black 3 poster seen below:

2012-04-08-mib3Poster.png

From a distance, the image looks like Will Smith's character in the movie. Close up, you see the image repeatedly advertises the movie as seen below.

2012-04-08-mibDetail.png

Such art can be created with math. Let's create Men in Pastel using chocolatey treats from Easter. While Skittles, Starburst, Jelly Beans or even Sticky Notes (if you're really watching calories) are options, we'll use M&Ms as packaged for Easter.

2012-04-08-mmPalette.png

We'll begin with a grayscale image of Will Smith and overlay the picture with a grid of squares.
Within each grid box, we'll place an M&M. The question becomes, which M&M do we use? Images are comprised from pixels. A grayscale image can be stored with values between 0 (black) to 255 (white). So, a 400 by 600 pixel grayscale image could be stored in a matrix with 400 rows and 600 columns.

For each square in the grid, record the value of the pixel in the middle of the square. If we have a 10 by 20 square grid, we'll have 200 values. Find 20% of these values that are darkest and place purple M&Ms on their corresponding squares. For the next 20% darkest values, place green M&Ms on the corresponding squares. Continue this process using the blue, pink, and yellow M&Ms.

Can this work? We are only using the center pixel and discarding all surrounding pixel information. It will work better for some images than others. Here is how it worked with the movie poster:

2012-04-08-mibEaster.png

What might improve the algorithm? Rather than taking the pixel value of the center square, you could take the average of the pixels over a grid box. Such a change produces only minor differences in the resulting image for the movie poster. Here we've used a relatively simple mathematical algorithm with the intent that one might use it or some adaptation with real M&Ms.

Mathematicians create other mathematical art. For example, Robert Bosch of Oberlin College uses math and computing to create domino mosaics. Below is a portrait of Jesus Christ, comprised of 96 complete sets of double nine dominoes and based on a XIV century Macedonian icon. To the right we see a detail of the same mosaic.

2012-04-08-domino.png

The school year is soon coming to an end, so I'll conclude with a small quiz. Given what you've learned, how might I have constructed the MIB poster below also constructed with text but possible with an old fashioned type-writer and no need for fonts of various thickness as with the poster that led this article? Think about it and possibly derive your own methods for creating mathematical art.

2012-04-08-mibText.png