Python图像处理库打开图片默认的维度顺序

总结:常用的Python图像处理库(PIL/Pillow、Matplotlib、OpenCV和scikit-image)在打开图像时默认使用先宽度和高度,然后是通道数的维度顺序。即 `(height, width, channels)`

python 复制代码
from PIL import Image
import matplotlib.pyplot as plt
import cv2
from skimage import io
import numpy as np

image_path = r"chase/train/image/Image_01L.tif"

# PIL(Pillow)库
image = np.array(Image.open(image_path).convert("RGB"))  # (height, width, channels)
print(image.shape)

image1 = Image.open(image_path)
image1 = np.asarray(image1)  # (height, width, channels)
print(image1.shape)

# Matplotlib库
image2 = plt.imread(image_path)  # (height, width, channels)
print(image2.shape)

# OpenCV库
image3 = cv2.imread(image_path)  # (height, width, channels)
print(image3.shape)

# scikit-image库(skimage)
image4 = io.imread(image_path)  # (height, width, channels)
print(image4.shape)
相关推荐
liu_chunhai5 分钟前
设计模式(3)builder
java·开发语言·设计模式
Mr.D学长10 分钟前
毕业设计 深度学习社交距离检测系统(源码+论文)
python·毕业设计·毕设
姜学迁14 分钟前
Rust-枚举
开发语言·后端·rust
wdxylb14 分钟前
解决Python使用Selenium 时遇到网页 <body> 划不动的问题
python
冷白白15 分钟前
【C++】C++对象初探及友元
c语言·开发语言·c++·算法
凌云行者19 分钟前
rust的迭代器方法——collect
开发语言·rust
代码骑士22 分钟前
【一起学NLP】Chapter3-使用神经网络解决问题
python·神经网络·自然语言处理
It'sMyGo22 分钟前
Javascript数组研究09_Array.prototype[Symbol.unscopables]
开发语言·javascript·原型模式
睡觉然后上课33 分钟前
c基础面试题
c语言·开发语言·c++·面试
qing_04060340 分钟前
C++——继承
开发语言·c++·继承