Example of a hybrid Image.
This project was aimed at familiarising with the concept of Image Filtering and Hybrid Images. In this project, pair of images of same size and orientation were given. One image of the pair was filtered using the low pass filter and the other one was filtered using the high pass filter. Then these images were combined together to create a hybrid images. The various image pairs taken are
Some of the important considerations which were taken into account before obtaining the hybrid images were:
We created a function which inputs two arguments the image and the filter to be used for the image. This image uses the filter as a sliding window and computes the final image with the same dimensions as the input image by using the dot product. Then the results were verified by using the identity filter & the large blur filter (low pass filter), Sobel filter & Laplacian filter (high pass filter). Then the results were tested for each of the image pair in order to identify which image is to be passed using which filter.
Figure showing the results of the cat.jpg with the identity filter, large blur filter, Sobel Filter and the Laplacian Filter. |
Figure showing the results of the dog.jpg with the identity filter, large blur filter, Sobel Filter and the Laplacian Filter. |
In this pair, we saw that the cat has more sharp features as compared to the dog.
Figure showing the results of the fish.jpg with the identity filter, large blur filter, Sobel Filter and the Laplacian Filter. |
Figure showing the results of the submarine.jpg with the identity filter, large blur filter, Sobel Filter and the Laplacian Filter. |
In this pair, we saw that the fish has more sharp features with the scales, eye and fins as compared to the submarine.
Figure showing the results of the einstein.jpg with the identity filter, large blur filter, Sobel Filter and the Laplacian Filter. |
Figure showing the results of the marilyn.jpg with the identity filter, large blur filter, Sobel Filter and the Laplacian Filter. |
In this pair, we saw that Einstein has more sharp features like the hair, mustache, eyes, nose and wrinkles on the face as compared to Marilyn.
Figure showing the results of the bicycle.jpg with the identity filter, large blur filter, Sobel Filter and the Laplacian Filter. |
Figure showing the results of the motorcycle.jpg with the identity filter, large blur filter, Sobel Filter and the Laplacian Filter. |
In this pair, the bicycle is bigger in size as compared to the motorcycle, so the features of bicycle otherwise will suppress the features of the mototrcycle.
Figure showing the results of the bird.jpg with the identity filter, large blur filter, Sobel Filter and the Laplacian Filter. |
Figure showing the results of the plane.jpg with the identity filter, large blur filter, Sobel Filter and the Laplacian Filter. |
In this pair, we saw that the bird has more sharp features as compared to the plane.
Figure showing the results of Justin Bieber with the identity filter, large blur filter, Sobel Filter and the Laplacian Filter. |
Figure showing the results of Miley Cyrus with the identity filter, large blur filter, Sobel Filter and the Laplacian Filter. |
In this pair, we saw that Bieber has more sharp features as compared to Miley.
function output = my_imfilter(image, filter)
[m,n,o] = size(image);
[f1,f2] = size(filter);
for i = 1:o
I(:,:,i) = padarray(image(:,:,i),[floor(f1/2), floor(f2/2)]);
end
output = zeros(m,n,o);
for i = 1:o
for j = 1:m
for k = 1:n
output(j,k,i) = sum(sum((I(j:j+f1-1,k:k+f2-1,i).*filter)));
end
end
end
So as mentioned above the images were filtered using the imfilter function. One image was passed through the low pass filter and the other one was passed through the high pass filter. The high pass filtering was done using the low pass filter. The image was filtered using the low pass filter and then the filtered image was subtracted from the original image, only to retain the high frequencies. The filtered images were then combined together to generate a hybrid image.
Cat has been passed through the high pass filter with cut-off frequency = 10 and the dog has been passed through the low pass filter with cut off frequency = 7 |
Hybrid Image of Cat and Dog |
Fish has been passed through the high pass filter with cut-off frequency = 4 and the Submarine has been passed through the low pass filter with cut off frequency = 5 |
Hybrid Image of Fish and Submarine |
Einstein has been passed through the high pass filter with cut-off frequency = 3 and the Marilyn has been passed through the low pass filter with cut off frequency = 5 |
Hybrid Image of Einstein and Marilyn |
Bicycle has been passed through the high pass filter with cut-off frequency = 4 and the Motorcycle has been passed through the low pass filter with cut off frequency = 6 |
Hybrid Image of Motorcycle and Bicycle |
Bird has been passed through the high pass filter with cut-off frequency = 4 and the Plane has been passed through the low pass filter with cut off frequency = 6 |
Hybrid Image of Motorcycle and Bicycle |
Justin Bieber has been passed through the high pass filter with cut-off frequency = 10 and Miley Cyrus has been passed through the low pass filter with cut off frequency = 10 |
Hybrid Image of Justin Bieber and Miley Cyrus |
Figure showing the results of swapping the dog and the cat images. The image of dog is not so clear. |
Figure showing the results of swapping the fish and the submarine. Although the fish can be seen in the last image, but the fine features of the shape of the fish are lost. |