最近在自学四步移相法提取相位,有个初级疑问:
有四幅移相图片a、b、c、d如下:完整解包裹代码如下:
程序运行后,主要是figure(7)和figure(8)没看太明白,;从figure(5)和figure(6)中可以看出被测物体的轮廓,可是从figure(7)和figure(8)中,怎么能看出物体的轮廓呢?figure(7)和figure(8)的解包是怎么解的?
由于是初学者,所以请您不吝赐教,谢谢。
clc;
clear all
clf
X1=imread('a.bmp');
X2=imread('b.bmp');
X3=imread('c.bmp');
X4=imread('d.bmp');
figure(1);I1=imresize(X1,1,'bilinear'); imshow(I1);
figure(2); I2=imresize(X2,1,'bilinear');imshow(I2);
figure(3); I3=imresize(X3,1,'bilinear'); imshow(I3);
figure(4); I4=imresize(X4,1,'bilinear'); imshow(I4);
[M N]=size(I1);
I1=double(I1);
I2=double(I2);
I3=double(I3);
I4=double(I4);
for j=1:615
for i=2:M
phase(i,j)=atan2(I2(i,j)-I4(i,j),I1(i,j)-I3(i,j));
end
end
%四步相移法计算出相位
figure(5);
imshow(mat2gray(phase));
figure(6);
imshow(phase);
n=zeros(M,615); %解包
n(1,1)=0;
for i=2:615
if abs(phase(1,i)-phase(1,i-1))
n(1,i)=n(1,i-1);
elseif phase(1,i)-phase(1,i-1)<=-pi
n(1,i)=n(1,i-1)+1;
elseif phase(1,i)-phase(1,i-1)>=pi
n(1,i)=n(1,i-1)-1;
end
end
for i=2:576
for j=1:615
if abs(phase(i,j)-phase(i-1,j))
n(i,j)=n(i-1,j);
elseif phase(i,j)-phase(i-1,j)<=-pi
n(i,j)=n(i-1,j)+1;
elseif phase(i,j)-phase(i-1,j)>=pi
n(i,j)=n(i-1,j)-1;
end
end
end
pphase=phase+2*pi.*n;
figure(7);
imshow(mat2gray(pphase));
figure(8);
surf(pphase(2:end-1,2:end-1));