-
Notifications
You must be signed in to change notification settings - Fork 4
/
example_numericalPropagation.py
99 lines (74 loc) · 3.22 KB
/
example_numericalPropagation.py
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
"""
Title--> Numerical propagation examples.
Author--> Ana Doblas, Carlos Trujillo, Raul Castaneda,
Date--> 05/09/2022
University of Memphis
Optical Imaging Research lab (OIRL)
EAFIT University
Applied Optics Group
Abstract --> Script that implements the different methods to propagate the resulting complex field data
Links--> - https://github.com/catrujilla/pyDHM
"""
from pyDHM import utilities
from pyDHM import numericalPropagation
import numpy as np
# Angular spectrum
print ("Angular spectrum example")
# Load the input plane
#inp = utilities.imageRead('data/numericalPropagation samples/UofM-1-inv.jpg')
inp = utilities.imageRead('data/numericalPropagation samples/+3cm.tif')
utilities.imageShow(inp, 'input field')
# FT of the hologram
#ft_holo = utilities.FT(inp)
#ft_holo = utilities.intensity(ft_holo, True)
#utilities.imageShow(ft_holo, 'FT hologram')
# Spatial filter
filter = utilities.sfmr(inp, True)
# Numerical propagation using the angular spectrum
output = numericalPropagation.angularSpectrum(filter, 70000, 0.633, 6.9, 6.9)
# Display the output field
intensity = utilities.intensity(output, False)
utilities.imageShow(intensity, 'focused output field')
for z in range(-100, 80, 10):
# Warning: Depending on the propagation distance step, this cycle can takke too much time.
# Numerical propagation using the angular spectrum
output = numericalPropagation.angularSpectrum(filter, z, 0.000633, 0.0069, 0.0069)
# Display the output field
intensity = utilities.intensity(output, False)
utilities.imageShow(intensity, 'output field ' + str(z))
print ("Fresnel transform example")
# Fresnel transform and speckle reduction via HM2F
# Load the input plane
inp = utilities.imageRead('data/numericalPropagation samples/horse.bmp')
utilities.imageShow(inp, 'input field')
# FT of the hologram
#ft_holo = utilities.FT(inp)
#ft_holo = utilities.intensity(ft_holo, True)
#utilities.imageShow(ft_holo, 'FT hologram')
# Spatial filter
filter = utilities.sfmr(inp, True)
# Numerical propagation using the Fresnel transforms
output = numericalPropagation.fresnel(filter, -450, 0.000633, 0.005000, 0.005000)
# Display the output field
amplitude = utilities.amplitude(output, False)
utilities.imageShow(amplitude, 'output field')
# HM2F to reduce the speckle
denoise = utilities.HM2F(amplitude, 7, False, False)
#amplitude = utilities.amplitude(denoise, False)
utilities.imageShow(amplitude, 'output field denoised')
# Fresnel-Bluestein transform
print ("Fresnel-Bluestein transform example")
# Load the input plane
inp = utilities.imageRead('data/numericalPropagation samples/die_1.jpg')
utilities.imageShow(inp, 'input field')
# FT of the hologram
#ft_holo = utilities.FT(inp)
#ft_holo = utilities.intensity(ft_holo, True)
#utilities.imageShow(ft_holo, 'FT hologram')
# Spatial filter
filter = utilities.sfmr(inp, False)
# Numerical propagation using the Fresnel transforms
output = numericalPropagation.bluestein(filter - np.average(filter), 30/100, 632.8e-9, 7e-6, 7e-6, 4.5e-5, 4.5e-5)
# Display the output field
amplitude = utilities.amplitude(output, False)
utilities.imageShow(amplitude, 'output field')