forked from TomTranter/JellyBaMM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsegment_jelly_roll.py
49 lines (40 loc) · 1.34 KB
/
segment_jelly_roll.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
# -*- coding: utf-8 -*-
"""
Created on Wed Oct 28 10:31:07 2020
@author: Tom
"""
import ecm
import matplotlib.pyplot as plt
import numpy as np
import os
import skimage
import openpnm as op
print('ECM version', ecm.__version__)
print('skimage version', skimage.__version__)
wrk = op.Workspace()
print(wrk)
plt.close('all')
os.listdir(ecm.INPUT_DIR)
# Return the average of the input images, the mid-half-span and a distance
# transform of the image with centre = 0 to act as radial map
im, mhs, dt = ecm.average_images()
plt.figure()
plt.imshow(im)
step = 1 # step to take when binning for averaging
deg = 6 # degree of polynomial fitting when fitting intensity profile
im_soft = ecm.remove_beam_hardening(im, dt, step, deg)
# Label Layers
im_soft, cc_im = ecm.label_layers(im_soft, dt, mhs,
can_width=30,
im_thresh=19000,
small_feature_size=20000)
np.sum(im_soft[~np.isnan(im_soft)])
np.sum(~np.isnan(im_soft))
np.savez(os.path.join(ecm.INPUT_DIR, 'im_soft'), im_soft)
np.savez(os.path.join(ecm.INPUT_DIR, 'cc_im'), cc_im)
# Make the spider web network
net = ecm.spider_web_network(im_soft, mhs, cc_im, dtheta=10)
ecm.plot_topology(net)
prj = net.project
im_spm_map = ecm.interpolate_spm_number(prj)
np.savez(os.path.join(ecm.INPUT_DIR, 'im_spm_map'), im_spm_map)