三維重建-四步相移法中的提取相位問題

四步相移法中的提取相位問題 
code

%% 清理工做空間
clc;
close all;
clear;圖片

%% 系統標定
L = 200; %攝像機光心到參考平面距離(標定得到)
D = 60; %投影儀光心到攝像機光心連線距離(標定得到)
f = 1/32; %投影的光柵頻率
W_Scale = 12;
H_Scale = 12;it

%% 讀四副圖片(調製圖案)
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; %轉成灰度圖像class

%% 讀參考圖像
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; %轉成灰度圖像im

%% 調製後的圖像相位計算
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)<I4(i,j))
I(i,j)=3*pi/2;
else
I(i,j)=0;
endco

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系統

相關文章
相關標籤/搜索