16

Figure 1.(c) shows the Test image reconstructed from MAGNITUDE spectrum only. We can say that the intensity values of LOW frequency pixels are comparatively more than HIGH frequency pixels.

Figure 1.(d) shows the Test image reconstructed from PHASE spectrum only. We can say that intensity values of HIGH frequency (edges,lines) pixels are comparatively more than LOW frequency pixels.

Why this magical contradiction of intensity change (or exchange) is present between Test image reconstructed from MAGNITUDE spectrum only and Test image reconstructed from PHASE spectrum only, which when combined together form the original Test image?

enter image description here

clc;
clear all;
close all;
i1=imread('C:\Users\Admin\Desktop\rough\Capture1.png');
i1=rgb2gray(i1);

f1=fftn(i1);
mag1=abs(f1);
s=log(1+fftshift(f1));
phase1=angle(f1);

r1=ifftshift(ifftn(mag1));
r2=ifftn(exp(1i*phase1));
figure,imshow(i1);
figure,imshow(s,[]);
figure,imshow(uint8(r1));
figure,imshow(r2,[]);
r2=histeq(r2);
r3=histeq(uint8(r2));     
figure,imshow(r2);
figure,imshow(r3);
sagar
  • 549
  • 1
  • 6
  • 18

2 Answers2

17

Figure 1.(c) shows the Test image reconstructed from MAGNITUDE spectrum only. We can say that the intensity values of LOW frequency pixels are comparatively more than HIGH frequency pixels.

Actually, this is not correct. The phase values determine the shift in the sinusoid components of the image. With zero phase, all the sinusoids are centred at the same location and you get a symmetric image whose structure has no real correlation with the original image at all. Being centred at the same location means that the sinusoids are a maximum at that location, and is why there is a big white patch in the middle of Figure 1.c.

The phase-only reconstruction preserve features because of the principle of phase congruency. At the location of edges and lines, most of the sinusoid components have the same phase. See http://homepages.inf.ed.ac.uk/rbf/CVonline/LOCAL_COPIES/OWENS/LECT7/node2.html This properly alone can be used to detect lines and edges, http://www.csse.uwa.edu.au/~pk/research/pkpapers/phasecorners.pdf , without regard to magnitude. So you can see that the phase information is most important.

Changing the magnitude of the various component sinusoids changes the shape of the feature. When you do a phase-only reconstruction, you set all the magnitudes to one, which changes the shape of the features, but not their location. In many images the low frequency components have a magnitude higher than the high frequency components, so phase-only reconstruction does look like a high-pass filter.

In short, phase contains the information about the locations of features.

You cannot add the phase-only and magnitude-only images to get the original. You can multiply them in the Fourier domain and transform back to get the original.

