Hybrid Imgae of Cat and Dog (You will see a Dog in a distance)
In this project, we are supposed to produce hybrid images by blending high frequency portion of one image with the low-frequency portion of another. For the resulted hybrid images, high frequency tends to dominate perception, while only the low frequency part of the signal can be seen in a distance. We are going to implement the my_imfilter() function in Matlab which will do filtering(correlation) making use of simple matrix calculation.
To get the low frequency portion of one image, we can remove the high frequencies from it by blurring it using the Gaussian filter. On the contrary, to get the high frequency portion of the image, we can get subtract a blurred version of it from the original version. To do image blurring, we make use of the my_imfilter() function implemented by ourselves.
The procedure of producing hybrid image:
We need to tune "cutoff-frequency" for different image-pairs, which controls how much high frequency to remove from Image 1 and how much low frequency to leave in Image 2.
function output = my_imfilter(image, filter)
% pad_column and pad_row are the number of rows and columns needed to be
% padded
pad_column=floor(size(filter,2)/2);
pad_row=floor(size(filter,1)/2);
pad_image=padarray(image,[pad_row,pad_column],0,'both');
output=zeros(size(image));
% do filtering for each color channel
for ii = 1:size(image,3)
for jj = 1:size(image,1)
for kk = 1:size(image,2)
output(jj,kk,ii) = sum(sum(filter.*pad_image(jj:jj+size(filter,1)-1,kk:kk+size(filter,2)-1,ii)));
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Remove the high frequencies from image1 by blurring it. The amount of
% blur that works best will vary with different image pairs
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
low_frequencies = my_imfilter(image1,filter);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Remove the low frequencies from image2. The easiest way to do this is to
% subtract a blurred version of image2 from the original version of image2.
% This will give you an image centered at zero with negative values.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
high_frequencies = image2-my_imfilter(image2,filter);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Combine the high frequencies and low frequencies
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
hybrid_image = low_frequencies+high_frequencies;
Original testing image | Applied the Identify filter | Applied the 9x9 average blur filter | Applied large Gaussian blur filter |
Applied the Oriented filter(Sobel Operator) | applied the High pass filter (Discrete Laplacian) | Original testing image-blur image |
Image 1 (Dog) | Image 2 (Cat) |
Low freqency of Image 1 | High frequency of Image 2 (Cat) |
Hybrid Image | |
Hybrid image shown in different scale of size |
Image 1 (Marilyn) | Image 2 (Einstein) |
Low freqency of Image 1 | High frequency of Image 2 |
Hybrid Image | |
Hybrid image shown in different scale of size |
Hybrid image(bicycle and motocycle) shown in different scale of size |
Hybrid image(bird and plane) shown in different scale of size |
Hybrid image(fish and submarine) shown in different scale of size |