Introduction

A reproduction of effects mentioned in various papers in Python and with the numpy and scikit-image libraries.

Hybrid Images: 2006 paper by Oliva, Torralba, and Schyns.
Multiresolution Blending: 1983 paper by Burt and Adelson.
Poisson Blending: 2003 paper by Perez et al.

Unsharp Mask

(click to view larger images)

As a warm-up exercise, we performed unsharp masking. We subtracted a blurred, or "unsharp", from the original image to extract the highest frequencies. Then we added these back to the original image to enhance sharpness.

Hybrid Images

Hybrid images look different depending on viewing distance. This is because higher frequencies tend to be visible up close while lower frequencies dominate visual perception when the viewer is far away.

To replicate this effect, we blend the higher frequenices of one image with the lower frequencies of another.

Displayed: a picture of a redhead, a drawing of said redhead, hybrid image.
Below: frequency analysis of each picture.
(last is larger because original blended image resulted in extraneous black space, which we cropped out)

Frequency analysis gives us better insight into which parts of the final image are from the first image and which components are from the second.

Displayed: the drawing with a high-pass filter, the orignal with a low-pass filter, and their respective frequency domain graphs.


Displayed: image of average male, image of average female, hybrid image.


Unfortunately, with this example with picture and a line drawing of Benedict Cumberbatch, the resulting image did not appear to be very effective. The lines of the drawing dominate the softer features that make up the picture.

Displayed: Benedict Cumberbatch, a line drawing of Benedict Cumberbatch, hybrid image.

Frequency Analysis

To better analyze and interpret the results from creating hybrid images, we can generate the gaussian and laplacian stacks for the hybrid image. The gaussian stack is created by repeatedly applying a gaussian filter to an image; the laplacian stack is created by subtracting adjacent images in the gaussian stack.

Marilyn Monroe and Albert Einstein (click for source)

Male or Female?

Multiresolution Blending

To blend an image with a smooth spline (seam) joining two images together, we can use a technique called multiresolution blending. Multiresolution blending computes a gentle seam between the two images seperately at each band of image frequencies, resulting in a much smoother seam.

Displayed: an apple, an orange, an apporange, and an orapple.
Computed with this vertical mask. Gradient masks result in smoother blending.

Displayed: art for Les Mis, Les Mis movie poster, poster → drawing, drawing → poster.
Computed with this diagonal mask. Gradient masks result in smoother blending.

Displayed: space, whale, space whale
Computed with this close mask. Close masks result in better results.

More Frequency Analysis

Again, to better analyze and interpret the results from creating hybrid images, we can generate the gaussian and laplacian stacks, this time for the final image above, and for the masked off input images.

Displayed (each row): final image, background only, whale only.

A Toy Problem

To get used to working with gradient domain processing, we started with a toy example. In this example we computed the x and y gradients from an image source s, then use all the gradients, plus one pixel intensity, to reconstruct an image v.

For each pixel, then, we have two objectives:
min (v(x+1,y)-v(x,y) - (s(x+1,y)-s(x,y)))^2: the x-gradients of v should closely match the x-gradients of s.
min (v(x,y+1)-v(x,y) - (s(x,y+1)-s(x,y)))^2: the y-gradients of v should closely match the y-gradients of s.

We also added a final objective, that the top left corners of the two images should be the same color.
minimize (v(1,1)-s(1,1))^2.

Displayed: original image, reconstructed image.

Poisson Blending

The primary goal of poisson blending is seamlessly blending an object or texture from a source image into a target image. The simplest method would be to just copy and paste the pixels from one image directly into the other for a naive blend. Unfortunately, this creates an obvious seam between the source and target image. How do we blend the seams... seamlessly?

Gradients are the difference in intensity between two pixels. If we can set up the problem as finding values for the target pixels that maximally preserve the gradient of the source region without changing any of the background pixels, we can create a nice blend. Note: we are making a deliberate decision here to ignore the overall intensity! So a green hat could turn red. But at least it'll still look like a hat.

Displayed: spaaaace, whale, crude mask, naive blending attempt.


Here are the final results, comparing multiresolution blending with poisson blending. Clearly, multiresolution maintains the original coloring of the whale while poisson blending prefers to maintain the gradients from the space background, resulting in a whale that is rather "ghostly".

Despite the ghostly whale, we had decided that it was our favorite blend after blending multiple images. But we later decided we preferred the multiresolution blending because it preserved the colors more faithfully, even after trying to poisson blend with a close mask. Thus, while this was our favorite result, we also decide it was mostly unsuccessful.

Displayed: multiresolution blending with a close mask, poisson blending with a crude mask, poisson blending with close mask.

Displayed: author with cat ears, also the author with cat ears, a mask for a third eye, third-eyed monstrosity.

Displayed: hikers, penguin, crude mask, penguin with hikers.

Final thoughts: definitely, the most important thing we learned from implenting these functions is to read the source papers very closely. Many times we realized we misinterpreted the paper's instructions.