根据定义绘制相位屏幕的相位结构功能

时间:2018-05-23 18:14:04

标签: matlab matlab-figure

我已经有了一个相位屏幕(2-D NxN矩阵和LxL的大小比例,例如:N = 256,L = 2米)。

我想找到由D(delta(r))=< [x(r)-x(r + delta(r))] ^ 2>定义的相位结构函数-D(r)。 (<。>是整体平均,r是相位屏幕中的位置,x是相位屏幕中的相位值,delta(r)是可变的而不是固定的)在Matlab程序中。你对我的目的有什么建议吗?

P / S:我试图通过自相关计算D(r)(定义为B(r)),但这个计算仍然保留了一些近似值。因此,我想精确计算D(r)的结果。拜托你see this image to better understand the definition of D(r) and B(r)。下面是我的函数代码来计算B(r)。

% Code copied from "Numerical Simulation of Optical Wave Propagation with Examples in Matlab",
% by Jason D. Schmidt, SPIE Press, SPIE Vol. No.: PM199
% listing 3.7, page 48.
% (Schmidt defines the ft2 and ift2 functions used in this code elswhere.)
function D = str_fcn2_ft(ph, mask, delta)
    % function D = str_fcn2_ft(ph, mask, delta)

    N = size(ph, 1);
    ph = ph .* mask;

    P = ft2(ph, delta);
    S = ft2(ph.^2, delta);
    W = ft2(mask, delta);
    delta_f = 1/(N*delta);
    w2 = ift2(W.*conj(W), delta_f);

    D = 2 * ft2(real(S.*conj(W)) - abs(P).^2, delta) ./ w2 .*mask;`



%fire run
N = 256; %number of samples  
L = 16;  %grid size [m]
delta = L/N; %sample spacing [m]
F = 1/L; %frequency-domain grid spacing[1/m]
x = [-N/2 : N/2-1]*delta; 
[x y] = meshgrid(x);
w = 2; %width of rectangle
%A = rect(x/2).*rect(y/w);
A = lambdaWrapped;
%A = phz;
mask = ones(N); 
%perform digital structure function 
C = str_fcn2_ft(A, mask, delta);
C = real(C);

1 个答案:

答案 0 :(得分:0)

直接计算此函数D(r)的一种方法是通过随机抽样:在屏幕上选择两个随机点,确定它们的距离和相位差的平方,并更新累加器:

phi = rand(256,256)*(2*pi); % the data, phase

N = size(phi,1); % number of samples  
L = 16;  % grid size [m]
delta = L/N; % sample spacing [m]

D = zeros(1,sqrt(2)*N); % output function
count = D; % for computing mean

for n = 1:1e6 % find a good amount of points here, the more points the better the estimate
   coords = randi(N,2,2);
   r = round(norm(coords(1,:) - coords(2,:)));
   if r<1
      continue % skip if the two coordinates are the same
   end
   d = phi(coords(1,1),coords(1,2)) - phi(coords(2,1),coords(2,2));
   d = mod(abs(d),pi); % you might not need this, depending on how A is constructed
   D(r) = D(r) + d.^2;
   count(r) = count(r) + 1;
end
I = count > 0;
D(I) = D(I) ./ count(I); % do not divide by 0, some bins might not have any samples
I = count < 100;
D(I) = 0; % ignore poor estimates

r = (1:length(D)) * delta;
plot(r,D)

如果您需要更高的精度,请考虑插值。计算随机坐标作为浮点值,并插入相位以获取样本之间的值。 D然后需要更长,索引为round(r*10)或类似的东西。您将需要更多随机样本来填充更大的累加器。