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)
相关推荐
昔我往昔3 分钟前
init文件介绍
python·flask
奋发向前wcx6 分钟前
CSP-J复赛模拟赛1 王晨旭补题 2026.10.2
java·开发语言
周杰伦fans13 分钟前
轻量模型高并发推理优化技巧
开发语言·人工智能·c#
Frank_refuel16 分钟前
【C++项目】手撕JRpc框架(单机怎么优化到分布式思想)
开发语言·c++
虫无涯22 分钟前
大模型联动 CodeQL + Coverity 完整落地方案
人工智能·python·大模型·llm·codeql·coverity
段一凡-华北理工大学33 分钟前
大模型与智能体在工业的应用~系列文章12:大模型 × 数字孪生 × 智能体的融合图景
大数据·人工智能·python·深度学习·大语言模型·python开发
可乐鸡翅yeah_34 分钟前
fmp4 碎片 MP4 格式 HLS 流,和传统 TS 分片有什么不一样
开发语言·javascript·ios·音视频·safari·m3u8·m3u8在线播放
流形填表37 分钟前
多校区题库标准化:Excel模板与校验脚本
开发语言·python
步行cgn1 小时前
AOP 通知的类型详解
开发语言
weixin_307779131 小时前
从“人操作仪器”到“Agent 自主发现”:OPL 金属材料自驱动实验室 MVP 技术论述
开发语言·人工智能·算法·架构