반응형
import cv2
import os
import numpy as np
from PIL import Image
path = 'Ferdata\\test\\angry'
imagePaths = [os.path.join(path,file_name) for file_name in os.listdir(path)]
for imagePath in imagePaths:
img = Image.open(imagePath).convert('L')
img_numpy = np.array(img, 'uint8')
cv2.imwrite("Ferdata\\" + imagePath.split("\\")[-1], img_numpy)
#저장 위치
print("All Done")
반응형
'컴퓨터 > 파이썬 (Python)' 카테고리의 다른 글
[Python] wav 파일 자르기 (0) | 2023.03.21 |
---|---|
[Python] wav 파일 Speech-to-Text 파이썬 코드 (0) | 2023.03.21 |
[Python] image to csv (0) | 2022.05.18 |
[Python, 머신러닝] Confusion Matrix 그리기 (0) | 2022.03.23 |
[Python] 파일명 지정 (0) | 2021.10.26 |