当前位置:网站首页>Opencv read picture details
Opencv read picture details
2022-06-28 16:53:00 【Da_ Shan_】
Recently, I was doing deep learning target detection , use opencv Image Reading , Do operations such as flipping , Before I found myself, I was opencv The understanding of data storage for reading pictures is not comprehensive , Now I would like to make a summary as follows :
opencv The picture is read from the first pixel on the left , Because it is color RGB picture , So there are three values at each pixel ,(opencv Is in accordance with the BRG Read pixel values in the order of ), Go through each line in turn , Each line is a (width, 3) Of numpy Format of two-dimensional array , Finally, add the two-dimensional array of each row to a large array , Form a three array , And finally img.shape Output (height, width, 3) Such a three-dimensional array
take opencv The read picture becomes normal RGB Pattern :
img_path = '000001.jpg'
img = cv2.imread(img_path)
# opencv Self contained imshow Function can be displayed normally BGR Format image
cv2.imshow('res', img)
cv2.waitKey(0)
# take BGR Turn into RGB, use plt Show
img_rgb = img[:, :, ::-1] # use numpy The array converts the last dimension
img_rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) # use cv The built-in conversion function
plt.imshow(img_rgb)
plt.show()
Horizontal mirror flip
img_flip = cv2.flip(img, 1)
img_flip = img[:, ::-1, :]
img_combine = np.hstack((img, img_flip))
cv2.imshow('res', img_combine)
cv2.waitKey(0)
Vertical mirror flip
img_flip = cv2.flip(img, 0)
img_flip = img[::-1, :, :]
img_combine = np.hstack((img, img_flip))
cv2.imshow('res', img_combine)
cv2.waitKey(0)
边栏推荐
- LDD knowledge sorting
- 【Hot100】2. Add two numbers
- 2022年暑期及9月份CSP-J1 CSP-S1初赛 培训计划及学习要点
- After the first failure, AMEC rushed to the Hong Kong stock exchange for the second time, and the financial principal changed frequently
- 中金证券经理给的开户链接安全吗?找谁可以开户啊?
- 【Hot100】3. Longest substring without duplicate characters
- 【力扣】35. 搜索插入位置
- Azure Kinect Microsoft camera unity development summary
- Steps to be taken for successful migration to the cloud
- Slim gain (sgain) introduction and code implementation -- missing data filling based on generated countermeasure network
猜你喜欢

Csp-j1 csp-s1 preliminary training plan and learning points in summer and September 2022

【TcaplusDB】祝大家端午安康!

Internet of things cloud convergence Security Guide

Slim gain (sgain) introduction and code implementation -- missing data filling based on generated countermeasure network

2022年暑期及9月份CSP-J1 CSP-S1初赛 培训计划及学习要点

中国SSD行业企业势力全景图
![[golang] how to install iris](/img/c6/842c4e920a74f9a07c2f6a82bb0cc1.png)
[golang] how to install iris

QQ出现大规模盗号,为什么会这样?就没有解决方法了吗?

使用Karmada实现Helm应用的跨集群部署

免费、强大、高颜值的笔记软件评测: OneNote、Heptabase、氢图、FlowUs
随机推荐
免费、强大、高颜值的笔记软件评测: OneNote、Heptabase、氢图、FlowUs
通过setTimeout解决子组件不会销毁的问题
【208】基于AccessToken方式实现API设计
LDD 知识整理
【力扣】35. 搜索插入位置
The future of platform as code is kubernetes extension
visio 使用
【杂谈】2021/01/31 哦豁
如何清除 WordPress 中的缓存
批量修改指定字符文件名 bat脚本
浅谈 SAP 软件里的价格折扣设计原理
NOIP1998-2018 CSP-S2 2019 2021提高组解题报告与视频
The new paradigm of AI landing is "hidden" in the next major upgrade of software infrastructure
R 编程语言 - 简介
10.Hystrix断路器
【Hot100】3. Longest substring without duplicate characters
Slim gain (sgain) introduction and code implementation -- missing data filling based on generated countermeasure network
The first WordPress plug-in you are taught to make step by step
运维-- 统一网关非常必要
opencv 读取图片详解