Project 1: Image Filtering and Hybrid Images

Example of original cat image

Algorithm

Before writing the main section of my algorithm that will require nested loops, I needed a way to pad a new image with 0's. With the hint that was given, the padarray method worked like a charge by allowing me to pad the array with 0's by the filter width(and height) / 2.


paddedImage = padarray(image, [(filterHeight - 1) / 2, ...
        (filterWidth - 1) / 2], ...
        'symmetric')

Our algorithm now requires 3 nested loops that go through the image channel, width, and height. We then use the matlab built in sum function to add the values from the padded image from above. The important take away from this line of code is the final element-wise multiplication code that I added. This small but crucial aspect of the code really simplified the code even further using the (.*) addition which was multiplied by the filter. After finally getting the new padded image sum, I was able to sum those values together and set it as the final output for the method.


paddedImageSum = sum(paddedImage(hIndex:hIndex+filterHeight - 1, ...
                wIndex:wIndex + filterWidth - 1, channel).*filter);

Results

As you can see from the images above, the first row of images are the results from the proj1_test_filtering file. The my_imfilter was able to take the original image and display different filters that were added onto it. The bottom row of images display the hybrid images merged together. The second image from the left was the high frequency and the third from the left was the low frequency. Merging those together gave us the final image on the right.

Extra Filters!

Because filters are cool, I added three other ones that i thought would be cool. from left to right, we have a sharpen filter, a emboss filter, and an edge detection filter.