更改灰度图片为三通道图片

img = np.array([[1, 2], [3, 4]])
stacked_img = np.stack((img,)*3, axis=-1)
print(stacked_img)

OR

import cv2 
import cv 
 
color_img = cv2.cvtColor(gray_img, cv.CV_GRAY2RGB) 

参考:
[1] https://stackoverflow.com/questions/40119743/convert-a-grayscale-image-to-a-3-channel-image
[2] https://www.quora.com/How-do-I-convert-a-grayscale-image-to-an-RGB-image-in-Python

posted @ 2023-04-12 13:26  xiaoxuxli  阅读(12)  评论(0编辑  收藏  举报