czyoung commited on
Commit
d97e211
·
verified ·
1 Parent(s): ac958ee

Added CSS color generator

Browse files
Files changed (1) hide show
  1. sonogram_utility.py +20 -0
sonogram_utility.py CHANGED
@@ -25,6 +25,26 @@ def colors(n):
25
  ret.append((bgr[0][0][0].item()/255,bgr[0][0][1].item()/255,bgr[0][0][2].item()/255))
26
  return ret
27
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  def extendSpeakers(mySpeakerList, fileLabel = 'NONE', maximumSecondDifference = 1, minimumSecondDuration = 0):
29
  '''
30
  Assumes mySpeakerList is already split into Speaker/Audience
 
25
  ret.append((bgr[0][0][0].item()/255,bgr[0][0][1].item()/255,bgr[0][0][2].item()/255))
26
  return ret
27
 
28
+ def colorsCSS(n):
29
+ '''
30
+ Creates a list size n of distinctive colors based on CSS formatting
31
+ '''
32
+ if n == 0:
33
+ return []
34
+ ret = []
35
+ h = int(random.random() * 180)
36
+ step = 180 / n
37
+ for i in range(n):
38
+ h += step
39
+ h = int(h) % 180
40
+ hsv = np.uint8([[[h,200,200]]])
41
+ bgr = cv2.cvtColor(hsv,cv2.COLOR_HSV2BGR)
42
+ b = f'{bgr[0][0][0].item():02x}'
43
+ g = f'{bgr[0][0][1].item():02x}'
44
+ r = f'{bgr[0][0][2].item():02x}'
45
+ ret.append('#'+b+g+r)
46
+ return ret
47
+
48
  def extendSpeakers(mySpeakerList, fileLabel = 'NONE', maximumSecondDifference = 1, minimumSecondDuration = 0):
49
  '''
50
  Assumes mySpeakerList is already split into Speaker/Audience