-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtransfer.py
37 lines (27 loc) · 923 Bytes
/
transfer.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
import czifile
from skimage import io
import numpy as np
import matplotlib.pyplot as plt
import SimpleITK as sitk
from mpl_toolkits.axes_grid1 import make_axes_locatable
from scipy import ndimage, misc
# Start layer
layer = 2
name = '5'
img = czifile.imread(name+'.czi')
img = np.squeeze(img)
labelimg = img[0,layer:,:,:]
resultlist = np.empty([0,2208,2752])
for i in range(labelimg.shape[0]):
result = ndimage.uniform_filter(labelimg[i,:,:], size=44, mode='constant')
print(np.max(result),np.min(result))
resultlist = np.append(resultlist, np.expand_dims(result,axis=0), axis=0)
print(resultlist.shape)
# np.save(name+".npy", img[0,:,:,:])
np.savetxt("avinten.txt", resultlist.reshape(1,-1), fmt='%1.1f')
# Transfer to vtk for segmentation
filtered_image = sitk.GetImageFromArray(img[1,layer:,:,:])
sitk.WriteImage(filtered_image, name+".vtk")
plt.imshow(resultlist[0,:,:])
plt.colorbar()
plt.show()