IDL programming issue - Fourier transform

AI Thread Summary
The discussion revolves around an issue with IDL programming related to applying the convolution theorem using Fourier transforms. The user expects identical results from spatial domain convolution and frequency domain multiplication but encounters discrepancies, resulting in a darker image. They detail their process of zero-padding a 3x3 kernel to 256x256, performing FFT on both the kernel and the image, and then applying inverse FFT. The user suspects that the non-integer values in the resulting array may be causing the problem. Suggestions include checking for rounding errors and increasing the precision of calculations to resolve the issue.
big man
Messages
241
Reaction score
0

Homework Statement


By the convolution theorem one would expect that if you convolved your image with a kernel in the spatial domain, you would get the exact same result if you multiplied the FFT of the image array by the FFT of the kernel.

My problem is that I don't get the same results.

3. What I did:
1. I first zeropadded the 3x3 kernel so that it was a 256x256 array.
2. I took the FFT of the zeropadded kernel and I took the FFT of the image array (256x256)
3. I multiplied these together and then took the inverse FFT to get the filtered image.

In doing this I get a darker image from the convolution in the spatial domain. I mean I have a non-integer array (no longer an integer greyscale array) which I think is the problem. Does anyone have any ideas as to why this is?? If it helps I've copied the code for this below.


kernel1zero=fltarr(256,256)
kernel1zero[0:2,0:2]=kernel1/(total(kernel1))
kernel1zero[3:255, 3:255]=0

convolfre1=fftscan2*(fft(kernel1zero))
inconvofre1=fft(convolfre1, /inverse)


window, 8, xsize=512, ysize=256
tvscl, abs(inconvofre1), 1

Thanks in advance for any help.
 
Physics news on Phys.org
This is just a guess since I have no idea about IDL, but could you have a rounding problem? Try increasing the number of significant digits if you can.
 

Similar threads

Back
Top