-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathDefDataPackages.py
58 lines (46 loc) · 1.73 KB
/
DefDataPackages.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
50
51
52
53
54
55
56
57
58
# -> Defines size of datapackages used for augmentation of image data
# Input: Image folder and output directory to store de_augmentation file
# Output: de_augmentation_info.mat
#
# Syntax : def_datapackages /ImageData/EMdata1/ /ImageData/AugmentedEMData/
#
#
# ----------------------------------------------------------------------------------------
# PreProcessImageData for CDeep3M -- NCMIR/NBCR, UCSD -- Author:
# ---------------------------------------------------------------------------------------
#
import sys
import os
import json
from check_image_size import check_image_size
from break_large_img import break_large_img
def main():
arg_list = []
for arg in sys.argv:
arg_list.append(arg)
if len(arg_list) < 2:
print(
'Use -> PreProcessImageData /ImageData/EMdata1/ /ImageData/AugmentedEMData/')
return
in_img_path = arg_list[1]
outdir = arg_list[2]
if os.path.isdir(outdir) == 0:
os.mkdir(outdir)
imagesize = check_image_size(in_img_path)
packages, z_blocks = break_large_img(imagesize)
num_of_pkg = len(packages)
json_dump = {}
json_dump['packages'] = packages
json_dump['num_of_pkg'] = num_of_pkg
json_dump['imagesize'] = imagesize
json_dump['z_blocks'] = z_blocks
with open(os.path.join(outdir, 'de_augmentation_info.json'), 'w') as json_file:
json.dump(json_dump, json_file)
with open(os.path.join(outdir, 'package_processing_info.txt'), 'w') as document:
document.write('\nNumber of XY Packages\n')
document.write(str(num_of_pkg))
document.write('\nNumber of z-blocks\n')
document.write(str(len(z_blocks) - 1))
if __name__ == "__main__":
print('Starting Image Augmentation:')
main()