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)
相关推荐
love530love5 分钟前
EPGF 新手教程 21把“环境折磨”从课堂中彻底移除:EPGF 如何重构 AI / Python 教学环境?
人工智能·windows·python·重构·架构·epgf
ldccorpora6 分钟前
Chinese News Translation Text Part 1数据集介绍,官网编号LDC2005T06
数据结构·人工智能·python·算法·语音识别
大学生毕业题目6 分钟前
毕业项目推荐:99-基于yolov8/yolov5/yolo11的肾结石检测识别系统(Python+卷积神经网络)
人工智能·python·yolo·目标检测·cnn·pyqt·肾结石检测
源代码•宸7 分钟前
Leetcode—1266. 访问所有点的最小时间【简单】
开发语言·后端·算法·leetcode·职场和发展·golang
寄思~8 分钟前
Excel 数据匹配工具 -笔记
笔记·python·学习·excel
遇见~未来11 分钟前
JavaScript数组全解析:从本质到高级技巧
开发语言·前端·javascript
南屿欣风11 分钟前
Sentinel 熔断规则 - 异常比例(order & product 示例)笔记
java·开发语言
u01040583618 分钟前
使用Java实现高性能的异步编程:CompletableFuture与Reactive Streams
java·开发语言
朔北之忘 Clancy25 分钟前
2020 年 6 月青少年软编等考 C 语言二级真题解析
c语言·开发语言·c++·学习·青少年编程·题解·尺取法
消失的旧时光-194331 分钟前
C++ 中的 auto 与 nullptr:不是语法糖,而是类型系统升级
开发语言·c++