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:
| (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.
The following subsections highlight implementation of linear image filtering through convolution and the generation of hybrid images.
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.
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.
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.
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.
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.
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.