当前位置:网站首页>opencv学习笔记一——读取图像的几种方法
opencv学习笔记一——读取图像的几种方法
2022-07-07 05:19:00 【我是一个小稻米】
cv2.IMREAD_COLOR
彩色图像cv2.IMREAD_GRAYSCALE
灰度图像cv2.COLOR_BGR2RGB
BGR转RGB
import cv2
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import numpy as np
from PIL import Image
1. cv
方式显示图像
image = cv2.imread('image.png')
def cv_show(name, image):
cv2.imshow(name, image)
cv2.waitKey(0)
cv2.destroyAllWindows()
cv_show("cat", image)
2. cv2+plt
方式显示图像
image = cv2.imread('image.png')
plt.imshow(image)
因为opencv
读进来的数据不是RGB
,而是BGR
,所以通过cv2
读进来的图像尽量不要用其他的工具去展示,可通过cv2.COLOR_BGR2RGB
来转化
image = cv2.imread('image.png')
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
plt.imshow(image)
3.plt
方式显示图像
image = mpimg.imread('image.png')
plt.imshow(image)
4. Image
方式显示图像
image = Image.open('image.png')
image.show()
边栏推荐
- Zcmu--1396: queue problem (2)
- Complex network modeling (III)
- Myabtis_Plus
- LeetCode中等题之我的日程安排表 I
- CDC (change data capture technology), a powerful tool for real-time database synchronization
- Summary of redis functions
- Easy to understand SSO
- Openjudge noi 2.1 1752: chicken and rabbit in the same cage
- LeetCode简单题之找到一个数字的 K 美丽值
- It's too true. There's a reason why I haven't been rich
猜你喜欢
The largest 3 same digits in the string of leetcode simple question
Hisense TV starts the developer mode
[step on the pit series] H5 cross domain problem of uniapp
Rainbond结合NeuVector实践容器安全管理
漏洞复现-easy_tornado
Dedecms collects content without writing rules
【数字IC验证快速入门】11、Verilog TestBench(VTB)入门
Leetcode simple question: find the K beauty value of a number
Rainbond 5.7.1 支持对接多家公有云和集群异常报警
Record a stroke skin bone error of the skirt
随机推荐
Vulnerability recurrence easy_ tornado
Excel import function of jeesite form page
Game attack and defense world reverse
让Livelink初始Pose与动捕演员一致
CDC (change data capture technology), a powerful tool for real-time database synchronization
Bayes' law
【数字IC验证快速入门】12、SystemVerilog TestBench(SVTB)入门
Complex network modeling (II)
Hisense TV starts the developer mode
Leetcode 187 Repeated DNA sequence (2022.07.06)
eBPF Cilium实战(1) - 基于团队的网络隔离
数据库实时同步利器——CDC(变化数据捕获技术)
Network learning (II) -- Introduction to socket
互动送书-《Oracle DBA工作笔记》签名版
复杂网络建模(一)
快解析内网穿透助力外贸管理行业应对多种挑战
漏洞复现-easy_tornado
复杂网络建模(二)
game攻防世界逆向
Real time monitoring of dog walking and rope pulling AI recognition helps smart city