matlab计算图像相位

%% ========================================================================
%% Title:
% 1) Importance of phase in images
% 2) Verification of Fig 6.2 of [1]
%% Author:
% Ankit A. Bhurane (ankit.bhurane@gmail.com)
%% Expression:
%
% Original images and their Fourier transforms:
%
% Space domain <=> Spatial Frequency
%
% I1(x,y) => |F1(w)| exp(j* <F1(w));
% I2(x,y) => |F2(w)| exp(j* <F2(w));
%
% Inverse Fourier transforms with phases exchanged:
%
% R1(x,y) <= |F1(w)| exp(j* <F2(w));
% R2(x,y) <= |F2(w)| exp(j* <F1(w));
%
%% Observations:
% Phase plays a vital role in capturing the changes within an image. If
% phases of the two images are interchanged, the complete image appears to
% be different.
%
%% References:
% [1] Oppenheim, Willsky, Nawab, "Signals and Systems", PHI, Second edition
%% Last Modified: Sept 26, 2013.
%% Copyright (c) 2013-2014 | Ankit A. Bhurane
%% ========================================================================

clc; clear all; close all;

% Read original images
VMG = imread('VMG.png');
SSG = imread('SSG.png');

% Fourier transforms of corrsponding images
F_VMG = fftn(VMG);
F_SSG = fftn(SSG);

% Isolate magnitude and phase of input images
M_VMG = abs(F_VMG); P_VMG = angle(F_VMG);
M_SSG = abs(F_SSG);P_SSG = angle(F_SSG);

% Take inverse Fourier transforms with phase exchanged
I_VMG = ifftn(M_VMG.*exp(1j*P_SSG)); I_SSG = ifftn(M_SSG.*exp(1j*P_VMG));

% Show Image
subplot 221; imshow(VMG); title('Prof. V.M. Gadre (VMG)');
subplot 222; imshow(SSG); title('Prof. Somnath Sengupta (SSG)');
subplot 223; imshow(uint8(I_VMG)); title('Magnitude of VMG, Phase of SSG');
subplot 224; imshow(uint8(I_SSG)); title('Magnitude of SSG, Phase of VMG');

%% ========================================================================

posted @ 2015-06-14 00:47  WhoamIamwho  阅读(2426)  评论(0)    收藏  举报