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

addign a parameter sample name to facilitate file writing

parent dd25545d
......@@ -9,10 +9,10 @@ import tifffile
import numpy as np
import math
def cut_image_with_covering_zones(image_name, path, section_size, covering_size, starting_slice = 0):
def cut_image_with_covering_zones(image_name, sample_name, path_read, path_save, section_size, covering_size, starting_slice = 0):
# reading image
print('Reading image ', image_name, '...')
chdir(path)
chdir(path_read)
image = tifffile.imread(image_name)
length = len(image)
num_sections = math.ceil((length-starting_slice)/section_size)
......@@ -31,14 +31,17 @@ def cut_image_with_covering_zones(image_name, path, section_size, covering_size,
start = start_indexes[i]
end = end_indexes[i]
section = image[start: end]
output_name = image_name.replace('.tif',"") + '_section_{}.tif'.format(i)
output_name = sample_name + '_section_{}.tif'.format(i)
chdir(path_save)
tifffile.imsave(output_name, section)
def main():
image_name = 'Segm.tif'
path = '/home/german.martinez-carvajal/Bureau/Tests_covering_cut_fusion'
image_name = 'Image_Filtered.tif'
sample_name = 'MONxx'
path_read = '/home/german.martinez-carvajal/Bureau/These/Hashemi_segmentation/Tests/Test9_Rapide'
path_save = path_read
section_size = 2
covering_size = 1
starting_slice = 3
cut_image_with_covering_zones(image_name, path, section_size, covering_size, starting_slice)
cut_image_with_covering_zones(image_name, sample_name, path_read, path_save, section_size, covering_size, starting_slice)
main()
\ No newline at end of file
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