New YouTube Jam Images

As part of our recent work around making your music look awesome, we’ve also updated how YouTube jam images look.

The challenge with making your music look great is that most of the time we’re starting with very low-quality source imagery. Similar to how apps like Instagram originally were hailed for turning crappy mobile phone pics into something with style, we’ve been trying to solve for this with music.

YouTube thumbnails are the most difficult to deal with in this category because not only are they very low quality themselves, they’re most likely to be from a video like this one. They’re pillar or letter-boxed; they have lots of compression artifacts; they tend to be low in saturation and contrast; and often the video footage is actually a square album cover (of varying sizes) on a black background.

As the backgrounds are generated from the jam image, it’s important that we have a nice-looking jam image to start with! So, this what we do:

First, we look for letter or pillar-boxing. We try to remove that by using a simple algorithm that scans the image horizontally/vertically and detects where the color exceeds a threshold. If that x/y point is consistent horizontally/vertically it’s probably letter or pillar-boxed.

Second, we crop in from the edges a bit to avoid the frequent few pixels of black border that often show up on one or all sides.

Lastly, we apply some filters to minimize the compression artifacts and increase the saturation and contrast. We do this in two stages: First we adjust the levels, then we add a subtle film grain texture.

To adjust the levels and increase contrast we need to apply a function that “squashes” the pixel values. This makes the low values lower and the high levels even higher. One function that does that is the hyperbolic tangent, here’s what it looks like:

image

And here’s a Python function (using PIL) that implements a scaled tanh that takes a depth parameter:

Code

Once we’ve adjusted the contrast we add a bit of noise to the image. This film grain-like effect not only felt appropriate for video; but we also discovered that applying an even texture (like noise) was most likely to eradicate the craggy irregularities of compression artifacts. The easiest way to do this is to iterate over all the pixels and adding a random value [-depth, depth] to each pixel.

Code

The problem with this approach is that Python is very slow at executing tight loops. Running this code on a laptop over a 400x400px image takes around 1.3 seconds.

Enter scipy.weave. Weave is a bit of magic that allows you to embed raw C code within Python. Here’s the previous code sample refactored (using PIL and scipy):

Code

Now the code takes less than 0.3 seconds to run locally; 4.5 times faster than using pure Python.

This is what it looks like when these steps are applied:

image

– Andreas, Han & Team Jam

Music we like, things we make & stuff we get up to. from Team Jam
www.thisismyjam.com

view archive