1
$\begingroup$

Assume the following:

img = 255*rand(512); %Generating a 2D matrix with random numbers between 0 to 255.

2D matrix with random values

fftimg = abs(fft2(img)); %FFT of the image.

FFT of the above 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?

$\endgroup$
3
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ 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. $\endgroup$ – Rakshit Kothari Feb 27 '14 at 5:12
  • $\begingroup$ answer updated, thx $\endgroup$ – lennon310 Feb 27 '14 at 5:36
  • 1
    $\begingroup$ @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]$. $\endgroup$ – Jason R Feb 27 '14 at 12:55
  • $\begingroup$ 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. $\endgroup$ – Rakshit Kothari Feb 27 '14 at 13:37
  • $\begingroup$ @RakshitKothari you need to run a couple of times of fft2 then average the power spectral density (fftimg.^2) to observe a flat spectrum $\endgroup$ – lennon310 Feb 27 '14 at 14:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.