MATLAB: Error using * MTIMES is not fully supported for integer classes. At least one input must be scalar.

dftdigital image processingfourier transformImage Processing Toolbox

I'm trying to implement a 1 dimensional DFT without using Matlab built-in functions such as fft(). This is my code:
function [Xk] = dft1(xn)
N=length(xn);
n = 0:1:N-1; % row vector for n
k = 0:1:N-1; % row vecor for k
WN = exp(-1j*2*pi/N); % Twiddle factor (w)
nk = n'*k; % creates a N by N matrix of nk values
WNnk = WN .^ nk; % DFT matrix
Xk = (WNnk*xn );
when i run the code after using the following commands:
I = imread('sample.jpg')
R = dft1(I)
I get this particular error: *Error using * MTIMES is not fully supported for integer classes. At least one input must be scalar. To compute elementwise TIMES, use TIMES (.*) instead.*
Can someone please help me to figure out how to solve this problem
Note: I am still in the very beginning level of learning Matlab. Thank you very much

Best Answer

To do an FFT you need to start by converting it to grayscale:
I = imread('sample.jpg');
G = double(rgb2gray(I));
Note that to take the FFT of a matrix M, you need to take the FFT of the transpose of the first FFT, that is
FFT(M) = FFT(FFT(M).').'
The dot operator here (.') takes the simple (not complex conjugate) transpose.
Related Question