开发者

Multiplying images in frequency domain

开发者 https://www.devze.com 2023-02-18 22:41 出处:网络
I\'ve been working with images in the frequency domain (by taking the DFT or FFT of an image) and I know that convolution in the space domain is multiplication in the frequency.

I've been working with images in the frequency domain (by taking the DFT or FFT of an image) and I know that convolution in the space domain is multiplication in the frequency.

So my question is, if I wanted to apply a specific kernel (lets say a 9x9 smoothing kernel) in the space domain, I would just convolve the whole image by the 9x9 filter. Now, if I wanted to do the same thing in the frequency doma开发者_Go百科in, do I take the FFT of both the image and the kernel? Then how/what do I multiply? After I have that new set of data (image multiplied by kernel), I just reverse the direction of the FFT and that should give me the same result as the kernel convolved with the image in the space domain, right?

Thanks for any help!


IIRC, manage to have your FFT'd image and kernel (both FFT'd) of the same dimensions, then multiply pixel-by-pixel both FFT'd images, then inverse FFT the result.

Take care of what happens to the borders of your image (see FFT theory).


Note that FFT multiplication is the same as circular convolution (e.g. as if the edges of your data wrapped around). If you don't want these circular edge effects from the convolution results, you can zero pad your data by at least the nonzero length of your convolution kernel plus 1. You also have to zero pad your convolution kernel to give it the same length.

For instance, in your case you could use a length 522 FFT (512 + 9 + 1), or maybe a 540 length FFT which has smaller price factors (the FFTW library can be used for very efficient non-power-of-2 FFTs), or zero pad all the way up to a length 1024 FFT if you have to use a power of 2.

As in @maola's answer, both FFTs of the data and the kernel must be of the same length (or else the frequencies you are multiplying won't match), and you have to do complex multiplication in the frequency domain.

0

精彩评论

暂无评论...
验证码 换一张
取 消