Example of a hybrid image.
This project required an implementation of a filtering function followed by addition of a low pass filtered and a high pass filetred image to get the resultant hybrid image. My implementation of the filter function proceeded as the following steps.
In order to check the accuracy of my function, I used max(max(max(abs(my_imfilter(image,filter)-imfilter(image,filter,'symmetric'))))) to get an idea about the pixel with the maximum error. The results were in the range of 10^-7.
Using Gaussian filters on both the images used to create the hybrid image, I obtained low pass filteretd images for both. For one of the images, I subtracted the low pass image from the original image to get a high pass image. This was followed by addition of the low pass and high pass images to get the hybrid image which has the same resolution as the input image.
n=size(image,1);
m=size(image,2);
x=size(filter,1);
y=size(filter,2);
img=zeros(n,m);
if (mod(x,2)~=0 && mod(y,2)~=0)
h = floor(x/2);
k=floor(y/2);
image=padarray(image,[0,k],'symmetric','both');
image=padarray(image,[h,0],'symmetric','both');
for p=1:size(image,3)
for i=1:n
for j=1:m
img(i,j,p)=sum(sum(image(i:i+2*h,j:j+2*k,p).*filter));
end
end
end
end
output=img;
The following results are tabulated as original images, followed by the respective high pass and low pass images in one row, followed by the hybrid images in varying sizes in the following row. This is done for a set of 5 images.
I used a frequency cut off of 7 for all images. I tried with other cut offs as well, but the results seemed unsatisfactory.
Following are a few hybrid images with different cut off frequencies. The first image has cut off frequency 4 and the second has cut off frequency as 10.
The dog's nose is too prominent in the cat's face. |
The dog's face becomes prominent only in the smallest image. |
Too much fish visible as noise in the submarine. |
Fish becomes prominent only in the smallest image. |
Same problem here as well. Too much noise in the bird image. |
This is something I tried on my own. A hybrid image of Donald Trump and Hillary Clinton. Though, this is not a very good hybrid image because there are allignment issues.