Commit f0c4b05f authored by Martinez-Carvajal German's avatar Martinez-Carvajal German
Browse files

faster final relabelling

parent d3f49ffe
......@@ -259,17 +259,42 @@ def connect_CR(path_read, file_top, file_bot, path_save, sample_name):
print("Final relabel...")
pores = np.sort(np.unique(connected_image))
ll = len(pores)
final_label = 0
for pore in pores:
progression = int((final_label/ll)*100)
ll_1 = len(pores)
print(ll_1)
print(pores)
for i in range(ll_1):
progression = int((i/ll_1)*100)
if progression % 2 == 0:
print("{}%".format(progression))
mask = (connected_image == pore)
connected_image[mask] = final_label
final_label +=1
new_label = i
if new_label in pores :
print("no need to relabel")
continue
else:
old_label = pores[i]
mask = (connected_image == old_label)
connected_image[mask] = new_label
#print("Pore {} has been relabeld to {}".format(old_label, new_label))
# final_label = 0
# for pore in pores:
#
# mask = (connected_image == pore)
# connected_image[mask] = final_label
# final_label +=1
pores = np.sort(np.unique(connected_image))
ll_2 = len(pores)
print(ll_2)
assert(ll_1==ll_2)
chdir(path_save)
tifffile.imsave("CR_{}.tif".format(sample_name) , connected_image)
tifffile.imsave("CR_{}.tif".format(sample_name) , connected_image)
print('Connection OK !')
path_read = "/home/german.martinez-carvajal/Bureau/These/Connecting_CR/test"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment