Project2: Fun with Filters and Frequencies!

Raiymbek Akshulakov

Part1:Fun with Filter

Here we are discovering how to get the magnitude of the gradient as well as how it can help us find edge which is super important in various tasks.

Original ||| Dx gradient ||| Dy gradient ||| Magnitude

If we threshold the magnitude by 0.2 we can get some of the edges

One problem tho, as you can see we get a lot of noise in the edges because there is some noise in the image, how do we can take case of those?
Of course Gaussian, it will smooth out those high frequency differences. Here is two ways we can implement it
Original ||| Blur ||| Magnitude of its gradient ||| Binary

Since we use several convolutions we can use useful convolution properties and first convolve gaussian filter with dx,dy filter and process further with cameraman image
Gauss_filter ||| dx of gaussian ||| dy of gaussian

Convolve dx||| Convolve dy||| Magnitude|||Binary

The Final binary answers from both ways are identical


Part 2: Image sharpening

Now we can blur, let's see how to sharpen. As we learned in class gaussian filter basically kills the high frequencies , and now we actually want to get those high frequencies. More high frequencies in the image more we perceive it sharper. The following images perform simple sharpening algorithm were we get the high frequencies of the image by

Subtracting image and its gaussian

And adding it with some alpha coefficient to the original image

alpha - 0 ||| alpha - 1||| alpha - 4
Other examples with alpha 0,1,4
Almaty(my home) ||| airplane ||| lantern at foothill college



LEt's try to blur an image and then sharpen it

Original ||| Blurred version ||| Sharpened version of the blurr with alpha - 2
As you can see sharpenning here does not make much difference because with gaussian blur we already killed some of the high frequencies so that would make sharpennign pointless

Part 2: Hybrid images

One cool application of sharpening and blurring is hybrid images which appear differently based on the distance. It happens because far away we can see much of the high frequencies but from close away we concentrate on those. So if we have low frequencies from one image and high frequencies from another we can make this effect - We can sharpen one image and blur another
We can sharpen one image and blur another, and add average them
Of course for effect to be more clear it is beneficial to have aligned images, so I had to use the code provided by instructors to align the examples

We can actually check what is going in the frequency domain so why it happens is more clearer

Intially Dereks image


------bluring kills some of the high frequencies------


Intially Nutmeg image

------just getting the high ones------



Final Result


Let's check some of other examples
Sather tower, Berkeley||| Hoover tower, Stanford

American Flag ||| Kazakhstan flag

Multi-resolution Blending and the Oraple journey


Our Goal

In this section, we want to seamlessly blend two images. In order to do that we basically are going to build Gaussian/Laplacian stack. When we sharpened images we divided the image into high frequency image and low frequency images. We are going to continue this idea by dividing image into bands of frequencies.

1.First build gaussian stack by applying gaussian filter iteratively until some level is reached <

2.As we go down our stack we get lesser and lesser frequencies so the difference between them will be the band of frequencies that are present in previous image but now in next one

3.So the output of the whole Gaussian/Laplacian pyramid is all the bands plus the last element in the gaussian stack that represents all the lower frequencies that are not in those bands

4.The best part is that if we add all the element back we will get the initial image


Our blending algorithm would consist from getting two Laplacian/Gaussian stacks for two images we can use alpha blending on all the levels and then reconstruct all of it. Here is schematics following this process







We can reuse the same mechanics when we need to blend two images using a mask instead of horizontal or vertical divide

This is just outside my home in Kazakhstan

airplane in space