-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbubbles_initial_testing.py
92 lines (73 loc) · 2.75 KB
/
bubbles_initial_testing.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
from skimage import io
import matplotlib.pyplot as pl
import scipy.fftpack as fftim
import numpy as np
from sklearn.preprocessing import MinMaxScaler
def radial_profile(data, centre):
y, x = np.indices((data.shape))
r = np.sqrt((x-centre[0])**2+(y-centre[1])**2)
r = r.astype(np.int)
tbin = np.bincount(r.ravel(), data.ravel())
nr = np.bincount(r.ravel())
radialprofile = tbin/nr
return radialprofile
def correlate(x, y):
fr = fftim.fft2(x)
fr2 = fftim.fft2(np.flipud(np.fliplr(y)))
m, n = fr.shape
cc = np.real(fftim.ifft2(fr*fr2))
cc = np.roll(cc, int(-m/2+1), axis=0)
cc = np.roll(cc, int(-n/2+1), axis=1)
return cc
test_file = '/Users/s1101153/OneDrive - University of Edinburgh/Files/bubbles/confocal_data/1280um/sample70/Image81.lsm'
test_im = io.imread(test_file)
io.imshow(test_im[0])
io.imshow(test_im[1])
test_a = test_im[0]
test_a[:100, :300].shape
io.imshow(test_a[:100, :300])
n_x = 4
n_y = 4
size_x = int(test_a.shape[1]/n_x)
size_y = int(test_a.shape[0]//n_y)
size_x
scaler = MinMaxScaler()
half_size = int(size_x/2)
im_list = []
for i in range(n_x):
for j in range(n_y):
im_tile = test_a[i*size_y:(i+1)*size_y, j*size_x:(j+1)*size_y]
im_tile = scaler.fit_transform(im_tile)
im_list.append(im_tile)
io.imshow(im_tile)
pl.title('Image ('+str(i)+', '+str(j)+')')
pl.savefig('Image'+str(i)+'-'+str(j))
pl.show()
b = im_tile
ac3 = correlate(b, b)
autoCorr = radial_profile(ac3,
(b.shape[0]/2,
b.shape[1]/2
)
)[:256]/radial_profile(ac3,
(b.shape[0]/2.,
b.shape[1]/2.
)
)[:half_size][0]
radProf = radial_profile(b,
(b.shape[0]/2,
b.shape[1]/2
)
)[:256]/radial_profile(b,
(b.shape[0]/2.,
b.shape[1]/2.
)
)[:half_size][0]
pl.plot(autoCorr)
pl.title('autoCorr ('+str(i)+', '+str(j)+')')
pl.savefig('autoCorr'+str(i)+'-'+str(j))
pl.show()
pl.plot(radProf)
pl.title('radProf ('+str(i)+', '+str(j)+')')
pl.savefig('radProf'+str(i)+'-'+str(j))
pl.show()