Subscribe to WolfCoder's Kawaii Column

## Laplacian Pyramids of Pictures

Here's a classic topic that comes up whenever one talks about doing things with digital images. These aren't picture wavelets, but it's a way to take apart an image into different frequencies without destroying the picture. Let's take a picture of Cirno-tan^^

Notice how her dimensions are powers of two. This is important when building the pyramid.

Building one of these is simple, you need to create two methods.

One will blur the image so that each pixel has information from up to two pixels away (use a Gaussian kernel: 0.05, 0.25, 0.4, 0.25, 0.05). Then you take every second pixel so the image is half it's size.

Then you need another method that doubles an image's size, and blurs it in the same way.

So we take the above picture, shrink it and then expand it. You'd imagine the picture was damaged, right? It wouldn't look right. We can take the original picture and subtract this new, damaged picture and get what's called a Laplacian of a difference of Gaussians.. We recorded how the image changed.

The image has lots of gray since gray is actually the value 0. This image is signed, dark parts are negative and light parts are positive. Notice how the edges are highlighted, the Laplacian can also be used to find edges of any particular size.

Then we take the original image, shrink it and repeat. We keep going until the image is a 4x4 pixel image and can't really be divided further:

And the smallest picture of all is the original image shrunken many times, chibi-Cirno~!

It's kind of hard to see, but we have this pyramid with the smallest picture on top. The reason this method was significant is that you have information at all half-resolutions and we can actually put the image back together without damage.

Let's take the microscopic thumbnail and expand it so that it matches the Laplacian image right under it. Here's an enlarged comparison of the two:

Image / Laplacian

If we add the Laplacian on the right back (which is the error), we actually get the original picture at a size twice as large as the one below it:

We can just repeat this and the image comes back! The damage is so tiny that when you convert it back into 0-255 integer values, it's indistinguishable. The damage actually comes from the computer's typical loss of resolution when dealing with floating point numbers.

And it looks just like it did at this final step:

Perhaps you can write a program that does this, and if you do, try modifying the Laplacians at each step in different ways to see what happens to the image.

S M T W T F S
12345
6789101112
13141516171819
20 212223242526
2728293031

...