Perform a 2D Fourier Transform in Matlab without using the inbuilt function
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaire
Réponses (1)
Voir également
Catégories
En savoir plus sur Discrete Fourier and Cosine Transforms dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!