三维重建-四步相移法中的提取相位问题

四步相移法中的提取相位问题 

%% 清理工作空间
clc;
close all;
clear;

%% 系统标定
L = 200; %摄像机光心到参考平面距离(标定获得)
D = 60; %投影仪光心到摄像机光心连线距离(标定获得)
f = 1/32; %投影的光栅频率
W_Scale = 12;
H_Scale = 12;

%% 读四副图片(调制图案)
image1 = imread('o_1000000.bmp');
I1=double(rgb2gray(image1))/255; %将0-255转化为0-1
image2 = imread('o_1000001.bmp');
I2=double(rgb2gray(image2))/255;

image3 = imread('o_1000002.bmp');
I3=double(rgb2gray(image3))/255;

image4 = imread('o_1000003.bmp');
I4=double(rgb2gray(image4))/255; %转成灰度图像

%% 读参考图像
image5 = imread('o_1000005.bmp');
I5=double(rgb2gray(image5))/255; %将0-255转化为0-1
image6 = imread('o_1000006.bmp');
I6=double(rgb2gray(image6))/255;

image7 = imread('o_1000007.bmp');
I7=double(rgb2gray(image7))/255;

image8 = imread('o_1000008.bmp');
I8=double(rgb2gray(image8))/255; %转成灰度图像

%% 调制后的图像相位计算
for i=1:512
for j=1:512
if (I1(i,j)==I3(i,j))
if(I2(i,j)>I4(i,j))
I(i,j)=pi/2;
elseif(I2(i,j)I(i,j)=3*pi/2;
else
I(i,j)=0;
end

    elseif (I1(i,j)>I3(i,j))
        if I2(i,j)>=I4(i,j)
            I(i,j)=atan((I2(i,j)-I4(i,j))/(I1(i,j)-I3(i,j)));
        else
            I(i,j)=2*pi-atan((I4(i,j)-I2(i,j))/(I1(i,j)-I3(i,j))); 
        end

    else
        if I2(i,j)>=I4(i,j)
            I(i,j)=pi-atan((I2(i,j)-I4(i,j))/(I3(i,j)-I1(i,j)));
        else
            I(i,j)=pi+atan((I4(i,j)-I2(i,j))/(I3(i,j)-I1(i,j))); 
        end
    end
end

end

%% 参考图像相位计算
for i=1:512
for j=1:512
if (I5(i,j)==I7(i,j))
if(I6(i,j)>I8(i,j))
phase(i,j)=pi/2;
elseif(I6(i,j) phase(i,j)=3*pi/2;
else
phase(i,j)=0;
end
elseif (I5(i,j)>I7(i,j))
if I6(i,j)>=I8(i,j)
phase(i,j)=atan((I6(i,j)-I8(i,j))/(I5(i,j)-I7(i,j)));
else
phase(i,j)=2*pi-atan((I8(i,j)-I6(i,j))/(I5(i,j)-I7(i,j))); 
end
else
if I6(i,j)>=I8(i,j)
phase(i,j)=pi-atan((I6(i,j)-I8(i,j))/(I7(i,j)-I5(i,j)));
else
phase(i,j)=pi+atan((I8(i,j)-I6(i,j))/(I5(i,j)-I7(i,j))); 
end
end
end
end

转载于:https://www.cnblogs.com/tansuoxinweilai/p/10588122.html

你可能感兴趣的:(人工智能)