CS 143 / Project 1 / Image Filtering and Hybrid Images

Hybrid submarine/fish image.

Hybrid images are the result of image combinations in which the image appears to change with respect to viewing distance. This process is accomplished by combining a high-pass filtered version of one image with the low-pass filtered version of another. When viewing the image from a short distance our eyes pick up on the sharper higher frequencies and we perceive an image version similar to that of the high-pass filter. As we begin to back away (or downscale the image as is done above) our eyes begin to pick up on the lower frequencies and the image begins to appear more like the object used with the low-pass filter.

Filtering

To begin the hybrid image process we first must use an image filtering algorithm that allows us to alter the original images. To accomplish this we use an algorithm that takes a small matrix (our filter) and performs operations on every pixel in our images. These operations are computed by first mapping the center of the filter matrix to a pixel value on the image we are filtering. We then take the product of each filter value and its corresponding pixel value (top-left times top-left, bottom-right times bottom-right, etc.) and then combine these values to get a sum. This sum is the new pixel value of the filtered image as shown in Figure 1.1 below.

Figure 1.1 : Filtering process.

By looping through every pixel in our image we can construct a new image using only the values computed by the filter. Depending on the value and the size of the filter this will give us different versions of the original image (Figure 2.1).

my_filter

The algorithm used for filtering the images used on this page was a combination of matrix transpositions, reorganization, and vector matrix products. If the image began as a color image then 3 separate image matrices were made for each of the image's red, green, and blue color values. Each color matrix was then evaluated as if it were a single gray scale value matrix. These values were then combined after the filtering process to recreate a new filtered color image.

The Algorithm

Before any computation could begin, every matrix had to be bordered with 0 values to allow for filtering of the image's edge pixels. Each separate filter sized block of the image matrix was then reorganized to become a single column of an entirely new matrix. Similarly, the filter was reorganized into a row vector and by multiplying this vector with our column matrix we produced a new row vector of filtered values. Using the same dimensions as the original image this new vector was then separated and reorganized into a row matrix creating a new filtered image.

Figure 1.2 : An image with various filters applied.

Hybrid Images

In order to create our low-pass and high-pass images we had to remove the high and low frequencies from each respective image. To remove the higher frequencies we apply a Gaussian filter to our image creating a blurred version of the original. To remove the high frequencies from our other image we can simply apply a Gaussian filter to get the low frequencies and then subtract these lower frequencies from our original.

Figure 3.1 : Gaussian filter applied to bird image.

Figure 3.2 : Laplacian approximation obtained using a Gaussian filter.

Finally, we simply combine the low-pass image with the high-pass image to obtain the hybrid.

Figure 3.3 : What seems to start as a jet slowly becomes a bird as we back away or down sample the image.

Results

Albert Einstein / Marilyn Monroe

Motorcycle / Bicycle

Cat / Dog

Fish / Submarine

Jet Plane / Bird