0

I am trying to understand how the MATLAB FFT normalization works.

Lets discuss the following example.

%%
sum2D = @(a) sum(reshape(a,1,[]));             % sum elements in 2D matrix

a = [0 0 0; 1 2 1; 1 1 1; 1 1 1; 0 0 0]

f1 = fft2(a)

m = [0 32 0; 0 0 0; 0 1 0; 0 2 0; 0 0 0]

fs = m.*fftshift(f1);
fs = fs./sqrt(numel(fs));

fm = ifft2(fs);
fm = fm.*sqrt(numel(fm))

% imshow(abs(fs))

norm(a(:))^2,norm(fs(:))^2,norm(fm(:))^2

sum2D(abs(a).^2)
sum2D(abs(fs).^2)
sum2D(abs(fm).^2)
sum2D(abs(fp).^2)

If the m = 1, the normalization works and the energy is the same in the initial signal, fft and inverse fft. But if I multiply the signal after making fft by some vector m, then I don't know how to normalize this again.

Should the energy change after multiplying with the m, or I am doing something wrong.

bordart
  • 249
  • 3
  • 11

1 Answers1

1

Yes, multiplying the frequencies by matrix m changes the energy. You have amplified some frequencies and killed others: this may well make the signal stronger or weaker. As a simple example, suppose m had all entries equal to 2: then you double the signal, multiplying its energy by 4. For a general multiplier m, the effect on the energy will depend on what the signal is.

If you really want fm to have the same energy as a, just make it so:

fm = fm*norm(a(:))/norm(fm(:));

To directly answer "how FFT normalization works": applying fft2 multiplies the energy by the number of elements of the matrix. The function ifft2, being the inverse of fft2, divides the energy by the number of elements. So, if you are using ifft2 after fft2 and don't care about intermediate results such as fs, you don't need to do any division or multiplication by sqrt(numel(...)).