-
Notifications
You must be signed in to change notification settings - Fork 0
/
alignholo.py
50 lines (46 loc) · 2.72 KB
/
alignholo.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
import numpy as np
def shift_holo(shift_gui, em_data):
# em_data.holo_2_aligned = shift(em_data.holo_2, shift_gui)
em_data.holo_2_aligned = np.roll(em_data.holo_2, shift_gui, axis=(0, 1))
def crop_phase(shift_gui, image_not_shifted, image_shifted):
print('shift image horizontal ', shift_gui[1])
print('shift gui vertical ', shift_gui[0])
if shift_gui[0] > 0:
if shift_gui[1] > 0:
image_not_shifted_crop = np.array(image_not_shifted[shift_gui[0]:, shift_gui[1]:])
image_shifted_crop = np.array(image_shifted[:-shift_gui[0], :-shift_gui[1]])
return [image_not_shifted_crop, image_shifted_crop]
if shift_gui[1] < 0:
image_not_shifted_crop = np.array(image_not_shifted[shift_gui[0]:, :shift_gui[1]])
image_shifted_crop = np.array(image_shifted[:-shift_gui[0], -shift_gui[1]:])
return [image_not_shifted_crop, image_shifted_crop]
if shift_gui[1] == 0:
image_not_shifted_crop = np.array(image_not_shifted[shift_gui[0]:, :])
image_shifted_crop = np.array(image_shifted[:-shift_gui[0], :])
return [image_not_shifted_crop, image_shifted_crop]
elif shift_gui[0] < 0:
if shift_gui[1] > 0:
image_not_shifted_crop = np.array(image_not_shifted[:shift_gui[0], shift_gui[1]:])
image_shifted_crop = np.array(image_shifted[-shift_gui[0]:, :-shift_gui[1]])
return [image_not_shifted_crop, image_shifted_crop]
if shift_gui[1] < 0:
image_not_shifted_crop = np.array(image_not_shifted[:shift_gui[0], :shift_gui[1]])
image_shifted_crop = np.array(image_shifted[-shift_gui[0]:, -shift_gui[1]:])
return [image_not_shifted_crop, image_shifted_crop]
if shift_gui[1] == 0:
image_not_shifted_crop = np.array(image_not_shifted[:shift_gui[0], :])
image_shifted_crop = np.array(image_shifted[-shift_gui[0]:, :])
return [image_not_shifted_crop, image_shifted_crop]
elif shift_gui[0] == 0:
if shift_gui[1] > 0:
image_not_shifted_crop = np.array(image_not_shifted[:, shift_gui[1]:])
image_shifted_crop = np.array(image_shifted[:, :-shift_gui[1]])
return [image_not_shifted_crop, image_shifted_crop]
if shift_gui[1] < 0:
image_not_shifted_crop = np.array(image_not_shifted[:, :shift_gui[1]])
image_shifted_crop = np.array(image_shifted[:, -shift_gui[1]:])
return [image_not_shifted_crop, image_shifted_crop]
if shift_gui[1] == 0:
image_not_shifted_crop = np.array(image_not_shifted[:, :])
image_shifted_crop = np.array(image_shifted[:, :])
return [image_not_shifted_crop, image_shifted_crop]