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)
相关推荐
小白菜又菜5 分钟前
Leetcode 235. Lowest Common Ancestor of a Binary Search Tree
python·算法·leetcode
Omigeq7 分钟前
1.2.2 - 采样搜索算法(以RRT和RRT*为例) - Python运动规划库教程(Python Motion Planning)
开发语言·人工智能·python·机器人
凌云拓界9 分钟前
TypeWell全攻略(二):热力图渲染引擎,让键盘发光
前端·后端·python·计算机外设·交互·pyqt·数据可视化
小白菜又菜15 分钟前
Leetcode 234. Palindrome Linked List
python·算法·leetcode
恒云客21 分钟前
python uv debug launch.json
数据库·python·json
Katecat9966327 分钟前
YOLO11-SEG-AFPN-P345改进采血装置检测与识别系统
python
m0_5312371741 分钟前
C语言-操作符进阶
c语言·开发语言
q1234567890981 小时前
FNN sin predict
开发语言·python
沐知全栈开发1 小时前
C++ 多态
开发语言
zihan03211 小时前
若依(RuoYi)框架核心升级:全面适配 SpringData JPA,替换 MyBatis 持久层方案
java·开发语言·前端框架·mybatis·若依升级springboot