-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcolormaps.py
42 lines (38 loc) · 1.1 KB
/
colormaps.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
import numpy as np
def greyscale():
colors = np.zeros((256,3))
for i in range(colors.shape[0]):
colors[i][0] = i
colors[i][1] = i
colors[i][2] = i
#colors[i][3] = i
return colors.astype('uint8')
def redscale():
colors = np.zeros((256,4))
for i in range(colors.shape[0]):
val = i / 16.
val *= val
val += 100.
val = min(val, 255.)
logval = 255 * (np.log(i+1) / np.log(256))
logval = min(255., logval)
logval = max(0., logval)
colors[i][0] = logval
colors[i][1] = 255
colors[i][2] = val
colors[i][3] = 0
return colors.astype('uint8')
def reverse_greenscale():
colors = np.zeros((256,4))
for i in range(colors.shape[0]):
val = i / 16.
val *= val
val = min(255., val)
logval = 255 * (np.log(i+1) / np.log(256))
logval = min(255., logval)
logval = max(0., logval)
colors[i][0] = (255 - val)
colors[i][1] = 128 - logval/2
colors[i][2] = 255
colors[i][3] = 0
return colors.astype('uint8')