import cv2
import numpy as np
img = cv2.imread('pic1.png')
# get the BGR value
px = img[100, 100]
print(px)
blue = img[100, 100, 0]
print(blue)
# get the argument of image
print(img.shape)
print(img.size)
print(img.dtype)
# get and change the value of a px
print(img.item(100, 100, 2))
img.itemset((100, 100, 2), 100)
print(img.item(100, 100, 2))
# get the ROI
ball = img[200:300, 200:300]
img[300:400, 300:400] = ball
# split bgr of the picture
b, g, r = cv2.split(img)
print(b)
#img = cv2.merge(b,g,r)
img[:, :, 1] = 0
cv2.imshow('img', img)
cv2.waitKey(0)
cv2.destroyAllWindows()
Python 5. 获取并改变某个像素或整个图片的BGR值,获取ROI区域OpenCV Linux
猜你喜欢
转载自blog.csdn.net/qq_36071362/article/details/104093374
今日推荐
周排行