For this project, I am implementing the image filtering function and use it to create hybrid images.
Given an image and a filter matrix, first I pad the image with zeros on all sides to deal with image boundaries; then, I compute the value for each pixel of the new image by element-wise multiplying the filter matrix with the corresponding region of the image and then add up these products. Specifically, for each pixel i
and j
result(i,j) = sum(sum(filter .* padded_image((i-(fh-1)/2):(i+(fh-1)/2), (j-(fw-1)/2):(j+(fw-1)/2))))
where .*
is the element-wise multiplication; fw
and fh
are the width and height of the filter.
Here are examples of filtering an image of a cat with different filters.
![]() ![]() ![]() |
![]() ![]() ![]() |
Top: (a) an original cat image, (b) cat image with identity filter, (c) blurred cat image |
A hybird image is an image that can be view differently depending on the distance from the image you are observing from. It is created by combining a low frequency image with another high frequency image. The high frequency image could be seen easier when looking up close, whereas the low frequency image could be seen easier from far distance.
A low frequency image can be obtained by blurring an image and a high frequency image can be obtained by subtracting the low frequency image from the original one. Below is an example of the low and the high frequency image.
![]() ![]() ![]() |
an original cat image – low-frequency cat image = high frequency cat image |
![]() ![]() |
An original image of a dog and a cat. |
![]() ![]() |
High frequency cat image and low frequency dog image |
![]() |
The hybrid image of a cat and a dog. |
![]() |
The hybrid images of a cat and a dog with different sizes. |
![]() ![]() ![]() |
![]() |
![]() ![]() ![]() |
![]() |
![]() ![]() ![]() |
![]() |
![]() ![]() ![]() |
![]() |