try for w = 0.5, 1, 2
% diameter w w = 1; func = @(x,y) cyl(x,y,w); str = sprintf('diameter %g',w); [out in] = fourier2(func);
subplot(1,1,1); rgb = cat(3,in,in,in); imagesc([-4 4],[4 -4],rgb); axis equal axis square axis([-4 4 -4 4]);
close all g = logim(out,3); rgb = cat(3,g,g,g); image([-4 4],[4 -4],rgb); title(str); axis equal axis square axis([-4 4 -4 4]);
close all sz = size(out); N = sz(1); k = -N/2:N/2-1; width = 8; x = width*k/N; idy = find(x==0); y = out(:,idy); idx = find(abs(x)<2); yt = somb(w*x).^2; subplot(2,1,1); plot(x,y,x,yt); title(str); subplot(2,1,2); semilogy(x,y,x,yt); xlabel('cross-section x');
w = 0.5;
xs = 2;
fprintf('shift %g',-xs);
func = @(x,y) cyl(x+xs,y,w);
fourier2(func);
shift -2
w = 2; xi = 2; func = @(x,y) cyl(x,y,w).*exp(j*2*pi*xi*x); fourier2(func);
w = 0.5; xs = 1; func = @(x,y) cyl(x+xs,y,w)+cyl(x-xs,y,w); out = fourier2(func); imshow(out);
w = 0.5; xs = 0.5; func = @(x,y) cyl(x+xs,y,w)+cyl(x-xs,y,w); out = fourier2(func); imshow(out);
w = 0.5; xs = 1.0; func1 = @(x,y) cyl(x+xs,y,w)+cyl(x-xs,y,w); func2 = @(x,y) rect(x+xs,w).*rect(y,w)+rect(x-xs,w).*rect(y,w); [out1 in1] = fourier2(func1); [out2 in2] = fourier2(func2); subplot(2,3,1); imshow(in1); subplot(2,3,2); imshow(out1); subplot(2,3,3); imshow(logim(out1,3)); subplot(2,3,4); imshow(in2); subplot(2,3,5); imshow(out2); subplot(2,3,6); imshow(logim(out2,3));
global n;
n = 1;
fourier(@func3);
n = 2; fourier(@func3);
原文地址:http://www.johnloomis.org/eop513/notes/optics5/script5.html
下面这两张是我计算的加了个colormap(hot) 顿时赶脚高大上了