forked from guchengxi1994/mask2json
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_imgAug.py
89 lines (58 loc) · 2.23 KB
/
test_imgAug.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
'''
@lanhuage: python
@Descripttion: image augmentation with labels.
@version: beta
@Author: xiaoshuyui
@Date: 2020-07-17 15:49:30
LastEditors: xiaoshuyui
LastEditTime: 2020-10-20 09:40:34
'''
import sys
sys.path.append("..")
from convertmask.utils.imgAug import imgFlip, imgNoise, imgRotation, imgTranslation, aug_labelme, aug_labelimg, imgZoom
import os
from skimage import io
from convertmask.utils.getMultiShapes import getMultiShapes
BASE_DIR = os.path.abspath(os.path.dirname(os.getcwd())) + os.sep + 'static'
# print(BASE_DIR)
imgPath = BASE_DIR + os.sep + 'multi_objs.jpg'
labelPath = BASE_DIR + os.sep + 'multi_objs.json'
imgPath2 = BASE_DIR + os.sep + 'label_255.png'
labelPath2 = BASE_DIR + os.sep + 'label_255.xml'
if __name__ == "__main__":
#### test1
# imgFlip(imgPath, labelPath)
# imgNoise(imgPath,labelPath)
# imgRotation(imgPath,labelPath)
# imgTranslation(imgPath,labelPath)
#### test2
# n = imgNoise(imgPath,labelPath,flag=False)
# tmp = n['noise']
# img , processedImg = tmp.oriImg , tmp.processedImg
# r = imgRotation(img,processedImg,flag=False,angle=15)
# tmp = r['rotation']
# img , processedImg = tmp.oriImg , tmp.processedImg
# t = imgTranslation(img,processedImg,flag=False)
# tmp = t['trans']
# img , processedImg = tmp.oriImg , tmp.processedImg
# f = imgFlip(img,processedImg,flag=False)
# tmp = f['h_v']
# img , processedImg = tmp.oriImg , tmp.processedImg
# parent_path = os.path.dirname(imgPath)
# if os.path.exists(parent_path+os.sep+'jsons_'):
# pass
# else:
# os.makedirs(parent_path+os.sep+'jsons_')
# fileName = 'test'
# io.imsave(parent_path+os.sep+'jsons_'+os.sep+fileName+'_assumble.jpg',img)
# assumbleJson = getMultiShapes(parent_path+os.sep+'jsons_'+os.sep+fileName+'_assumble.jpg',processedImg,flag=True,labelYamlPath='')
# saveJsonPath = parent_path+os.sep+'jsons_'+os.sep+fileName+'_assumble.json'
# with open(saveJsonPath,'w') as f:
# f.write(assumbleJson)
#### test3
# aug_labelme(imgPath,labelPath)
#### test4
# aug_labelimg(imgPath2, labelPath2)
#### test5
imgZoom(imgPath, labelPath, 1.2)
# io.imsave(BASE_DIR + os.sep + 'test_zoom.jpg', i)