Fun with Filters and Frequencies

~ Pramath


Introduction

Part 1.1 Finite Difference Operator

Below is the original cameraman image.

cameraman imgage

Here is result of the image convolved with the finite difference operators D_x and D_y.

Finite difference operator

Below is the graident magnitude image

magnitude imgage

I then binarized this magnitude image by taking a threshold of greater than 79 pixel intensity to saturate to 255 and the rest to go to 0. This threshold was set qualitatively in order to suppress false postive edges. Below is the result of this binarization.

threshold imgage

Part 1.2 Deravative of Gaussian (DoG) Filter

A blurry image was created by convolving the original image with the gaussian kernel that was generated using cv2.getGaussianKernel(). Below is the blurry image.

Blurry image

The process mentioned in Part 1.1 was then repeated with this gaussian blurred image. Below is the resulting image.

gx_gy gaussian imgage magnitude imgage blur imgage

The differences are quite prominent where the edges are easily detected and more visible. The edges are also thicker and bolder.

Next, the operation was combined into 1 singular convolution. The gaussian was convolved with D_x and D_y. The resulting filter is displayed as an image below.

dog dxdy The same result is gotten as above with the the magnitude image generated as shown below. mag imgage

Part 2.1: Image "Sharpening"

In this part, a sharpening filter was generated and convolved with the image of interest to get a sharpened image. The sharpening filter was generated by taking the impluse filter minus a gaussian filter, multiplying that result by some multiple and then adding the impulse filter. Using this filter under different multiplicative factors lead to results shown below.

Sharpen imgage Sharpen Dog Sharpen imgage

It was noticed that as the number of high Frequency signals were added to the image, it appeared sharper with the edges being more prominent.

For evaluation, a sharp image was blurred with sigma set to 2 and then that blurred image was sharped to get the original image. Below is the result.

Sharpen imgage

Part 2.2 Hybrid Images

Using the idea of different Frequencies that our eyes are sensitive to, we can overlay images filteered at differing frequencies.

Sharpen imgage

Here is the same FFT magnitude plot but after filtering the images.

Sharpen imgage

Here is the FFt magnitude of the hybrid image.

Sharpen imgage

Here is the hybrid image of Derek and nutmeg.

Sharpen imgage

From close, it is einstein but from far it is schrodinger.

Sharpen imgage Sharpen imgage

Another interesting example I created is where you can see a change in expression. From close, it looks like the woman is angry but from afar, she appears not angry. Below is the input images.

Sharpen imgage Sharpen imgage

Here is an example of the hybrid image not working. In this case, the frequencies in both input were very similar therefore, it is not possible to distinguish the 2 images. It is supposed to be a man in close and a woman from afar.

Sharpen imgage

From analysing the FFT spectrum, it was seen that the dominant frequencies between the images were very close and were not filtered out which is why the hybrid image failed.

Part 2.3 Gaussian and Laplacian Stack

Gaussian and laplacian stacks were implemented from scratch. The visualization below shows the laplacian stack at various levels. The top most row is the first level with lots of high frequency features. The left column is the apple, middle column is the orange and the right column is the combination of the 2 images.

Sharpen imgage

Part 2.4 Multiresolution Blending

The laplacian stacks were then blended together to create the "oraple". Below is the result. Sharpen imgage

The "oraple" was created using a vertical seam. I then tried out various filters such as a horizontal seam and an irregular filter too. I created a function that takes in an image and generates a binary filter from its edges. That way, irregular shaped filters can be created with interesting results.

Firstly, using a vertical seam, I blended 2 images of tahoe to create one super image. Below are the raw images.

Sharpen imgage

Below is the combined image.

Sharpen imgage

Using a horizontal seam, I blended an image of an airplane with another image of tahoe. Here are the raw images.

Sharpen imgage

Below is the result.

Sharpen imgage

Finally, here are the results of the irregular mask. First, an image of an eye is taken and made a filter. Below is the original eye image.

Sharpen imgage

Below is the filter that was automatically generated from my function - createmask.

Sharpen imgage

I then applied that filter to the image of tahoe and the eye shown below.

Sharpen imgage

Here are the reuslts of the irregular eye filter. I also inverted the tahoe image to create a cool effect of looking through the lens of another person and the inversion of color is like a memory.

Sharpen imgage

Here are some other interesting blends. Enjoy!

Sharpen imgage Sharpen imgage Sharpen imgage