forked from 12dmodel/deep_motion_mag
-
Notifications
You must be signed in to change notification settings - Fork 1
/
convert_saturate.py
58 lines (37 loc) · 1.18 KB
/
convert_saturate.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
import cv2
import os
from PIL import ImageEnhance
from PIL import Image
def frame_saturate(frame):
'''
Saturate current frame
'''
converter = ImageEnhance.Color(frame)
Im_sat = converter.enhance(2.0)
return Im_sat
################# main script
def main():
# path to folder with frames to convert
#video = 'guitar'
video = 'juguete-turbio'
path = 'data/vids/'+video+'/'
# path to folder with grayscale frames
output_path = 'data/vids/'+video+'/sat/'
# Check whether the specified path exists or not
isExist = os.path.exists(output_path)
if not isExist:
# Create a new directory because it does not exist
os.makedirs(output_path)
print("Saturated frames will be stored in "+output_path)
count = 0
namelist = sorted(os.listdir(path))
for filename in namelist:
if filename.endswith(".png"):
count += 1
frame = Image.open(path+filename)
if frame is not None:
sat_frame = frame_saturate(frame)
name = output_path + '%04d.png' % (count)
sat_frame.save(name)
if __name__ == "__main__":
main()