user1452954
user1452954

Reputation: 89

How to compute power spectrum from 2D FFT

I've encounter a problem when doing my lab assignment, not sure how to implement this:

Use fft2 on a gray image and to do Fourier transform and then compute the power spectrum. This is my code so far:

>> Pc = imread('pckint.jpg');
>> whos Pc;
  Name        Size             Bytes  Class    Attributes

  Pc        256x256            65536  uint8              

>> imshow(Pc);
>> result = fft2(Pc);

My question is from the result. How to computer power spectrum?

Upvotes: 4

Views: 10837

Answers (2)

monk
monk

Reputation: 134

I guess that you are looking for the logarithmic form of FFT, because this is one of the better ways to express the power spectrum of the Fourier series, because the dynamic range of the spectrum is so large compared to the 8 bits of the display that the bright values in the center dominate the result, this difficulty is handled via a log transformation.

This is the way of doing in MATLAB:

I = imread('cameraman.tif');
imshow(I)
F = fft2(I);
shF = fftshift(F);
Log = log2(1 + abs(shF));
imshow(Log, []);

The empty brackets at the end of the imshow expression is necessary to display the image in the specifying range, for this case that means [min(I(:)) max(I(:))]; that is the minimum value in I is displayed as black, and the maximum value as white.

Upvotes: 4

Cape Code
Cape Code

Reputation: 3574

Try:

psd=abs(fftshift(fft2(Pc))).^2;

In dB:

psd=immultiply(log10(abs(fftshift(fft2(Pc)))), 20);

Upvotes: 4

Related Questions