In this project, we explore different applications of using frequencies to process images in interesting ways. First, we process the images in different ways for edge detection, using finite difference or Derivative of Gaussian Filters. We then explore the separation of an image into high and low frequencies to create sharpen filters, combine images into hybrid images, and develop combine images through gaussian and laplacian pyramids.
We take the partial derivative of the image by convolving the image with the finite difference, dx = [1, -1] and dy = [[1], [-1]] vertically. To develop edges, we binarize the image by thresholding a value and setting to black or white accordingly We use these derivatives to create a gradient magnitude image which shows the edges, using np.sqrt(dx ** 2 + dy ** 2).
dx filter
dx filter (binarized)
dy filter
dy filter (binarized)
gradient magnitude image
gradient magnitude image (binarized)
We found that the optimal threshold for the binarization was 50
We first repeat 1.1 on the image that has been convolved with a Gaussian kernel to blur it. We found a good kernel parameter was k = 10, sigma = 2
Blurred dx filter
Blurred dx filter (binarized)
Blurred dy filter
Blurred dy filter (binarized)
Blurred gradient magnitude image
Blurred gradient magnitude image (binarized)
We first convolve the gaussian kernel with dx = [1, -1] and dy = [[1], [-1]] respectively to create two DoG filters. We then convolve the original image with these filter to create the dx and dy blurred. Again, the gradient is calculated
DoG dx filter
DoG dx filter (binarized)
DoG dy filter
DoG dy filter (binarized)
DoG gradient magnitude image
DoG gradient magnitude image (binarized)
The image is convolved with the gaussian kernel to blur it, which removes the high frequencies. We then subtract the blurred image from the original to have just the high frequencies. We then add this back to the original image to sharpen it, multiplied by an alpha to boost sharpness.
Original Image
Image Details (high frequencies)
Sharpened Image
Original Image
Image Details (high frequencies)
Sharpened Image
Here we blurred the image, only to sharpen it again to compare
Original Image
Blurred Image
Image Details (high frequencies)
Resharpened Image
We create hybrid images. We first apply Gaussian blur to one image to get the low frequencies. We then get the high frequencies of the other image by subtracting the original from the blurred. We then add the low frequencies from image one to the high frequencies of image two, to create the hybrid image.
Hybrid Image Result
FFT of the image
FFT of the result image
A gaussian stack was constructed by repeatedly convolving the image with a gaussian kernel, blurring the image without downsampling. The laplacian stack was constructed by taking the difference between the i and i + 1 for i in the gaussian stack, capturing the loss in detail in each level of the gaussian stack.
Gaussian Stack
Laplacian Stack
Gaussian Stack
Laplacian Stack
For these preview images, the images were normalized so that it can bee seen with the eye.
Image 1 and Image 2 are used to generate laplacian stacks. Then, a gaussian stack is created from the mask image. TO create the blended image, this formula was used (1 - mask_gaussian _stack[i]) * laplacian_stack1[i] + mask_gaussian_stack[i] * laplacian_stack2[i] = blended_stack[i] Then the blended image is reconstructed by summing the blended stack.
Pre Blended Image
Pre Blended Image 1
Pre Blended Image 2
Blended Image
Pre Blended Image 1
Pre Blended Image 2
Mask Image
Blended Image