# Compare phase and magnitude spectrum results of 2 Images [duplicate]

I have read that from Fourier transform we obtain magnitude and phase spectrum. The magnitude spectrum tells you how strong are the harmonics in a image and the phase spectrum tells where this harmonic lies in space.

I have used Matlab to compute the magnitude and phase spectrum of the 2 grayscale images of babies using fftn function, but the all spectrum are difficult to understand.  Can anyone please explain the features given in 1st paragraph by comparing the spectrums of both babies ?

1.phase spectrum

and

2.magnitude spectrum

(If you have results other than in Matlab, explaining with your method is also okay)

image1=imread('D:\baby1.jpg');%Read colour image
image1=rgb2gray(image1);%covert colour image into Gray scale

image2=rgb2gray(image2);%covert colour image into Gray scale

figure,
subplot(1,3,1);
imshow(image1);
title('Gray scale Image of Baby1');

%Apply Fourier transform on Gray scale image
fft1=fftn(image1);
fft1=log(1+fftshift(fft1));%Use log function for scaling

%Find the magnitude spectrum
magnitude1=abs(fft1);
subplot(1,3,2);
imshow(magnitude1,[]);
title('Amplitude Spectrum 1');

%Find the phase spectrum
phase1=angle(fft1);
subplot(1,3,3);
imshow(phase1,[]);
title('Phase Spectrum 1');

figure,
subplot(1,3,1);
imshow(image2);
title('Gray scale Image of Baby2');

%Apply Fourier transform on Gray scale image
fft2=fftn(image2);
fft2=log(1+fftshift(fft2));%Use log function for scaling

%Find the magnitude spectrum
magnitude2=abs(fft2);
subplot(1,3,2);
imshow(magnitude2,[]);
title('Amplitude Spectrum 2');

%Find the phase spectrum
phase2=angle(fft2);
subplot(1,3,3);
imshow(phase2,[]);
title('Phase Spectrum 2');

• What kind of "understanding" are you assuming is possible beyond the mathematical formulas? For a limited sort of "understanding", you might try using some extremely simple images, e.g. just a few vertical stripes, horizontal stripes, a few checks of a checkerboard rotated at various angles, etc. A 2D FFT is a linear transform, so composite as needed. – hotpaw2 May 11 '15 at 19:32
• Did you try to write your own code and did you try to carry out your own experiments with simple images. The code and images from your question taken from other question - link, link. – SergV May 12 '15 at 5:08
• @SergV sorry sir,i will write my code and post it's result after some time. – pandu May 12 '15 at 5:44
• @SergV sir,i have made changes – pandu May 12 '15 at 8:17
• To all the "duplicators", you should be careful in stating such claims. The idea is to learn more and not limit our understanding to the limitations of the questions and readers. Suggest to remove the duplication SINCE IT IS NOT! – Moti May 13 '15 at 17:14

When you create the transform, an embedded assumption is that you extend your image to infinity by duplicating it vertical and horizontal direction. Each point in the transform provides information about a 1D wave (frequency that has certain direction based on the point location and phase (how it is moved along the image). Try to draw a 1D sine wave over a 2D array and then run the 2D FFT to see how the point is created - the higher the frequency the point further from the origin. Starting at a peak will result a $90^0$ phase...