Objective

The goal of this project is to use low-pass and high-pass filters to process two images respectively and then combine them to get a hybrid image. Both grayscale image and color image are supported. Also, three padding methods are used: pad zero, pad replicate and pad symmetric. Besides, Fast Fourier Transform is used to accelerate the convolution.

Hybrid Images


By applying a Gaussian filter to an image, we can make it smoother and it's called low-pass filtering. After that, we keep the low-frequency information. If we substract this low-frequency part from the original image, then we can get a high-pass filtered image, where only the high-frequency information (edges) remains. Adding them together, we can get a hybrid image, which looks like the low-pass filtered image when it's small but looks like the high-pass filtered image when it's large.

Cutoff Frequencies

Using different frequencies will affect how smooth the filtered image is and then affect how good the result is. In this project, the cutoff frequency is related to the standard deviation and the size of kernel that we use. Generally, when increasing the cutoff frequency, low-pass filtered image becomes more smooth but high-pass filtered image becomes more clear, seen in hybrid image. We need to adjust these two cutoff frequencies to keep a balance between two images so that both of them can be seen in the hybrid image generated.

Padding Methods

Using pad-zero method, there may be a black border in the filtered image, as it's actually padding the image with a black border. However, by using pad-replicate or pad-symmetric method, this effect can be eliminated.

Fast Fourier Transform

Previously, when calculating convolution, we need to do the multiplication between image and kernel directly, which cost us O(n^2*m^2). After using Fourier Transform to process the image and kernel first, we only need to do mutiplication in frequency domain and then do the Inverse Fast Fourier Transform. The results look basically the same, but the speed is much faster. In this project, I first pad image according to the size of kernel, then pad kernel to the same size as the new image, then apply FFT to them after padding zeros to size 1024*1024. After IFFT, I remove those paddings to get the hybrid image as the same size as source image.

Efficiency

When not using FFT, the running time is roughly around 700 seconds, varying with the size of images and kernel. When using FFT, the running time is roughly around 3.5 seconds, which is roughly 200 times faster. This definitely shows that FFT can largely accelerate the convolution process.