This project aims at implementing the built-in function imfilter(A, h) of MATLAB. To do this, I first extracted three color channels from the original image: red, green and blue. Then, for each of them, I performed convolution to get the filtered output. Eventually, I catenated three channels to get the final result. A brief summary of my workflow is listed as below.
To implement the convolution function in a 2-D spatial domain, I first padded the input image with zeros to handle boundary issue. Then I looped through each pixel of the input image and computed its value after convolution. Lastly, I removed the padded elements from output.
% construct hybrid image
low_frequencies = my_imfilter(image1, filter);
high_frequencies = image2 - my_imfilter(image2, filter);
hybrid_image = low_frequencies + high_frequencies;