Project 1: Image Filtering and Hybrid Images

Component 1: Filtered Images

This project's goal was on reproducing the hybrid images reported by Oliva in Siggraph06. A hybrid image is a fixed image that when viewed by the human eye changes in appearance, depending if seen up close or far away. Far away, the low frequency values dominate and close up, the high frequency values are prominent. When the human eye views low frequency values of an image (the image is blurred), the human eye attempts to "fill in the gaps" with additional details, creating groupings that collectively represent an object in an image. When the human eye sees an image up close, the human eye tends to focus on the specific contrasts and color gradient changes, creating a different object in the image.

The procedure for creating a hybrid images work by applying a low pass filter such as a blurring Gaussian filter on one image and applying a high pass filter such as by removing the low frequencies on the other image, and then blending or summing each images' pixel values into a final image.

The first step in order to create a hybrid image is first finding a way to blur an image. One way this step is done by applying a Gaussian filter to each pixel in the image. This is called convolution. I applied convolution to a sample cat image provided with different filters (identity filter, blur filter, large blur filter, sobel filter, laplacian filter, sharpen filter). The results are below in a table.

I applied convolution to each layer in the image if color, or only once if grayscale. For each pixel, I identified the neighborhood of the image that is the same size as the applied filter. For corner pixels, I padded the boundary regions of the image with zeros, resulting in darkening on the edges of the image but still producing the desired effect for the majority of the image with the applied filter. So the procedure I performed for convolution and as a result, image filtering, was as follows:

  1. Identify image size and filter size
  2. Pad image with rows and columns of zeros to make filter compatible
  3. Initialize new filtered image
  4. For each pixel in each layer, get the pixel neighborhood and compute inner product with filter of same dimensions.
  5. Assign new pixel value to new filtered image.

Original Image.

Identity Image Filter.

Blur Image Filter.

Large Blur Pass Image Filter.

Sobel Image Filter.

Laplacian Image Filter.

High Pass Image Filter.

.

Once I had a procedure for image filtering, I now went about creating hybrid images. The filter I used for creating hybrid images was the Gaussian filter, which is a low-pass filter. To sharpen an image, I would take the original image and subtract out the low frequencies of the image by applying the Gaussian filter to the image (original - blurred image = sharper image). For the Gaussian filter, the standard deviation of the Gaussian can be applied as the cutoff frequency. The same Gaussian filter was applied to both blurred image1 and sharpened image 2. For each image pair below, the hybrid image was created by selecting qualitatively the best cutoff frequency. Below is a detailed example for the default hybrid image of two aligned images - the dog image with a low frequency band pass filter, the cat image with a high frequency band pass filter, with the subjective, qualitatively optimal cutoff frequency being 7. The first table shows the intermediate images, and the remaining tables are for various scaled image pairs with optimal cutoff frequency

Component 2: Hybrid Images

Intermediate Images

Original Dog Image.

Low Frequency Dog Image.

Original Cat Image.

High Frequency Cat Image.

Hybrid Dog and Cat Image, Cutoff Frequency = 7

Hybrid Einstein and Marilyn Image, Cutoff Frequency = 4

Hybrid Submarine and Fish Image, Cutoff Frequency = 4

Hybrid Plane and Bird Image, Cutoff Frequency = 6

Hybrid Bicycle and Motorcyle Image, Cutoff Frequency = 9

One small note of analysis is that hybrid images are effective only in certain situations. As mentioned Oliva and coworkers, the images need to be aligned, but the colors and structure of the two images need to provide a strong illusion. In some cases, it also matters which image has the high pass band filter applied. For example, the dog and cat hybrid image seen above uses the cat for high frequencies and the dog for low frequencies. In this situation, the cat has a smooth orange color skin that disappears after filtering because it is low frequency. If we instead had the dog filtered for high frequencies and the cat for low frequencies, the resulting hybrid image is not as convincing.

Hybrid Cat and Dog Image, Cutoff Frequency = 7

Conclusion: By convolving each pixel in an image with a filter that applies a linear combination of weights to its neighboring pixels, we can create a new image that is blurred, shaper, or even display the horizontal or vertical edges in the original image. By using the Gaussian filter, hybrid images were created by summing the extracted low or high frequencies from each image.