in flow_color.py [0:0]
def computeColor(u, v):
colorwheel = makeColorwheel();
nan_u = np.isnan(u)
nan_v = np.isnan(v)
nan_u = np.where(nan_u)
nan_v = np.where(nan_v)
u[nan_u] = 0
u[nan_v] = 0
v[nan_u] = 0
v[nan_v] = 0
ncols = colorwheel.shape[0]
radius = np.sqrt(u**2 + v**2)
a = np.arctan2(-v, -u) / np.pi
fk = (a+1) /2 * (ncols-1) # -1~1 maped to 1~ncols
k0 = fk.astype(np.uint8) # 1, 2, ..., ncols
k1 = k0+1;
k1[k1 == ncols] = 0
f = fk - k0
img = np.empty([k1.shape[0], k1.shape[1],3])
ncolors = colorwheel.shape[1]
for i in range(ncolors):
tmp = colorwheel[:,i]
col0 = tmp[k0]/255
col1 = tmp[k1]/255
col = (1-f)*col0 + f*col1
idx = radius <= 1
col[idx] = 1 - radius[idx]*(1-col[idx]) # increase saturation with radius
col[~idx] *= 0.75 # out of range
img[:,:,2-i] = np.floor(255*col).astype(np.uint8)
return img.astype(np.uint8)