基于光流法相位提取算法---MATLAB实现

基于光流法相位提取算法原理的参考文献为:点击打开链接

%% *******************************************
%% **********************************************
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 = rofDemod(I(:,:,1),I(:,:,2));
figure;imshow(phi_cor,[]);
程序中rofDemod函数见:rofDemo

没有更多推荐了,返回首页