-
Notifications
You must be signed in to change notification settings - Fork 0
/
colorEval.py
110 lines (90 loc) · 2.63 KB
/
colorEval.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import scipy.optimize as optimize
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d.axes3d import Axes3D
from pylab import *
import numpy as np
from matplotlib import cm
from refcolors import *
from color import *
fig = plt.figure()
ax = fig.gca(projection='3d')
X,Y,Z = [],[],[]
for x in range(len(baseColors)):
for y in range(len(colorSets[x])):
setC = color(colorSets[x][y]).hsv("h")
if setC > 180:
setC -= 360
X += [ color(colorSets[x][y]).hsv("h") ]
Y += [ enumeration[y] ]
specC = color(baseColors[x]).hsv("h")
if specC > 180:
specC -= 360
Z += [ specC - setC ]
p = ax.scatter(X,Y,Z,c="r")
plt.show()
A = np.array(zip(X, Y, Z))
def func(data, a, b, c, d, e, f, g, h):
return a*data[:,0]**3 +\
b*data[:,1]**3 +\
c*data[:,0]**2 +\
d*data[:,1]**2 +\
e*data[:,0]*data[:,1] +\
f*data[:,0] +\
g*data[:,1] +\
h
guess = (1,1,1,1,1,1,1,1)
params, pcov = optimize.curve_fit(func, A[:,:2], A[:,2], guess)
print "Hue"
print(params)
# # -------------------------------------
# fig = plt.figure()
# ax = fig.gca(projection='3d')
# X,Y,Z = [],[],[]
# for x in range(len(baseColors)):
# for y in range(len(colorSets[x])):
# X += [ color(colorSets[x][y]).hsv("h") ]
# Y += [ enumeration[y] ]
# Z += [ color(baseColors[x]).hsv("s") ]
# p = ax.scatter(X,Y,Z,c="g")
# plt.show()
# A = np.array(zip(X, Y, Z))
# def func(data, a, b, c, d, e, f, g, h):
# return a*data[:,0]**3 +\
# b*data[:,1]**3 +\
# c*data[:,0]**2 +\
# d*data[:,1]**2 +\
# e*data[:,0]*data[:,1] +\
# f*data[:,0] +\
# g*data[:,1] +\
# h
# guess = (1,1,1,1,1,1,1,1)
# params, pcov = optimize.curve_fit(func, A[:,:2], A[:,2], guess)
# print "Sat"
# print(params)
# fig = plt.figure()
# ax = fig.gca(projection='3d')
# X,Y,Z = [],[],[]
# for x in range(len(baseColors)):
# # print colorSets[x]
# for y in range(len(colorSets[x])):
# X += [ color(colorSets[x][y]).hsv("h") ]
# Y += [ enumeration[y] ]
# Z += [ color(baseColors[x]).hsv("v") ]
# p = ax.scatter(X,Y,Z,c="b")
# plt.show()
# A = np.array(zip(X, Y, Z))
# def func(data, a, b, c, d, e, f, g, h):
# return a*data[:,0]**3 +\
# b*data[:,1]**3 +\
# c*data[:,0]**2 +\
# d*data[:,1]**2 +\
# e*data[:,0]*data[:,1] +\
# f*data[:,0] +\
# g*data[:,1] +\
# h
# guess = (1,1,1,1,1,1,1,1)
# params, pcov = optimize.curve_fit(func, A[:,:2], A[:,2], guess)
# print "Val"
# print(params)
hue = linspace(0,360)
grd = linspace(50,900)