Fourier Transform of Gaussian Kernel in Matlab
Mostrar comentarios más antiguos
Hi everyone,
I need your help!
I was reading a document on Discrete Fourier Transform and found the following example:

Here's the mentioned gaussian kernel:
g_k = (1/256)*[1 4 6 4 1;...
4 16 24 16 4;...
6 24 36 24 6;...
4 16 24 16 4;...
1 4 6 4 1];
As can be seen, the size of g_k or g(x,y) is 5 x 5 - while the size of G(u,v) is around 380 x 450
Can you please show me the Matlab code that can generate the above G(u,v) image or result?
Respuesta aceptada
Más respuestas (1)
One could also do as below. This gives only an approximately Gaussian spectrum, however,
g_k = (1/256)*[1 4 6 4 1;...
4 16 24 16 4;...
6 24 36 24 6;...
4 16 24 16 4;...
1 4 6 4 1];
Guv=fftshift( abs(fft2(g_k,380,450)) );
imshow(Guv)
7 comentarios
Gobert
el 12 de Abr. de 2022
Watch your zero-padding.
img_in = double(rgb2gray(imread("peppers.png")));
[m,n]=size(img_in);
g_k = (1/256)*[1 4 6 4 1;...
4 16 24 16 4;...
6 24 36 24 6;...
4 16 24 16 4;...
1 4 6 4 1];
% Compute the FT of the input image
ft_in = fft2(img_in,2*m,2*n);
% Compute the FT of the gaussian kernel
g_k(2*m,2*n)=0;%zero-pad
ft_g_k = fft2(circshift(g_k,[-2,-2]));
% Multiplication
ft_mult = ft_g_k.*ft_in ;
% Inverse FT
inv_out = ifft2(ft_mult,'symmetric');
inv_out=inv_out(1:m,1:n); %unpad
figure, imshow(inv_out,[]), title('output')
Gobert
el 12 de Abr. de 2022
Categorías
Más información sobre Fourier Analysis and Filtering en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!




