def rgb_array(self):
if self._rgb is None:
# Apply the standard biases
YUV = self.array.copy()
YUV[:, :, 0] = YUV[:, :, 0] - 16 # Offset Y by 16
YUV[:, :, 1:] = YUV[:, :, 1:] - 128 # Offset UV by 128
# YUV conversion matrix from ITU-R BT.601 version (SDTV)
# Y U V
M = np.array([[1.164, 0.000, 1.596], # R
[1.164, -0.392, -0.813], # G
[1.164, 2.017, 0.000]]) # B
# Calculate the dot product with the matrix to produce RGB output,
# clamp the results to byte range and convert to bytes
self._rgb = YUV.dot(M.T).clip(0, 255).astype(np.uint8)
return self._rgb
评论列表
文章目录