Doarchive

[Python] 1채널 이미지를 3채널로 바꾸기 1Channel Image convert to 3 Channel Image 본문

Computer Vision/ImageProcessing

[Python] 1채널 이미지를 3채널로 바꾸기 1Channel Image convert to 3 Channel Image

오순발닦개 2022. 12. 21. 16:26
import cv2
import numpy as np 
import os


src = cv2.imread(filepath)
1ch_img= cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

3ch_img = np.zeros_like(src)
3ch_img[:,:,0] = 1ch_img
3ch_img[:,:,1] = 1ch_img
3ch_img[:,:,2] = 1ch_img

cv2.imwrite(filepath, 3ch_img)

 

728x90