Blog RSS Feed

Archive for February, 2008

New Feature: Bible Verse Photo Composites

Monday, February 4th, 2008

Try Bible Verse Photo Composites. Move your mouse over the image to see a photo composite for a particular verse, and click to see composites for the words in that verse.

An example:
Genesis 1:1 shows images over the words “beginning,” “God,” “created,” “heavens,” and “earth.”

Here’s the idea: Use the Flickr API to find photos matching each of the words in the Bible. Then download the photos for each word and layer them on top of each other to produce a composite image for word. Once you do that, layer the important words from each verse on top of each other to produce a composite image for each verse.

Then put all the verses together in sequence to create the orangeish image you see above. About 300,000 images comprising 13,000 words make up the image. Each verse occupies about six pixels.

Technical Background

For layering the photos, I wanted the brightest (most-saturated) colors possible; I used a simple formula. It finds the difference between the brightest and darkest channels in a particular pixel. The brighter colors will tend have bigger differences.

function weight_pixel($pixel)
$rgb = array(( $pixel >> 16 ) & 0xFF, ( $pixel >> 8 ) & 0xFF, $pixel & 0xFF);
sort($rgb, SORT_NUMERIC);
return $rgb[2] - $rgb[0];

This formula differs from the usual conversion formula from RGB to HSL. I didn’t like the results of the RGB-HSL formula as much; the images were slightly darker.

Then I placed the darkest pixels on the bottom layer of the composite image, layering brighter (but about 50% transparent) pixels on top. The results for each word resemble abstract art:

11 (11) begrudge (begrudge) liquid (liquid) sharp (sharp) waterfalls (waterfalls)

I did a similar procedure to produce verse composites, layering the important words from each verse on top of each other. The results are generally less spectacular (in my opinion) than the word composites, as many of the verses look like each other. I’d like to explore other compositing algorithms to try to differentiate the verses more. (Feel free to leave a comment if you have any suggestions for an algorithm!)

Gen 1:2 (Gen 1:2) Josh 3:10 (Josh 3:10) Matt 5:4 (Matt 5:4)

The hardest part was the waiting. It took a long time to download the 300,000 images, and nearly as long to process them all. Plus, it takes a while to upload half a gigabyte of data after processing the images.

The verses composites omit images for about 200 common words (as listed in the Crossway Comprehensive Concordance of the ESV). I didn’t want common words to overwhelm the important ones.

From a coding standpoint, this project let me try out the jQuery Javascript library, which I’ve been wanting to do for some time.

Future Directions

Well, the result is awfully orange. As I said above, I would’ve liked to see some more differentiation. (I tried a few different formulas but didn’t come up with anything that works much better.) You can see some bands that are more orange than others, but I’m not sure how significant they are.

It would be interesting to try to calculate cross-references based on the similarity of the verse composites—are verses that look alike actually similar?

Any work of literature would lend itself to this kind of project. Project Gutenberg has lots of public-domain e-texts available. It would be interesting to compare the composite footprint of, say, Moby Dick to the Bible’s.


The inspiration for this project comes from the 80 Million Tiny Images project by Antonio Torralba, Rob Fergus, and William T. Freeman at MIT. They created a map of nouns in the English language by downloading images from search engines, combining the images, and then arranging them into a graphic based on the words’ semantic distance from each other. Fascinating stuff. Via ReadWriteWeb.