metamerist

Thursday, November 01, 2007

Gradient-directed Displacement

In the beginning, this blog was to be a blog about computer graphics, but, well, you know... Returning to the subject, let's look at an interesting way to deform an image.

In most applications, a displacement map indicates how much pixels in some other image are to be moved. Generally, one channel (red, green, blue) of the displacement map indicates horizontal shift while another channel indicates a vertical shift.

In other words, given D (the destination image), S (the source image), M(the displacement map) and k (some scaling constant), the mapping between D and S is something like this:

D(x,y) = S(x+k*M(x,y).red, y+k*M(x,y).green)

Interesting results can be realized with another approach. Rather than generating the displacement vectors from the color values of M, generate the displacement vectors from the gradient of the luminance channel of M (e.g., using a Sobel filter).

Here's an example with the original image on the left and the filtered image on the right:

In this case, the displacement map (M) is generated from the gradient of luminance channel of the original. A Gaussian Blur was applied to the luminance channel before calculating the gradients (without the blur, the results would be noisier, choppier and less smooth).

Visually, this effect causes lighter areas to sort of ooze into darker areas. (Of course, if you invert the vector, the opposite will happen). The results are especially interesting with faces and wrinkly things. In the case of faces, it reminds me of the style of a certain famous illustrator whose name escapes me at the moment.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home