Project 1: Image Filtering and Hybrid Images

Hybrid image of my sad/happy face

Introduction

The goal of this assignment was to create hybrid images by leveraging a self-written image filtering function. Hybrid images are static images with two interpretations that change as a function of viewing distance (Oliva et al. 2006). As described in the paper, hybrid images can be created by superimposing two images with different spacial scales (i.e. a low-spacial scale and a high-spacial scale). Because high-spacial scale images dominate visual processing at short distances (and vice versa), we see either image depending on how far from the combined image we sit/stand.

Methodology

My project employs a Gaussian filter on the two starting images to get the high frequency (high-spacial scale) and low frequency (low-spacial scale) versions of the respective images. More specifically, my filtering code takes a correlation between the image and the filter (or in this case a convolution since the kernel is symmetric):

Gaussian 2D Kernel values sampled from:

Given the symmetric kernel H, the correlation/convolution is defined as:

Note that the Gaussian filter presented above is a low-pass filter (i.e. eliminates high frequencies). Thus to get the low frequency version of one of the images, it suffices to simply filter it with the above filter. To get the high frequency version of the other image, however, I first get the low frequency version of the image and then subtract this image away from the original.

The image results of my project are shown below. As suggested by the paper, I used two different filters to get the high-frequency and low-frequency images. The choice of what standard deviations to use was driven by judgment.

Results

Index Original Image Post Filtering Combined
1A
Low-Filter Image, std = 8
        
1B
High-Filter Image, std = 5
        
2A
Low-Filter Image, std = 7
        
2B
High-Filter Image, std = 3
        
3A
Low-Filter Image, std = 12
        
3B
High-Filter Image, std = 2
        
4A
Low-Filter Image, std = 8
        
4B
High-Filter Image, std = 3
        

Additional Work

Beyond creating the hybrid images, I thought it would be interesting to look at the hybrid images/intermediate filtering steps in the frequency domain rather than the spacial domain. To do so, I applied the Fourier Transform to each of the images shown above, and plotted the magnitude component. I've reproduced some of my results with comments below. Note that the indices used below correspond to the indices used in the 'Results' section.

Index Image Type Frequency Domain Comments
1A Orignal Image
In this type of plot, the lower frequencies 
are at the center of the graph while higher 
frequencies are represented as further out 
in all directions. Thus, the low-pass filter
does its job of dampening all of the 'brightness'
at higher frequencies. In fact, the filtering
seems to work so well that the filtered image 
is black everywhere but the center of the image.
1A Low-Filter Image
1B Orignal Image
The description of the center of the plot being low
frequency values and the outer areas being high
frequency values still applies here. Notice how
in this case, the image after the high-pass filter
is brighter in those 'outer', higher frequency areas.
The low frequency center, on the other hand, becomes
dampened after the high-pass filter.
1B High-Filter Image