Created
February 1, 2022 09:35
-
-
Save Keycatowo/1e9ac879a7de99a4a7ba951fe4088f6f to your computer and use it in GitHub Desktop.
分別使用scikit-image, PIL, cv2三種套件讀取圖片
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 方法1:scikit-image | |
import skimage.io as skio # 安裝需要使用scikit-image | |
img1 = skio.imread('example.jpg') | |
plt.imshow(img1) | |
# 方法2:PIL | |
img2 = np.array(Image.open('example.jpg')) # PIL物件需要轉換才是np array | |
plt.imshow(img2) | |
# 方法3:cv2 | |
import cv2 | |
img3 = cv2.cvtColor(cv2.imread('example.jpg'), cv2.COLOR_BGR2RGB) # cv2的預設通道的BGR | |
plt.imshow(img3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment