balthou commited on
Commit
0ddc74f
·
1 Parent(s): fd96015

add vibrance tuning

Browse files
Files changed (1) hide show
  1. app.py +22 -8
app.py CHANGED
@@ -73,12 +73,26 @@ def tone_map(
73
  return hsv
74
 
75
 
76
- @interactive(vibrance=(0, [0, 100]))
77
- def modify_vibrance(hsv_in, vibrance: float = 0.):
78
- gain_luma = np.interp(hsv_in[..., 2], [0., 0.5, 1.], [0., 0., 1.])
79
- gain_sat = np.interp(hsv_in[..., 1], [0., 0.5, 1.], [0., 0., 1.])**2
80
- red_thresh = 30.
81
- pink_thresh = 8.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
  overlap = 10.
83
 
84
  gain_hue = np.interp(
@@ -86,8 +100,8 @@ def modify_vibrance(hsv_in, vibrance: float = 0.):
86
  [0., red_thresh, red_thresh+overlap,
87
  360-pink_thresh-overlap, 360-pink_thresh, 360],
88
  [0., 0., 1., 1., 0., 0.]
89
- )**2
90
- gain = 1. + gain_luma * gain_sat * gain_hue*(vibrance / 100)
91
  hsv_in[..., 1] = np.clip(gain*hsv_in[..., 1], 0, 1)
92
  return hsv_in
93
 
 
73
  return hsv
74
 
75
 
76
+ @interactive(
77
+ vibrance=(0, [0, 100]),
78
+ # vibrance_mask_smoothness=(3., [-0.9, 4.])
79
+ )
80
+ def modify_vibrance(
81
+ hsv_in: np.ndarray,
82
+ vibrance: float = 0.,
83
+ vibrance_mask_smoothness: float = 3.
84
+ ) -> np.ndarray:
85
+ gain_luma = np.interp(
86
+ hsv_in[..., 2],
87
+ [0., 0.5, 1.],
88
+ [0., 0., 1.]
89
+ )
90
+ gain_sat = np.interp(hsv_in[..., 1],
91
+ [0., 0.25, 1.],
92
+ [0., 0., 1.]
93
+ )**(1+vibrance_mask_smoothness)
94
+ red_thresh = 55.
95
+ pink_thresh = 10.
96
  overlap = 10.
97
 
98
  gain_hue = np.interp(
 
100
  [0., red_thresh, red_thresh+overlap,
101
  360-pink_thresh-overlap, 360-pink_thresh, 360],
102
  [0., 0., 1., 1., 0., 0.]
103
+ )**(1+vibrance_mask_smoothness)
104
+ gain = 1. + gain_luma * (gain_sat + gain_hue).clip(0., 1.)*(vibrance / 100)
105
  hsv_in[..., 1] = np.clip(gain*hsv_in[..., 1], 0, 1)
106
  return hsv_in
107