I'm trying to write a very simple code for the reconstruction of an in-line hologram of particles in a micro channel (digital holographic microscopy), but I'm getting some results that are hard for me to understand.
clear;
lambda = 632.8e-9/1.333; %wavelength
pix_size = 7.4e-6; %camera's pixel size
dx = pix_size;
dy = pix_size;
hologram = imread([file_path file_name]);
N = size(hologram);
tukey_win = tukeywin(N(1),0.075); %tukey window
% multiply image (single precision) with the tukey window to darken edges
trimmed_holo = single(hologram) .* (tukey_win * tukey_win');
prop_distance = 0.01:0.005:0.2; % propagation distances vector
fft_hologram = fft2(trimmed_holo); %Fourier transform of hologram
fft_shifted_hologram = fftshift(fft_hologram); %Fourier shift of hologram
for k = 1:length(prop_distance) % do multiple propagation distances
% obtain transfer function
G = trans_func(lambda, N(1), dx, dy, prop_distance(k));
%multiply FT of impulse response times FT of hologram
psi = G .* fft_shifted_hologram;
% get slice of reconstructed optical field through inverse FT
recon_image = ifftshift(ifft2(psi));
%write image to file
imwrite(uint8(abs(recon_image)), [file_path_save 'out' num2str(k,'%2.2d') '.tif']);
end
function G = trans_func(lambda, N, Delta_xi, Delta_eta, z)
M = N;
[m, n] = meshgrid(-N/2:N/2-1,-M/2:M/2-1);
first_term = (lambda^2 * (n + (N^2 * Delta_xi^2) ./ (2 * z * lambda)).^2) ...
./ (N^2 * Delta_xi^2);
second_term = (lambda^2 * (m + (M^2 * Delta_eta^2) ./ (2 * z * lambda)).^2) ...
./ (M^2 * Delta_eta^2);
arg_root = 1 - first_term - second_term;
arg_root(arg_root<0) = 0;
G = exp(-2*pi*1i*z/lambda * sqrt(arg_root));
The actual reconstruction appears to be correct, but I am getting a circular shift that varies with the reconstruction (propagation distance).
Here's the original hologram:
Here's z = 0.01, which (just) looks like I missed the ifftshift():
The circular shift keeps getting smaller, and by the last propagation distance (z = 0.2) it is practically gone:
I've looked at the code for quite some time and can't figure out what's causing the circular shift, so I would greatly appreciate it if anyone could explain to me what is causing/how to correct it. Thanks.