-
Notifications
You must be signed in to change notification settings - Fork 2
/
fpp_test.py
52 lines (39 loc) · 1.83 KB
/
fpp_test.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
#!/usr/bin/env python
from numpy import *
import matplotlib.pyplot as plt
from imageio import imread, imsave
from glob import glob
import fpp_tools as fpp
if __name__ == '__main__':
files = sort(glob('./figures/lens_crop*.jpg'))
#files = sort(glob('./figures/fringe_phi*.png'))
## Make a list of the images to use, and then convert the list into a Numpy array 3D image stack.
imagestack = []
for file in files:
imagestack.append(float32(imread(file)))
imagestack = dstack(imagestack)
(Nx,Ny,num_images) = imagestack.shape
print('imagestack shape =', imagestack.shape)
deltas = array([0.0, pi/2.0, pi, 3.0*pi/2.0])
#(phi4_image, contrast4_image, bias4_image) = fpp.estimate_phi_4_uniform_frames(imagestack)
#(phi_imageN, contrast_imageN, bias_imageN) = fpp.estimate_phi_N_uniform_frames(imagestack)
#(phi_image) = fpp.estimate_phi_4_nonuniform_frames(imagestack, deltas)
(phi_image) = fpp.estimate_phi_N_nonuniform_frames(imagestack, deltas)
#(phi_image, contrast_image, bias_image, deltas) = fpp.estimate_phi_estimate_deltas_and_phi(imagestack)
deltas -= deltas[0]
print(f"est. deltas [deg] = {array2string(deltas*180.0/pi, formatter={'float': lambda x:f'{x:.2f}'}, separator=', ')}")
plt.figure('img0')
plt.imshow(imagestack[:,:,0])
plt.figure('phi')
plt.imshow(phi_image)
## In the unwrapped phase image, make sure that the smallest phase is zero. If the phase is increasing, then we subtract the
## smallest value. If decreasing, then we add the smallest value.
unwrapped_phi = unwrap(phi_image)
avg_gradient = mean(gradient(unwrapped_phi[:,Ny//2]))
if (avg_gradient > 0.0):
unwrapped_phi += amax(unwrapped_phi)
else:
unwrapped_phi -= amax(unwrapped_phi)
plt.figure('phi_unwrapped')
plt.imshow(unwrapped_phi)
plt.show()