资源简介
全息投影的matlab算法,计算机生成全息图,CGH
代码片段和文件信息
% Table 3.1 OSH.m : m-file for illustrating optical scanning holography.
%------------------------------------------------------
% OSH.m
% Adapted from “Contemporary Optical Image Processing with MATLAB“
% by Ting-Chung Poon and Partha Banerjee Table 7.2
% Pages 222-223 Elsevier (2001).
clear all
%%Reading input bitmap file
I=imread(‘lena.jpg‘);
I=I(::1);
figure(1)%displaying input
colormap(gray(255));
image(I)
title(‘Original image‘)
axis off
pause
%%Creating OTFosh with SIGMA=z/2*k0 (Eq.(3.5-1a))
ROWS=512;
COLS=512;
sigma=2.0; %not necessary to scale
%kxky are spatial frequencies
ky=-12.8;
for r=1:COLS
kx=-12.8;
for c=1:ROWS
OTFosh(rc)=exp(-j*sigma*kx*kx-j*sigma*ky*ky);
kx=kx+.1;
end
ky=ky+.1;
end
max1=max(OTFosh);
max2=max(max1);
scale=1.0/max2;
OTFosh=OTFosh.*scale;
%Recording hologram
% Taking Fourier transform of I
FI=fft2(I);
FI=fftshift(FI);
max1=max(FI);
max2=max(max1);
scale=1.0/max2;
FI=FI.*scale;
% FH is the recorded hologram in Fourier domain
FH=FI.*OTFosh;
H=ifft2(FH);
max1=max(H);
max2=max(max1);
scale=1.0/max2
H=H.*scale;
figure(1)
colormap(gray(255));
%Displaying the real part becomes sine-FZP hologram
% Eq. (3.5-8a)
image(2.5*real(512*H));
title(‘Sine-FZP hologram
评论
共有 条评论