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

I prefer python (not jython) scripts to do that

parent c6037f4b
def Cut_in_sections(Folder,Name_Image, sections):
# Number of divisions
# You should set a number of sections to create images of no more than 1GB
from ij import IJ
from ij.io import FileSaver
# Opening Image as virtual stack
argument = "open=" + Folder + Name_Image
IJ.run("TIFF Virtual Stack...", argument);
# Getting number of slices
Imp = IJ.getImage()
Total_Slices = Imp.getNSlices()
for section in range(sections):
start = int(section /float(sections)*Total_Slices)+1
print('start',start)
end = int((section+1)/float(sections)*Total_Slices)
print('end', end)
argument = "title=section" + str(section) + '.tif' + " duplicate" + " range=" + str(start) + '-' + str(end)
IJ.run(Imp, "Duplicate...", argument)
Imp_section = IJ.getImage() # Points to imp the last image you have opened
fs = FileSaver(Imp_section)
filepath = Folder + "/Section" + str(section) + '.tif'
fs.saveAsTiff(filepath)
Imp_section.close()
print('ok')
Folder = '/home/german.martinez-carvajal/Desktop/Test_divide_in_sections'
Name_Image = '/Test_division.tif'
sections = 7
Cut_in_sections(Folder,Name_Image, sections)
\ 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