条纹图生成(四步相移)与时域解得包裹相位代码
废话不多说,直接上代码(matlab),后面两个是函数。包含条纹投影图的生成与解得包裹相位两个部分。
clc;
close all;
clear;
width =1240;
height =1110;
WaveLengthArr= [15];
nStepPS=4;
xArr = [1:height];
%% Fringes generation
StdFringeSet = GetFringeSet(height, width, nStepPS, WaveLengthArr, 0);
%% Phase demodulation
Phase_fring = PhaseDemodulate4StepPS(StdFringeSet(1,:));
figure,imagesc(Phase_fring);
%% Fringes generation
function [FringeSet] = GetFringeSet(height, width, nStepPS, WaveLengthArr, ObjectHeight)
FringeSet = cell(1,4);
xArr = [1:height];
yArr = [1:width];
[yGrid, xGrid] = meshgrid(yArr, xArr);
for iWavelength = 1:length(WaveLengthArr)
WaveLength = WaveLengthArr(iWavelength);
for iStepPhaseshift = 1:nStepPS
Phase = -pi + 2*pi*(xGrid+ObjectHeight)/WaveLength;
Phase = Phase + (iStepPhaseshift-1)* (2*pi/nStepPS) ;
Fringe2D = cos(Phase);
% figure, imagesc(Fringe2D); colormap gray; axis image;
FringeSet{iWavelength,iStepPhaseshift} = Fringe2D;
filename = sprintf('%0.2d_%0.2d.bmp', WaveLength, iStepPhaseshift);
imwrite(mat2gray(Fringe2D),filename,'bmp');
end
end
function [phaseMap] = PhaseDemodulate4StepPS(FringeSet)
%PHASEDEMODULATE4STEPPS Summary of this function goes here
% Detailed explanation goes here
phaseMap = -atan2((FringeSet{2} - FringeSet{4}),(FringeSet{1} - FringeSet{3}));
end