您的位置:首页 > 编程语言 > MATLAB

基于傅里叶变换的相位提取算法---MATLAB实现

2018-02-02 17:20 1246 查看
%% **********************************************
%
%% **********************************************
clear;close all;clc;
N = 512;
xmax = 1;
ymax = 1;
delta = [0,pi/3];
x = linspace(-xmax,xmax,N);
y = linspace(-ymax,ymax,N);
[X,Y] = meshgrid(x,y);
%参数设置,背景光强,调制幅度,物体相位
A = 0.2*exp(-1.8*(X.^2+Y.^2));
B = 0.2*exp(-0.2*(X.^2+Y.^2));
phi = pi*5*(X.^2 + Y.^2);  %模拟相位
figure;mesh(phi);
phi_w = mod(phi,2*pi);
figure;imshow(phi_w,[]);    %模拟包裹相位
M = 2;
I = zeros(N,N,M);
%高通滤波去除背景光强
for k = 1:M
I(:,:,k) = A + B.*cos(phi+delta(k)) + 0.05*rand(N,N);
[NR, NC]=size(I(:,:,1));
[u,v]=meshgrid(1:NC, 1:NR);
%Temporal variables
u0=floor(NC/2)+1; v0=floor(NR/2)+1;
u=u-u0; v=v-v0;
%High pass Fourier filtering by Gaussian filter with sigma=freq
freq = 3;
H=1-exp(-(u.^2+v.^2)/(2*(freq)^2));
C=fft2(I(:,:,k));
CH=C.*ifftshift(H);
I(:,:,k)=real(ifft2(CH));
end
phi_cor = kreisDemod(I(:,:,1),I(:,:,2));
figure;imshow(phi_cor,[]); %显示提取出的相位

其中kreisDemo函数下载地址为:点击打开链接
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  MATLAB 相位提取