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)
相关推荐
wuyk5553 分钟前
Python实战项目01:简易记事本系统
开发语言·python
凤城老人9 分钟前
从零手写开源私有云盘|Flask+Vue3+Electron全栈网盘,单容器一键部署
python·docker·electron·vue
Zentceh21 分钟前
海洋牧场夜间监测:AI全彩夜视+水下成像集成方案
图像处理·人工智能·科技·计算机视觉·车载系统·无人机·智能家居
lpfasd12321 分钟前
配置文件格式对比 与 AI Coding 的选择逻辑
python·flask·numpy
2601_9628857224 分钟前
如何用 Python 把 A 股行情批量导出到 Excel/CSV?(多股票多 Sheet)
python
君顾134 分钟前
本地城市社区家政物业联动系统源码:架构设计与派单联动实战
java·开发语言·健身房
2601_9622186143 分钟前
万象生鲜系统多终端统一数据协议PC手机PDA数据实时同步
大数据·数据库·人工智能·python·算法
AI编码进化论1 小时前
云IDE介绍:环境模板化、Agent上云,云IDE该怎么选
开发语言·ide·人工智能·团队开发·ai编程
科技苑1 小时前
Python AI自动剪辑视频简易程序
人工智能·python
晴天的雨.9921 小时前
[C++算法]盛最多水的容器(双指针算法)
开发语言·c++·算法