📄 myunwrappro.m
字号:
function z=myunwrap(input,direction,pointx,pointy)
%This function is used to archieve the phase unwrapping
%the mode tested is z=myunwrap(input,pointx,pointy)
%input is the original truncate phase and it must also be matrix
%region is the central point of the original truncate phase
%if the second parameter misses,the defalut value is the
%original phase center point
%The output is the whole phase map
if nargin<1 error('the input parameter is not enough');end
if nargin==1
direction=0;end
[Nx Ny]=size(input);
m=floor(Nx/2);
k=floor(Ny/2);
if nargin>2
m=pointx;
k=pointy;
end
z=input;
i=m;%%unwrap the truncate phase from the special row
switch direction
case 0
%direction为零时先展开列
%%At first unwrap the arbitrary row phase as the standard phase
while i>1
z(i-1,k)=z(i,k)+mod(z(i-1,k)-z(i,k)+pi,2*pi)-pi;
i=i-1;
end
i=m;
while i<Nx
z(i+1,k)=z(i,k)+mod(z(i+1,k)-z(i,k)+pi,2*pi)-pi;
i=i+1;
end %展开指定点所在的列
%%set the arbitrary row as the start to unwrap all rows
i=k;
while i>1
for j=1:Nx
z(j,i-1)=z(j,i)+mod(z(j,i-1)-z(j,i)+pi,2*pi)-pi;
end
i=i-1;
end %以展开列为基准,向左右一列一列得展开
i=k;
while i<Ny
for j=1:Nx
z(j,i+1)=z(j,i)+mod(z(j,i+1)-z(j,i)+pi,2*pi)-pi;
end
i=i+1;
end
case 1
%为1时先展开行
%%At first unwrap the arbitrary column phase as the standard phase
i=k;
while i>1
z(m,i-1)=z(m,i)+mod(z(m,i-1)-z(m,i)+pi,2*pi)-pi;
i=i-1;
end
i=k;
while i<Ny
z(m,i+1)=z(m,i)+mod(z(m,i+1)-z(m,i)+pi,2*pi)-pi;
i=i+1;
end
%%set the arbitrary row as the start to unwrap all rows
i=m;
while i>1
for j=1:Ny
z(i-1,j)=z(i,j)+mod(z(i-1,j)-z(i,j)+pi,2*pi)-pi;
end
i=i-1;
end
i=m;
while i<Nx
for j=1:Ny
z(i+1,j)=z(i,j)+mod(z(i+1,j)-z(i,j)+pi,2*pi)-pi;
end
i=i+1;
end
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -