A Hybridation of Einstein and Marilyn. A close Einstein and a far away Marilyn.
In this project, I write a my_imfilter function which aims to serve in the same way as Matlab's imfilter. Basically, it takes in two martrices and convolute them.
I make some decisions while constructing the algorithm. The first is to process color image layer by layer, say red, green, and bule.
The second is edge processing. Since convolution is basically a process that alters the pixel based on its neighbor pixels. However, those on the edge does not have neighbors all round, so I use padarray in 'symmetric' mode to reflect the border pixels and build the psudo-neighbors for the edges.
The third one is the convolution order. I choose to dot multiply the filter and the image pixel by pixel from upper left corner to down right corner. The alternative process is to build up row vectors, and concatenate vectors. My way to process the whole image is more intuitive.
The code snip aims to explain the hybridization process. Basically, the low frequencies of an image get to be combined with the high frequencies of the other image.
% generate low frequencies of both image
low_frequencies = my_imfilter(image1, filter);
low_frequencies2 = my_imfilter(image2, filter);
% by substracting low frequencies, the high frequencies are remained
high_frequencies = image2 - low_frequencies2;
% re-construct am image with high and low frequenies from two different images
hybrid_image = low_frequencies + high_frequencies;
The following table exhibits the same filtering and hybrid algorithm applying on the same two images: cat and dog.
But they look so different.
The left one was generated using high frequency from dog while low frequency from cat, with a high frequency cut off rate at 12. The right one was generated using high frequency from cat while low frequency from dog, with a high frequency cut off rate at 9.
Frequency is a quite abstract concept. By comparing these two images, several conclusions about image frequencies can be drawn.