Overview
In this project, we first use difference operators to view the change the vertical and horizontal directions.
We also analyze and view the gradient magnitude with thresholds to reduce the noise. In order to blur the results with a
non ideal low pass filter we use the gaussian.
We also create interesting operations on images such as sharpening images, creating hybrid images of two images, and blending two images together.
Part 1
Part 1.1
In order to compute the finite difference operator with respect to x, we first take the difference matrix for x [[1, -1], [0, 0]] and then we take the difference operator for y [[0, 1], [0, -1]] and we use that with a 2d convolution with each image.
In order to get the gradient, we take (convolved_result_x^2 + convolved_result_y^2)^.5. Then we can run a threshold through the data to reduce noise.
dx
|
dy
|
gradient
|
threshold(.3)
|
Part 1.2
In order to smoothe the result and reduce the amount of noise, we apply the non ideal low pass, the gaussian.
The gaussian 2d kernel is made via taking the outer product of two 1d gaussian kerneles.
The kernel size tested was (k=5, sigma=1.5) and threshold .5.
The first approach was pre blurring the image and then computing the gradients.
Original Cameraman blurred
|
blur image then dx gradient
|
blur image then dy gradient
|
blur image then gradient
|
blur image then threshold(.5)
|
The second approach was to reduce the number of convolutions by convolving the difference operators with gaussian.
The results look the same as if it was done seperately.
Combined dx and gaussian
|
Combined dy and gaussian
|
blur image with gradient combined convolves
|
blur image with gradient threshold combined convolves
|
Part 2
Part 2.1
In order to sharpen the image, we compute the unsharpen filter. This is the filter ((1 + alpha) * e - alpha * gaussian2d). Where e is unit matrix.
With differing value of alpha, the sharpness changes.
The sample Taj Mahal Sharpened below:
Original Taj mahal
|
taj mahal sharpend with alpha = 1
|
taj mahal sharpend with alpha = 3
|
taj mahal sharpend with alpha = 5
|
taj mahal sharpend with alpha = 10
|
The new image I tested on was the picture of a dog, where details such as the snout and the ear were enhanced.
Original dog
|
dog sharpend with alpha = 1
|
dog sharpend with alpha = 3
|
dog sharpend with alpha = 5
|
dog sharpend with alpha = 10
|
dog sharpend with alpha = 15
|
This was also done on a blurred version of the following image.
The sharpening of the blurred image isn't great. This probably because the details of the image was already reduced:
Original Hornet Image
|
Blurred Hornet Image with kernel (6,2)
|
Blurred Hornet sharpend with alpha = 1
|
Blurred Hornet with alpha = 3
|
Blurred Hornet with alpha = 5
|
Blurred Hornet with alpha = 10
|
Part 2.2
The part involved computing hybrid images by using the low frequencies of one of them and combining it with high frequencies of another.
This also involved aligning those images to allow combining them.
The following image is of Derek and Nutmeg. If you look at it close you can see nutmeg. If you look at it far away, you can see Derek.
Hybrid with Derek and Nutmeg grey
|
Hybrid with Derek and Nutmeg color
|
Another Image of Ted Lasso and Bear
Original ted
|
Original bear
|
Ted Lasso + Bear no color
|
Ted Lasso + Bear color
|
Another hybrid I ran was kevin heart and Dwanye Johnson. The combo worked out really well. These were done with gaussian of (20, 25)
Original Dwayne
|
Original Kevin
|
Kevin + Dwayne no color
|
Kevin + Dwayne color
|
FFT Analysis of Kevin + Dwayne
Original Dwayne fft
|
Original Kevin fft
|
dwayne Low Pass fft
|
kevin High Pass fft
|
hybrid fft
|
Part 2.3
In 2.3, we computed gaussian and laplacian stacks of the image.
The gaussian stack is computed by repeatedly taking larger gaussian convolutions(2x the sigma) at every level.
The laplacian is computed by taking the difference between the current gaussian convolution and the previous convolution.
The final layer of the laplacian is the last layer of the gaussian.
The following is the gaussian stacks of the oraple. These results were run with ksize 40.
Oraple Gaussian 0
|
Oraple Gaussian 1
|
Oraple Gaussian 2
|
Oraple Gaussian 3
|
Oraple Gaussian 4
|
The following is the laplacian stacks of oraple
Oraple Laplace 0
|
Oraple Laplace 1
|
Oraple Laplace 2
|
Oraple Laplace 3
|
Oraple Laplace 4
|
The following is the color versions:
The following is the gaussian stacks of the oraple.
Oraple Gaussian 0
|
Oraple Gaussian 1
|
Oraple Gaussian 2
|
Oraple Gaussian 3
|
Oraple Gaussian 4
|
The following is the laplacian stacks of oraple
Oraple Laplace 0
|
Oraple Laplace 1
|
Oraple Laplace 2
|
Oraple Laplace 3
|
Oraple Laplace 4
|
The following the is the oraple grid from the paper
Oraple blend A Mask Level 0
|
Oraple blend B Mask Level 0
|
Oraple blended Level 0
|
Oraple blend A Mask Level 2
|
Oraple blend B Mask Level 2
|
Oraple blended Level 2
|
Oraple blend A Mask Level 4
|
Oraple blend B Mask Level 4
|
Oraple blended Level 4
|
Oraple blend A Mask Sum
|
Oraple blend B Mask Sum
|
Oraple blended
|
Part 2.4: Blending++
In order to blend the result, we first the laplacian of img1, laplacian of img2, gaussian of the masks and then compute
laplacian_a * gaussian_mask + (1 - gaussian_mask) * laplacian_b for each level of the laplacian. We then sum the results.
The following the is a color/black and white version of blended oraple. This with a vertical mask down the center
Oraple Color blended vertically
|
Orple Grey Blended
|
With a horizontal mask down the middle we get :
Oraple Grey blended horizontally
|
Orple Color blended horizontally
|
The next images were done using an irregular Mask to create a colorful volcano.
You can see that the color versions look so much better than black and white
Volcano Mas
|
|
Volcano Image 1
|
Volcano Image 2
|
Volcano Blended other way
|
Volcano Blended one way
|
Volcano Blended one way
|
Volcano Blended other way
|
Conclusion
This project was interesting with the chance to create interesting hybrids, blends, and such. It also was good practice working with gradients and gauissian filters.