def lab_to_rgb(x, eps=1e-8):
"""Converts a lab image [0; 100] [-127; 128] [-128; 127] to a valid RGB image."""
x_rectified = np.array(x)
upper_bound = 200 * (x[..., 0] + 16.) / 116. - eps
x_rectified[..., 2] = np.clip(x_rectified[..., 2], - float('inf'), upper_bound)
return np.array([lab2rgb(y) * 255. for y in x_rectified]).astype(np.uint8)
评论列表
文章目录