Perform a 2D Fourier Transform in Matlab without using the inbuilt function
13 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello Community,
Perhaps this is a silly one.
I'm trying to get the Fourier transform of an image using matlab, without relying on the fft2() function. As you'll see, I've tried taking the transform in three ways to compare the result but I'm unable to match the result with that obtained from the inbuilt function. Could someone please help me out here. I'm sure there is something simple that I am missing. Thank you in advance.
The code I'm using is as follows -
if true
% code
a=imread('sq1.jpg');
Mat = double(a);
[rows,columns]=size(Mat);
A = zeros(rows,columns);
B = zeros(rows,columns);
for r=1:rows
for c=1:columns
A(r,c)= A(r,c)+(Mat(r,c)*exp(((-1j)*2*pi*(r-1)*(c-1))/rows));
end
end
for c=1:columns
for r=1:rows
B(r,c)=(B(r,c)+(A(r,c)*exp((-1i)*2*pi*(r-1)*(c-1)/columns)));
end
end
figure(1), imshow(B)
% Using the inbuilt function
a=imread('sq1.jpg');
Mat = double(a);
[rows,columns]=size(Mat);
for r=1:rows
ffta(r,:)=fft(Mat(r,:));
end
for c=1:columns
fftb(:,c)=fft(ffta(:,c));
end
figure(2), imshow(fftb) % appliying 1d fft sequentially
fftd=fft2(a);
figure(3), imshow(fftd) %applying 2d fft function
end
end
1 comentario
Respuestas (1)
Mustafa Rifat
el 4 de Nov. de 2021
Could you solve this? I am looking for the same thing!
0 comentarios
Ver también
Categorías
Más información sobre Discrete Fourier and Cosine Transforms en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!