opencv-python(五)

opencv的颜色通道中顺序是B,G,R。

图像属性

import cv2

img = cv2.imread('jk.jpg')
print(f'shape={img.shape}')
print(f'size={img.size}')
print(f'dtype={img.dtype}')

shape:图像像素的行,列,通道

size:行数 X 列数 X 通道数

dtype:图像的数据类型

像素的BGR值

import cv2
img = cv2.imread('jk.jpg')
cv2.imshow('Before the change', img)
pt_y = 169
pt_x = 118
px = img[pt_y,pt_x]
print(type(px))
print(f'BGR={px}')
blue = img[pt_y,pt_x,0]
green = img[pt_y,pt_x,1]
red = img[pt_y,pt_x,2]
print(f'BGR={blue},{green},{red}')
for y in range(img.shape[0]-50, img.shape[0]):
    for x in range(img.shape[1]-50, img.shape[1]):
        img[y,x] = [255,255,255]
cv2.imshow("After the change", img)
cv2.waitKey(0)
cv2.destroyAllWindows()

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值