Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gaussian blur with FFT

im trying to implement a gaussian blur with the use of FFT and could find here the following recipe.

This means that you can take the Fourier transform of the image and the filter, multiply the (complex) results, and then take the inverse Fourier transform.

I've got a kernel K, a 7x7 Matrix and a Image I, a 512x512 Matrix.

I do not understand how to multiply K by I. Is the only way to do that by making K as big as I (512x512) ?

like image 320
Paul Avatar asked Aug 24 '10 16:08

Paul


People also ask

How is Gaussian blur done?

In a Gaussian blur, the pixels nearest the centre of the kernel are given more weight than those far away from the centre. The rate at which this weight diminishes is determined by a Gaussian function, hence the name Gaussian blur. A Gaussian function maps random variables into a normal distribution or “Bell Curve”.

What is FFT in image processing?

The Fast Fourier Transform (FFT) is commonly used to transform an image between the spatial and frequency domain. Unlike other domains such as Hough and Radon, the FFT method preserves all original data. Plus, FFT fully transforms images into the frequency domain, unlike time-frequency or wavelet transforms.

What is Gaussian blur good for?

Photographers and designers choose Gaussian functions for several purposes. If you take a photo in low light and the resulting image has a lot of noise, Gaussian blur can mute that noise. If you want to lay text over an image, a Gaussian blur can soften the image so the text stands out more clearly.

What is Gaussian blur?

What is Gaussian blurring? Named after mathematician Carl Friedrich Gauss (rhymes with “grouse”), Gaussian (“gow-see-an”) blur is the application of a mathematical function to an image in order to blur it. “It's like laying a translucent material like vellum on top of the image,” says photographer Kenton Waltz.


1 Answers

Yes, you do need to make K as big as I by padding it with zeros. Also, after padding, but before you take the FFT of the kernel, you need to translate it with wraparound, such that the center of the kernel (the peak of the Gaussian) is at (0,0). Otherwise, your filtered image will be translated. Alternatively, you can translate the resulting filtered image once you are done.

Another point: for small kernels not using the FFT may actually be faster. A 2D Gaussian kernel is separable, meaning that you can separate it into two 1D kernels for x and y. Then instead of a 2D convolution, you can do two 1D convolutions in x and y directions in the spatial domain. For smaller kernels that may end up being faster than doing the convolution in the frequency domain using the FFT.

like image 94
Dima Avatar answered Sep 24 '22 19:09

Dima