# What's the frequency transform of a random matrix?

Assume the following:

img = 255*rand(512); %Generating a 2D matrix with random numbers between 0 to 255. fftimg = abs(fft2(img)); %FFT of the image. The frequency transform of this image is a single high value at the top left corner of the image. This means the 'energy' or the frequency response is the highest and concentrated at the lowest frequency

Can you explain why this happens?

That is the DC offset (at zero frequency).

img = 255*randn(512);  % thanks @Jason's comment
img1=img-mean(img(:));
fftimg = abs(fft2(img1));
imagesc((fftshift(fftimg)))


gives you the spectrum of the normal distribution image. Note that white noise is flat in the frequency domain, but the Gaussian noise in the time domain is still Gaussian in the frequency domain. You may need to average a large number of FFTs of white noise to approach the average power spectral density.

• I saw the frequency transform and it appears as random as the original image. Why is that? What does it mean? I did not observe any spectrum as such. – Rakshit Kothari Feb 27 '14 at 5:12
• answer updated, thx – lennon310 Feb 27 '14 at 5:36
• @RakshitKothari: Try changing the function call that generates the noise to randn instead of rand. This will give you zero-mean, unit-variance Gaussian noise instead of uniformly-distributed noise on $[0,1]$. – Jason R Feb 27 '14 at 12:55
• I agree, with all you are saying, but I want to understand how to deduce the image frequency transform by looking at a simple image. I tried the same using randn and I observe the same noise pattern in my frequency transform. – Rakshit Kothari Feb 27 '14 at 13:37
• @RakshitKothari you need to run a couple of times of fft2 then average the power spectral density (fftimg.^2) to observe a flat spectrum – lennon310 Feb 27 '14 at 14:22