The myth of infinite detail: Bilinear vs. Bicubic

Have you ever noticed how, in movies and television, actors can take a crappy, grainy low-res traffic camera picture of a distant automobile and somehow “enhance” the image until they can read the license plate perfectly?

Yeah.

I don’t know what kind of crazy infinite-detail fractal images these scriptwriters think we have. Here in the real world, bitmaps don’t scale worth a damn. Take this bitmap, for example:

Hello Kitty, biatch!

If we blow that up 300% using the simplest possible algorithm ‐ a naïve nearest neighbor (aka pixel resize) approach – we get this:

Pixel-tastic! But there’s a well known way of interpolating the pixels in the image so it doesn’t look quite so bad when upsized – something called bilinear filtering. Bilinear filtering samples nearby pixels in an effort to guesstimate what the missing pixels would look like in a larger image. Let’s enlarge the image 300% using bilinear filtering and see what happens:

A bit blurry, yes, but clearly superior to giant chunky pixels.

There’s also something called bicubic filtering which is supposed to be an improvement over bilinear filtering. Video cards have offered bilinear filtering for years, but they don’t bother with bicubic filtering to this day. And that’s with millions of transistors to burn. If bicubic is only offered by paint programs, you have to wonder, is it really worth it? Here’s the same image enlarged 300% using bicubic filtering:

Interesting. It’s sharper, but I’m not sure it’s all that much better. And there’s a bit of an over sharpening or halation effect at some color borders, too.

There’s another image sample at Interpolate This with a writeup that implies that bicubic is flat-out superior, but I’m not sure that’s the case. Either way you’re interpolating,* it’s just a question of how sharp you like your simulated pixels to be.

The best solution of all is to move to a vector representation and give up on bitmaps – and interpolation – entirely.

*A reader pointed out an interesting algorithm for interpolating low-res images called 2xSAI. Here’s a screenshot I generated of a SNES game with 2xSAI interpolation enabled. Compare to the original screenshot.

Related posts

Better Image Resizing

In a previous post, I examined the difference between bilinear and bicubic image resizing techniques. Those are the two options available in most graphics programs for resizing an image. After some experimentation, I came up with these rules of thumb: * When making an image smaller, use bicubic, which has a

By Jeff Atwood ·
Comments

Recent Posts

Let's Talk About The American Dream

Let's Talk About The American Dream

A few months ago I wrote about what it means to stay gold — to hold on to the best parts of ourselves, our communities, and the American Dream itself. But staying gold isn’t passive. It takes work. It takes action. It takes hard conversations that ask us to confront

By Jeff Atwood ·
Comments
Stay Gold, America

Stay Gold, America

We are at an unprecedented point in American history, and I'm concerned we may lose sight of the American Dream.

By Jeff Atwood ·
Comments
The Great Filter Comes For Us All

The Great Filter Comes For Us All

With a 13 billion year head start on evolution, why haven’t any other forms of life in the universe contacted us by now? (Arrival is a fantastic movie. Watch it, but don’t stop there – read the Story of Your Life novella it was based on for so much

By Jeff Atwood ·
Comments
I’m feeling unlucky... 🎲   See All Posts