-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreconstruction.m
More file actions
32 lines (27 loc) · 1.29 KB
/
Copy pathreconstruction.m
File metadata and controls
32 lines (27 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
% DHM Reconstruction using Angular Spectrum Method
clc; clear; close all;
% Parameters
lambda = 632.8e-9; % Wavelength (in meters, e.g., 632.8 nm for He-Ne laser)
pixel_size = 6.45e-6; % Pixel size (in meters, e.g., 6.45 µm)
z = 0.01; % Reconstruction distance (in meters, e.g., 10 mm)
% Load hologram
hologram = imread('OH WL 20 18Nov25_00009.tif'); % Replace with your hologram file
hologram = double(hologram) / 255; % Normalize intensity (if grayscale)
% Dimensions
[M, N] = size(hologram);
kx = (-N/2:N/2-1) / (N * pixel_size); % Spatial frequency in x
ky = (-M/2:M/2-1) / (M * pixel_size); % Spatial frequency in y
[KX, KY] = meshgrid(kx, ky);
k = 2 * pi / lambda; % Wave number
% Angular spectrum propagation
H = fftshift(fft2(hologram)); % Fourier transform of hologram
propagation_kernel = exp(1i * z * sqrt(k^2 - (2 * pi * KX).^2 - (2 * pi * KY).^2));
propagation_kernel(abs(KX) > 1/lambda | abs(KY) > 1/lambda) = 0; % Avoid evanescent waves
reconstructed_field = ifft2(ifftshift(H .* propagation_kernel));
% Visualization
figure;
subplot(1, 2, 1);
imshow(hologram, []); title('Original Hologram');
subplot(1, 2, 2);
%imshow(abs(reconstructed_field), []); title('Reconstructed Amplitude');
imshow(0.0000001*(abs(reconstructed_field)), []); title('Reconstructed Amplitude');