当前位置:网站首页>opencv学习笔记一——读取图像的几种方法
opencv学习笔记一——读取图像的几种方法
2022-07-07 05:19:00 【我是一个小稻米】
cv2.IMREAD_COLOR彩色图像cv2.IMREAD_GRAYSCALE灰度图像cv2.COLOR_BGR2RGBBGR转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()
边栏推荐
- Use of JMeter
- 探索STEAM艺术设计中的创造力
- [quick start of Digital IC Verification] 13. SystemVerilog interface and program learning
- The element with setfieldsvalue set is obtained as undefined with GetFieldValue
- WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after conne
- Game attack and defense world reverse
- Example of file segmentation
- The zblog plug-in supports the plug-in pushed by Baidu Sogou 360
- jeeSite 表单页面的Excel 导入功能
- Interview questions (CAS)
猜你喜欢

CCTV is so warm-hearted that it teaches you to write HR's favorite resume hand in hand

Easy to understand SSO

解析机器人科技发展观对社会研究论
![[step on the pit series] H5 cross domain problem of uniapp](/img/53/bd836a5c5545f51be929d8d123b961.png)
[step on the pit series] H5 cross domain problem of uniapp

Jmeter 的使用

数据库实时同步利器——CDC(变化数据捕获技术)

jeeSite 表单页面的Excel 导入功能

JS复制图片到剪切板 读取剪切板

Wang Zijian: is the NFT of Tencent magic core worth buying?

王爽 《汇编语言》之寄存器
随机推荐
Avatary's livedriver trial experience
Introduction à l'objet blob
Pytoch (VI) -- model tuning tricks
LeetCode中等题之我的日程安排表 I
Interview questions (CAS)
Dedecms collects content without writing rules
UnityHub破解&Unity破解
Zcmu--1492: problem d (C language)
Recursive method to verify whether a tree is a binary search tree (BST)
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after conne
Bugku CTF daily one question chessboard with only black chess
buureservewp(2)
Call pytorch API to complete linear regression
Network learning (I) -- basic model learning
发挥创客教育空间的广泛实用性
JS复制图片到剪切板 读取剪切板
jeeSite 表单页面的Excel 导入功能
[untitled]
[step on the pit series] H5 cross domain problem of uniapp
Use of any superclass and generic extension function in kotlin