Saturday 1 August 2015

matlab - Image Reconstruction:Phase vs. Magnitude


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);

Answer




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.



No comments:

Post a Comment

readings - Appending 内 to a company name is read ない or うち?

For example, if I say マイクロソフト内のパートナーシップは強いです, is the 内 here read as うち or ない? Answer 「内」 in the form: 「Proper Noun + 内」 is always read 「ない...