Question: digital image processing : Title: 2D DFT/FFT and its properties. 1) In MATLAB, write the function myDFT2 which takes as input a (complex) matrix X
digital image processing : Title: 2D DFT/FFT and its properties.
1) In MATLAB, write the function myDFT2 which takes as input a (complex) matrix X and outputs the 2D DFT of X: Y = myDFT2(X);
Your function should compute the 2D DFT by computing the 1D DFT along the rows and then along the columns (or vice-versa).
You should therefore also write the function myDFT which takes as input a vector and outputs the 1D DFT of the vector.
**have to use Input X = single(rand(2^i,1)) + j * single(rand(2^i,1)); where i = 1 to 16 %note: X has to be a random vector (single precision)
possible solution 1 : (is this version correct?)
% Computes the discrete Fourier transform (DFT) of the given vector. % input 'X' can be a row vector or a column vector. % The returned output is the same type of vector with the same dimensions. % function output = mydft(X) n = length(X); output = zeros(size(X)); for k = 0 : n - 1 % For each output element s = 0; for t = 0 : n - 1 % For each input X element s = s + X(t + 1) * exp(-2i * pi * t * k / n); %correct or not? end output(k + 1) = s; end end
Possible solution (version 2):
function X = mydft(x)
N = length(x);
X = zeros (length(x),1)
for k = 0:N-1
for n = 0:N-1
X(k+1) = X(k+1) + x(n+1)*exp(-j*pi/2*n*k) %this is a little bit different with version1, are they the same? is this correct or not?
end
end
end
Thanks
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
