CS 6476 Project 1:
Image Filtering and Hybrid Images

Ian Buckley

August 31, 2016

1 Introduction

The project serves as a brief introduction to image processing in MATLAB. The purpose of Project 1 was to explore linear image filtering and the creation of hybrid images as detailed by Oliva et. al. [?]. Linear filtering was performed using spatial convolution of the image with the filter according to the equation:

        ∑
g(i,j) =    f(i- k,j - l)h (k, l),
        k,l
(1)

where g(i,j) is the output image for rows i and columns j, f()˙ is the input image, and h(k,l) is the filter for rows k and columns l. Hybrid images contain the high and low frequency information from two separate images such that the image appears different depending on the distance from which the image is viewed. The hybrid images were generated by combining two properly aligned images which are alternately filtered using low and high-pass filters. This report highlights the approach used in the implementation of image filter and and hybrid image generation; the results of the implementation are presented to demonstrate its efficacy.

2 Approach

The following subsections highlight implementation of linear image filtering through convolution and the generation of hybrid images.

2.1 Image Filtering

Linear image filtering was implemented by performing the convolution shown in Equation (1). Three nested for loops surrounding the summation of the element-wise multiplication of the filter matrix with the image. The three loops correspond to the three dimensions of images: color channels, rows, and columns–by including a loop for the color channels, the filtering function was able to handle both RGB and gray-scale images. Before filtering, the edges of the image were padded by mirroring the image across the boundaries.

2.2 Hybrid Images

The hybrid images were generated by combining two aligned images as detailed in [?]. The first image was convolved with a high-pass filter, and the second image was convolved with a low-pass filter; finally, the two images were added together to create the final image.

3 Results

The results are presented in two subsections. To demonstrate that the image filtering function performs the same operation as the MATLAB imfilter, side-by-side filtered images are presented. To demonstrate successful generation of hybrid images, a number of scaled hybrid images are presented.

3.1 Image Filtering


PIC

Figure 1: my_imfilter Identity
PIC
Figure 2: imfilter Identity



PIC

Figure 3: my_imfilter Blur
PIC
Figure 4: imfilter Blur



PIC

Figure 5: my_imfilter Sobel
PIC
Figure 6: imfilter Sobel


These figures highlight the similarity between my_imfilter and imfilter. Figures 1 and 2 show the results of convolving the image with an identity filter. Figures 3 and 4 show the results of blurring the image. Figures 5 and 6 show the results of convolving the image with a sobel filter. While only three images are selected for side-by-side comparison, the results of the two implementations are sufficiently identical.

3.2 Hybrid Images


PIC

Figure 7: High Frequency Filter of Cat
PIC
Figure 8: Low Frequency Filter of Dog



PIC

Figure 9: Cat-Dog Scaled Hybrid Image



PIC

Figure 10: Bicycle-Motorcycle Scaled Hybrid Image



PIC

Figure 11: Bird-Plane Scaled Hybrid Image



PIC

Figure 12: Einstein-Monroe Scaled Hybrid Image


Figures 7 and 8 show the filtered (high and low respectively) images of a cat and a dog. Figure 9 shows the hybrid image generated by combining these filtered images at various scales, highlighting the effect of viewing the hybrid image at different images. Figures 10-12 show more example of hybrid images, demonstrating that the purpose of the project was sufficiently addressed.

4 Conclusion

Linear image filtering through convolution was successfully implemented in MATLAB, emulating the results of the built-in imfilter function. Hybrid images were generated using this function by combining aligned images that were alternately high and low-filtered. As demonstrated by the results, the objectives of the project were successfully addressed.