geometrikal
  • 3,616
  • 15
  • 27
  • 1
    @geometrical thank u sir for explanation.I read article but i have a doubt.sir,you said "At the location of edges and lines, most of the sinusoid components have the same phase." and using phase congruency method these can be detected .but sir low frequency components from white big patch also can have same phase ? so these frequencies also should be detected. also i have prepared one code as u said in your last line of answer,but i am unable to reconstruct the original image... i am adding my code in next comment. – sagar Jun 24 '14 at 06:10
  • 1
    @geometrical 'clc; clear all; close all; i1=imread('C:\Users\Admin\Desktop\rough\Capture1.png'); i1=rgb2gray(i1); figure,imshow(i1); f1=fftn(i1); mag1=abs(f1); phase1=angle(f1);

    a1=fftn(mag1); a2=fftn(phase1); a3=a1.*a2; a4=ifftn(a3);

    figure,imshow(uint8(a4));'

    – sagar Jun 24 '14 at 06:15
  • 3
    In the big white patch image all the sinusoids have been shifted to have the same phase (= 0) in the centre. Phase congruency is about detecting line or edge features in images. It is another proof that phase is most important for image structure. With your code I mean reconstruct with the phase and magnitude images. – geometrikal Jun 24 '14 at 07:37
  • 2
    clc; clear all; close all; i1=imread('peppers.tif'); i1=rgb2gray(i1); figure,imshow(i1); f1=fftn(i1); mag1=abs(f1); phase1=exp(1i * angle(f1)); a1=ifftn(mag1); a2=ifftn(phase1); a3=fftn(a1).*fftn(a2); a4=ifftn(a3); figure,imshow(uint8(a4)); – geometrikal Jun 24 '14 at 07:38
  • 1
    sir sorry to disturb you but what happens to the low frequency components which have same phase.they also should be preserved in phase only reconstruction.?? – sagar Jun 24 '14 at 13:07
  • 1
    @geometrical sir,in your answer u said "At the location of edges and lines, most of the sinusoid components have the same phase." i want to calculate phase at edges .so i found edges pixels locations using "impixelinfo" command in MATLAB and after running my code, when i type " phase1=angle(f1(167,297))" and 'phase1=angle(f1(165,297))' or 'phase1=angle(f1(165,297))' i am not getting same value at edge locations. where am i getting wrong?? – sagar Jun 25 '14 at 10:40
  • 1
    ahhh, do you realise that the x and y coordinates have a different meaning in the spectrum? x and y in the spectrum represent the sinusoid frequency in the x and y directions. They are not related to the pixel value at that location. – geometrikal Jun 25 '14 at 10:52
  • 1
    @geometrical sir then using MATLAB how should i check that edges have same phase and others have not ? – sagar Jun 25 '14 at 11:13
  • 1
    sir then using MATLAB how should i check that edges have same phase and others have not ? – sagar Jun 25 '14 at 11:19
  • 1
    Edges, by their nature, are made of sinusoids with the same phase (at the edge location). But in a big image it is a bit more complicated as there are many sinusoids, so the typical way to do it is have a quadrature filter bank (filters at different scales) and compare the phases of the filter responses at each scale. Please see Kovesi's work for more code: http://www.csse.uwa.edu.au/~pk/research/matlabfns/ – geometrikal Jun 25 '14 at 12:21
  • 1
    sir one last question...what happens to the low frequency components which have same phase.they also should be preserved in phase only reconstruction.?? – sagar Jun 25 '14 at 12:28
  • 1
    Every frequency component is preserved, they just have their magnitude set to 1. By the way, the phase congruency examples use simple structures as an example, in a whole image there are many sinusoids interacting, and it would be difficult to pick out which ones phases are the same for a particular line or edge. Wavelets on the other hand, are often like sinusoids constrained to a small spatial extent. At the location of lines and edges most of wavelets corresponding to that location have their phases the same. It is worth learning these once you have understood Fourier transform stuff. – geometrikal Jun 25 '14 at 13:15
  • 1
    Some youtube videos have good demos e.g. https://www.youtube.com/watch?v=op0XoVMEdpE – geometrikal Jun 25 '14 at 13:21
  • 1
    sir,what u said about reconstruction from phase is just awesome.i am reading reference books like digital image processing by Gonzalez and woods. and other book by jayaraman.but it is not given in detail about Fourier transform and also about phase spectrum . so,if possible can u send some more useful links or articles related to Fourier transform and also about reconstruction using phase (or its importance)? ?? thank u. – sagar Jun 27 '14 at 09:04
5

In your line mag1=abs(f1); you are leaving the total intensity of the image unchanged (test this by summing up the intensities over all pixels). Rejecting the phase information in Fourier space just leads to a spatial redistribution of the intensity in real space, such that r1 will have the same total insity as i1.

In your line phase1=angle(f1); you are normalizing the amplitudes of each pixel (in Fourier space) to 1, so the total intensity of the image will be changed. As the phase carries a large part of the spatial information of the image, major features of the image are nevertheless preserved.

a.j.
  • 51
  • 1