2020. 4. 23. 10:42ㆍCoding/Android Studio
#공통 import 목록
import cv2
import numpy as np
from PIL import Image,ImageEnhance
from matplotlib import pyplot as plt
openCV방식
img = cv2.imread("/home/ubuntu/dev/_dataset/dental/panorama/188.png")
print(type(img))
-> numpy.ndarray
openCV -> PIL
img = cv2.imread("/home/ubuntu/dev/_dataset/dental/panorama/188.png")
pil_image=Image.fromarray(cv2.cvtColor(img, cv2.COLOR_BGR2RGB))
print(type(pil_image))
-> PIL.Image.Image
PIL방식
img = Image.open("./188.png")
print(type(img))
-> PIL.PngImagePlugin.PngImageFile
PIL -> openCV
img = Image.open("./188.png")
numpy_image=np.array(img)
print(type(numpy_image))
-> numpy.ndarray
참고
https://stackoverflow.com/questions/43232813/convert-opencv-image-format-to-pil-image-format
'Coding > Android Studio' 카테고리의 다른 글
[scikit-image]error : cannot import name '_validate_lengths' (0) | 2020.04.21 |
---|---|
[Matplotlib]imshow 이미지색 이상하게 나올때 (1) | 2020.04.16 |
[pip]특정 버전 설치 (0) | 2020.04.11 |
[Kotlin]Fragment에서 MapView로 GoogleMap사용하기 (0) | 2019.12.11 |
[Kotlin]for문 간단 정리 (0) | 2019.11.21 |