只是为了好玩,如果有人想要 Python OpenCV 版本,我做了一个这样的:
#!/usr/bin/env python3
import cv2
import numpy as np
# Set size of output image
h, w = 500, 500
# Create "L" channel, L=90
L = np.full((h,w), 90.00, np.float32)
# Create "a" channel, -80 to +80
a = np.linspace(-80,80,w,endpoint=True,dtype=np.float32)
a = np.resize(a,(h,w))
# Create "b" channel by rotating "a" channel 90 degrees
b = cv2.rotate(a, cv2.ROTATE_90_COUNTERCLOCKWISE)
# Stack the 3-channels into single image and convert from Lab to BGR
res = np.dstack((L,a,b))
res = cv2.cvtColor(res, cv2.COLOR_LAB2BGR)
# Save result
cv2.imwrite('result.png', (res*65535).astype(np.uint16))