Perform a 2D Fourier Transform in Matlab without using the inbuilt function
이전 댓글 표시
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
Alex Bjurstrom
2018년 3월 23일
Did you ever figure this out? Wondering the exact same thing.
답변 (1개)
Mustafa Rifat
2021년 11월 4일
0 개 추천
Could you solve this? I am looking for the same thing!
카테고리
도움말 센터 및 File Exchange에서 Discrete Fourier and Cosine Transforms에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!