Project 1: Image Filtering and Hybrid Images

Image Filtering

My image filtering algorithm for this project is relatively straight forward. For each color in the image, I separate out the matrix that defines the pixels of that color and add a padding of 0s to the matrix based on the size of the filter. The padding is done such that the pixels of the original image I am interating over will always be in the center of the filter. This means that above and below the image there are floor(filterHeight/2) rows of 0s and to the left and right of the image there are floor(filterWidth/2) columns of 0s.

Once the padded matrix of a particular color has been created, I use nested for loops to interate over the image and apply the filter to each pixel. I do this by using Matlab's matrix functionalities to grab only the section of the padded image that is the size of the filter with the current pixel at the center. I then use Matlab's dot() function to compute the dot product of this section and the filter, and then the sum() function to sum the values of the resulting matrix of the dot product. This is the value that I then store in what will eventually be returned as the output image of the function, after the process has been repeated for all pixels on each level of color.

Below are the results of running the proj1_test_filtering provided file with my implemented image filtering algorithm.

Hybrid Images

The hybrid image algorithm is also fairly straight forward. I apply a gaussian filter to both images I am trying to merge, and for the second image I subtract the blurred image from the original. This gives a low frequency first image and a high frequency second image. The sum of the low and high frequency image values then gives us a hybrid image.

Below are the results of all of provided image pairs (as well as one bonus pair that I added myself) passed through the hybrid image algorithm given in proj1. The order of the images is the two orginals, the first original as low frequency, the second original as high frequency, and then the merged hybrid image of the two. Some pairs are less effective at being combined then others, depending on the background of the images or how defined some of the features in them are. I also used slightly different values of cutoff_frequency for each image pair in an attempt to get a better hybrid, the number of which can be seen at the end of each row.

7
6
6
5
5
7

Also worth mentioning is that for all of these image pairs, the gradient of size is still intact, in which in the larger image it appears to be more of the high frequency image, and in the smaller image it appears to be more of the low frequency image. You can see this below in the gradient scale of the hybrid of Captain America and Ironman, in which in the larger image you see more features of Ironman (such as the lines of his suit) and the smaller images more features of Captain America (such as the A on his forehead).