-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathfactor.py
More file actions
34 lines (28 loc) · 840 Bytes
/
factor.py
File metadata and controls
34 lines (28 loc) · 840 Bytes
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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Aug 9 15:56:12 2019
@author: jihyeonje
"""
from read_config import read_cfg
def factor(strength, i=0):
if strength.isdigit():
power = [int(strength)] * 10
else:
power = read_cfg(strength)
factor_choices = {
0: 0,
1: 1.25 + 0.25 * power[0], # HighContrast
2: 0.95 - 0.05 * power[1], # LosContrast
3: power[2], # Blur
4: 0.125 + 0.125 * power[3], # Sharpen
5: 0.05 + 0.015 * power[4], # UniformNoise
6: 0.1 * power[5], # TV_Chambolle
7: 261 - 5 * power[6], # HistogramEqualization
8: power[7], # Skew
9: 27 - power[8] # ElasticDistortion
}
if strength == '0':
return factor_choices.get(0)
else:
return factor_choices.get(i)