当前位置:网站首页>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)
边栏推荐
- C#/VB. Net to convert PDF to excel
- You have a chance to collect wool. Click "earn" and you will have a chance to earn a high commission
- C#/VB.NET 将PDF转为Excel
- Tianyi cloud web application firewall (edge cloud version) passed the first batch of trusted authentication
- STM32CubeMX使用方法及功能介绍
- Can Huawei become a "brother of lipstick" or a "Queen of goods"?
- 【尚硅谷与腾讯云官方合作】硅谷课堂项目视频发布
- [tcaplusdb knowledge base] view tcapdir directory server
- Internet of things cloud convergence Security Guide
- 【力扣】977. 有序数组的平方
猜你喜欢

Azure Kinect Microsoft camera unity development summary

Use open connector to integrate hubspot and SAP systems

岛屿类问题通用解法与DFS框架

The first place on the list - brake by wire "new cycle", the market competitiveness of local suppliers is TOP10

MATLB|可视化学习(plot和bar)

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

浅谈 SAP 软件里的价格折扣设计原理

General solution of island problems and DFS framework

批量修改指定字符文件名 bat脚本

Lucky draw animation - Carp jumps over the dragon's gate
随机推荐
岛屿类问题通用解法与DFS框架
LDD 知识整理
Convolutional neural networks for machine learning -- an introduction to CNN
R 编程语言 - 简介
Inspur network wins step by step
小新黑苹果声卡ID注入
共享主机和 WordPress 主机之间的区别
批量修改指定字符文件名 bat脚本
[tcapulusdb knowledge base] view the business password
2019 CSP J2入门组 CSP-S2提高组 第2轮 视频与题解
The first place on the list - brake by wire "new cycle", the market competitiveness of local suppliers is TOP10
10.hystrix circuit breaker
通过setTimeout解决子组件不会销毁的问题
Hello, is it safe to open an account to buy stocks online?
中国SSD行业企业势力全景图
PMD-源代码分析器介绍
使用Karmada实现Helm应用的跨集群部署
Practice of curve replacing CEPH in Netease cloud music
How to log in to your WordPress admin dashboard
如何在网站上安装 WordPress