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)
相关推荐
qq_172805591 分钟前
Go 自建库的使用教程与测试
开发语言·后端·golang
久绊A7 分钟前
Hydra-SSH 破解安全防范
开发语言·php
ZZHow10249 分钟前
02OpenCV基本操作
python·opencv·计算机视觉
阿昭L15 分钟前
c++中获取随机数
开发语言·c++
计算机学长felix20 分钟前
基于Django的“酒店推荐系统”设计与开发(源码+数据库+文档+PPT)
数据库·python·mysql·django·vue
3壹21 分钟前
数据结构精讲:栈与队列实战指南
c语言·开发语言·数据结构·c++·算法
站大爷IP21 分钟前
Python随机数函数全解析:5个核心工具的实战指南
python
悟乙己30 分钟前
使用 Python 中的强化学习最大化简单 RAG 性能
开发语言·python·agent·rag·n8n
max50060034 分钟前
图像处理:实现多图点重叠效果
开发语言·图像处理·人工智能·python·深度学习·音视频
AI原吾1 小时前
玩转物联网只需十行代码,可它为何悄悄停止维护
python·物联网·hbmqtt