当前位置:网站首页>图像基本操作的其他内容
图像基本操作的其他内容
2022-08-01 06:38:00 【The code family】
1.获取并修改图像中的像素点
我们可以通过行和列的坐标值获取该像素点的像素值。对于BGR图像,它返回一个蓝,绿,红值的数据组。对于灰度图像,仅返回相应的强度值。使用相同的方法对像素值进行修改。
import numpy as np
Import cv2 as cv
Img = cv.imread(‘ ’)
#获取某个像素点的值
Px = img[100,100]
#进获取蓝色通道的强度值
Blue = img[100,100,0]
#修改某个位置的像素值
Img[100,100]=[255,255,255]
2.获取图像的属性
图像属性包括行数,列数和通道数,图像数据类型,像素值等。
属性 API
形状 img.shape
图像大小 img.size
数据类型 img.dtype
3.图像通道的拆分与合并
有时需要在B,G,R通道图像上单独工作。在这种情况下,需要将BGR图像分割为单个通道。或者在其他情况下,可能需要将这些单独的通道合并到BGR图像。你可以通过以下方式完成。
#通道拆分
B,g,r = cv.split(img)
#通道合并
Img = cv.merge((b,g,r))
4.色彩空间的改变
Opencv中有150多种颜色空间转换方法。最广泛使用的转换方法有两种,BGR<->Gray和BGR<->HSV。
API:
cv.cvtColor(input_image,flag)
参数:input_image:进行颜色空间转换的图像
flag:转换类型
cv.COLOR_BGR2GRAY:BGR<->Gray
cv.COLOR_BGR2HSV:BGR->HSV
边栏推荐
- After the image is updated, Glide loading is still the original image problem
- 【翻译】确保云原生通信的安全:从入口到服务网及更远的地方
- 实战演练 Navicat 中英文模式切换
- Introduction to the basic principles, implementation and problem solving of crawler
- leetcode43 字符串相乘
- Dell PowerEdge Server R450 RAID Configuration Steps
- Malicious attacks on mobile applications surge by 500%
- The BP neural network based on MATLAB voice characteristic signal classification
- dbeaver连接MySQL数据库及错误Connection refusedconnect处理
- curl (7) Failed connect to localhost8080; Connection refused
猜你喜欢
随机推荐
matplotlib pyplot
Dbeaver connect the MySQL database and error Connection refusedconnect processing
Seleniu: Common operations on elements
Information system project managers must recite the work of the core test site (56) Configuration Control Board (CCB)
Introduction to the basic principles, implementation and problem solving of crawler
响应式织梦模板园林景观类网站
CSP-S2019 Day1
MVVM项目开发(商品管理系统一)
字符中的第一个唯一字符
Srping中bean的生命周期
戴尔PowerEdge服务器R450 RAID配置步骤
[Translation] Securing cloud-native communications: From ingress to service mesh and beyond
Vsce package after the Command failed: NPM list - production - parseable - the depth = 99999 - loglevel = error exception
Offer刷题——1
leetcode125 Verify palindrome string
使用string 容器翻转 字母
WebSocket implements chat function
史上超强最常用SQL语句大全
Jupyter shortcuts
权重等比分配