python读取图片的几种方式及图像宽和高的存储顺序


Posted in Python onFebruary 11, 2020

1、opencv
2、imageio
3、matplotlib
4、scipy

# coding:utf-8
import cv2
import imageio
from scipy import misc
from PIL import Image
from matplotlib import pyplot as plt
image_path = "./images/000011.jpg"
# 使用pillow读取图片,获取图片的宽和高
img_pillow = Image.open(image_path)
img_width = img_pillow.width # 图片宽度
img_height = img_pillow.height # 图片高度
print("width -> {}, height -> {}".format(img_width, img_height))
img_cv = cv2.imread(image_path)
img_imageio = imageio.imread(image_path)
img_scipy = misc.imread(image_path)
img_matplot = plt.imread(image_path)
print(img_cv.shape)
print(img_imageio.shape)
print(img_scipy.shape)
print(img_matplot.shape)

输出结果如下:

width -> 2000, height -> 1333
(1333, 2000, 3)
(1333, 2000, 3)
(1333, 2000, 3)
(1333, 2000, 3)

注意事项:读取出的图像矩阵的shape是按 高度、宽度、通道数 这个顺序,图像宽度是第一个维度

总结

以上所述是小编给大家介绍的python读取图片的几种方式及图像宽和高的存储顺序,希望对大家有所帮助!

Python 相关文章推荐
Python使用稀疏矩阵节省内存实例
Jun 27 Python
python根据出生日期返回年龄的方法
Mar 26 Python
详解python的webrtc库实现语音端点检测
May 31 Python
python引入导入自定义模块和外部文件的实例
Jul 24 Python
Python中的groupby分组功能的实例代码
Jul 11 Python
python 对给定可迭代集合统计出现频率,并排序的方法
Oct 18 Python
用python写一个定时提醒程序的实现代码
Jul 22 Python
Django+python服务器部署与环境部署教程详解
Mar 30 Python
pycharm下pyqt4安装及环境配置的教程
Apr 24 Python
django使用graphql的实例
Sep 02 Python
如何使用python写截屏小工具
Sep 29 Python
Python爬虫之Selenium实现关闭浏览器
Dec 04 Python
详解Python中的分支和循环结构
Feb 11 #Python
python re模块匹配贪婪和非贪婪模式详解
Feb 11 #Python
详解Python的三种拷贝方式
Feb 11 #Python
Python @property原理解析和用法实例
Feb 11 #Python
如何使用Python发送HTML格式的邮件
Feb 11 #Python
python模式 工厂模式原理及实例详解
Feb 11 #Python
Python3搭建http服务器的实现代码
Feb 11 #Python
You might like
php5数字型字符串加解密代码
2008/04/24 PHP
PHP+MYSQL会员系统的登陆即权限判断实现代码
2011/09/23 PHP
如何使用php判断服务器是否是HTTPS连接
2013/07/05 PHP
PHP设计模式之工厂模式与单例模式
2016/09/28 PHP
thinkPHP5.0框架开发规范简介
2017/03/25 PHP
thinkphp5 migrate数据库迁移工具
2018/02/20 PHP
uploadify 3.0 详细使用说明
2012/06/18 Javascript
如何让div span等元素能响应键盘事件操作指南
2012/11/13 Javascript
当json键为数字时的取值方法解析
2013/11/15 Javascript
JavaScript实现16进制颜色值转RGB的方法
2015/02/09 Javascript
JavaScript将当前时间转换成UTC标准时间的方法
2015/04/06 Javascript
jQuery实现按钮只点击一次后就取消点击事件绑定的方法
2015/06/26 Javascript
Bootstrap每天必学之滚动监听
2016/03/16 Javascript
使用jQuery实现Web页面换肤功能的要点解析
2016/05/12 Javascript
浅谈Angularjs link和compile的使用区别
2016/10/21 Javascript
jquery实现输入框实时输入触发事件代码
2016/12/21 Javascript
js处理层级数据结构的方法小结
2017/01/17 Javascript
js鼠标移动时禁止选中文字
2017/02/19 Javascript
cropper js基于vue的图片裁剪上传功能的实现代码
2018/03/01 Javascript
Python3通过Luhn算法快速验证信用卡卡号的方法
2015/05/14 Python
深入理解python对json的操作总结
2017/01/05 Python
python Opencv将图片转为字符画
2021/02/19 Python
Python实现base64编码的图片保存到本地功能示例
2018/06/22 Python
Django中在xadmin中集成DjangoUeditor过程详解
2019/07/24 Python
Booking.com英国官网:全球酒店在线预订网站
2018/04/21 全球购物
Nike比利时官网:Nike.com (BE)
2019/02/07 全球购物
中药专业大学生医药工作求职信
2013/10/25 职场文书
中学教师师德承诺书
2014/05/23 职场文书
求职信范文大全
2014/05/26 职场文书
法人授权委托书公证范本
2014/09/14 职场文书
银行客户经理岗位职责
2015/04/09 职场文书
倡议书范文大全
2015/04/28 职场文书
2015年国庆放假通知范文
2015/08/18 职场文书
导游词之杭州西湖
2019/09/19 职场文书
SpringBoot整合Mybatis Generator自动生成代码
2021/08/23 Java/Android
基于Redis的List实现特价商品列表功能
2021/08/30 Redis