Can't prove the convolution theorem of Fourier theorem for two dimensional matrices.

4 vues (au cours des 30 derniers jours)
I multiplied two 2D matrices.A, B
A=[1 2;1 1];
B=[1 2;2 1];
C=A.*B;
I convolved their respective DFTs of 512*512 samples each by using the code given in https://in.mathworks.com/matlabcentral/answers/1665734-how-to-perform-2-dimensional-circular-convolution?s_tid=srchtitle
A_fft2=fft2(A,512,512);
B_fft2=fft2(B,512,512);
C_fft2_cconv2=circular_conv(A_fft2, B_fft2);
I found the IDFT of C_fft2; and applied DFT on C
C_ifft2=ifft2(C_fft2);
C_fft2=fft2(C,512,512);
Acoording to fourier theorem
C_ifft2(1:2,1:2) should be equal to C;
C_fft2 should be equal to C_fft2_cconv2.
But neither are them are same in the results.
Could someone tell how to get it.

Réponse acceptée

Abderrahim. B
Abderrahim. B le 27 Juil 2022
Hi!
Please read about discrete convolution ....
Perhaps this:
Conv, fft and ifft
x = randi(10, 20, 1);
y = randi(20,20,1);
n = length(x)+length(y)-1;
xConvFFt = ifft(fft(x,n).*fft(y,n)) ;
xConv = conv(x,y) ;
% compare
isequal(round(conv(x,y), 4), round(xConv, 4))
ans = logical
1
Conv2, fft2 and ifft2
x = randi(10, 20, 10);
y = randi(20,20,10);
m = length(x)+length(y)-1;
n = length(x) - 1;
xConvFFt2 = ifft2(fft2(x,m, n).*fft2(y,m, n)) ;
xConv2 = conv2(x,y) ;
% compare
isequal(round(xConvFFt2), round(xConv2))
ans = logical
1
HTH
  5 commentaires
Paul
Paul le 30 Juil 2022
Modifié(e) : Paul le 31 Juil 2022
When approximating an integral with a sum, the sum needs to be scaled by dtheta.
format short e
a2=[1 2 1 3];
b2=[2 3 2 1];
c2=a2.*b2
c2 = 1×4
2 6 2 3
For N = 512
N = 512;
dtheta = 2*pi/N;
c2f_cconv_dft=(1/(2*pi))*cconv(fft(a2,N),fft(b2,N),N)*dtheta;
Note that 2*pi cancels, so better to just do
c2f_cconv_dft=cconv(fft(a2,N),fft(b2,N),N)/N;
c2f_cconv_idft=ifft(c2f_cconv_dft,512);
The first four points "match"
c2f_cconv_idft(1:4)
ans =
2.0000e+00 - 2.0900e-17i 6.0000e+00 + 1.2001e-16i 2.0000e+00 - 6.4627e-17i 3.0000e+00 - 1.1330e-17i
The rest of the points are "zero"
max(abs(c2f_cconv_idft(5:end)))
ans =
3.7831e-16
I think this example is actually demonstrating circular convolution theorem of the DFT or its dual, which should be closely related to the convolution property of the DTFT.

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by