def rotate_hue(image, hue_angle): hue_rad = math.radians(hue_angle) img_dkl = colour_spaces.rgb2dkl01(image) - 0.5 output = colour_spaces.dkl012rgb01(rotation(img_dkl, hue_rad) + 0.5, raw=True) if hue_angle == 90: minvs = [-0.15963513, -0.24257698, -0.61854306] maxvs = [+1.15951755, +1.24262220, +1.61844135] elif hue_angle == 270: minvs = [-0.90117482, 0.00000000, -0.17976814] maxvs = [+1.90109239, 1.00001458, +1.17986642] if hue_angle in [90, 270]: for i in range(3): output[:, :, i] = normalisations.min_max_normalise(output[:, :, i], minv=minvs[i], maxv=maxvs[i]) output = normalisations.clip01(output) return output
def hsv012rgb01(x): x = x.copy() x[:, :, 0] *= 360 x = cv2.cvtColor(x.astype('float32'), cv2.COLOR_HSV2RGB) return normalisations.clip01(x)
def dkl2rgb01(x, raw=False): x = np.dot(x, rgb_from_dkl) if raw: return x return normalisations.clip01(x)
def yog2rgb01(x): x = np.dot(x, rgb_from_yog) return normalisations.clip01(x)
def xyz2rgb01(x): x = np.dot(x, rgb_from_xyz) return normalisations.clip01(x)