矩形弥散效果实现方案

https://github.com/loopeer/shadow

compile 'com.loopeer.lib:shadow:0.0.4-beta3'

% 参数设置 % 复色光参数(红、绿、蓝波长) lambdas = [620e-9, 550e-9, 480e-9]; % 单位:(m) theta = 10; % 微透镜阵列旋转角度 (度) theta_rad = deg2rad(theta); f1 = 0.1; % 成像透镜焦距 (m) fm = 0.005; % 微透镜焦距 (m) fc = 0.05; % 准直透镜焦距 (m) f3 = 0.05; % 第二个成像透镜焦距 (m) p_mla = 100e-6; % 微透镜阵列周期 (m) L = 5e-3; % 模拟区域大小 (m) N = 2048; % 采样点数 D = 5e-3; % 透镜圆形孔径直径 (5mm) % 生成坐标网格 dx = L / N; x = (-N/2:N/2-1) * dx; y = x; [X, Y] = meshgrid(x, y); % 透镜孔径 circ_aperture = @(D) sqrt(X.^2 + Y.^2) <= D/2; P = circ_aperture(D); % 光栅透过率函数 t(x0, y0) a = 5e-6; % 缝宽 (m) d = 10e-6; % 光栅周期 (m) L = 5e-3; % 光栅长度 (m) % 定义矩形函数 rect(x) rect = @(x, width) abs(x) <= width/2; % 定义周期性组合函数 comb(x) comb = @(x, period) sign(sin(pi * x / period)); % 初始化RGB强度矩阵 I_rgb = zeros(N, N, 3); % 各波长循环计算 for color_idx = 1:3 lambda = lambdas(color_idx); k = 2 * pi / lambda; % 1. 平行光入射 A = 1; % 2. 第一个成像透镜相位调制 % E_lens1 = A.* P.*exp(-1i * k/(2*f1) * (X.^2 + Y.^2)); % 3. 传播到后焦面 (夫琅禾费衍射) % E_focal = fftshift(fft2(ifftshift(E_lens1))) * dx^2 / (1i*lambda*f1); % 4. 旋转的微透镜阵列相位调制 x_rel = mod(X + p_mla/2, p_mla) - p_mla/2; y_rel = mod(Y + p_mla/2, p_mla) - p_mla/2; % 添加倾斜相位项(绕Y轴旋转) tilt_phase = exp(-1i * k * sin(theta_rad) * x_rel); ml_phase = exp(-1i * k/(2*fm) * (x_rel.^2 + y_rel.^2)) .* tilt_phase; E_mla = E_focal .* ml_phase; %%加一个菲涅尔衍射%% % E_mla1=fftshift(fft2(ifftshift(E_mla.*exp(1i*k*(x_rel.^2 + y_rel.^2)/(2*(fm+fc))))))* dx^2 *exp(1i*k*(X.^2 + Y.^2)/(2*(fm+fc)))*exp(1i*k*(fm+fc)) / (1i*lambda*(fm+fc)); E_mla1=fftshift(fft2(ifftshift(E_mla)))* dx^2 *exp(1i*k*(X.^2 + Y.^2)/(2*(fm+fc)))*exp(1i*k*(fm+fc)) / (1i*lambda*(fm+fc)); % 5. 准直透镜相位调制 collimator_phase = exp(-1i * k/(2*fc) * (X.^2 + Y.^2)); E_collimator = P.*E_mla1 .* collimator_phase; E_collimator1 = fftshift(fft2(ifftshift( E_collimator))) * dx^2 / (1i*lambda*fc); % 6. 光栅调制 t_x = rect(X, a) .* comb(X, d) .* rect(X, L); t_y = rect(Y, L); grating_transmission = t_x .* t_y; % 光栅调制 E_grating = E_collimator1 .* exp(1i * pi/2 * grating_transmission); % 7. 第二个成像透镜相位调制 E_lens2 = E_grating .* exp(-1i * k/(2*f3) * (X.^2 + Y.^2)); % 8. 传播到CCD (夫琅禾费衍射) E_ccd = fftshift(fft2(ifftshift(E_lens2))) * dx^2 / (1i*lambda*f3); I_rgb(:, :, color_idx) = abs(E_ccd).^2; end % 归一化并显示彩色图像 I_rgb_normalized = I_rgb / max(I_rgb(:)); figure; imagesc(x, y, I_rgb_normalized); axis image; xlabel('x (m)'); ylabel('y (m)'); title('CCD '); 请添加代码,作用为入射光为0-5度的平行光
最新发布
03-17
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值