靡不有初,鲜克有终
先在这里放着官方文档的链接OpenCV官方文档
OpenCV对图像的基本操作
对于RGB图像的操作 [ blue, green, red]
# accessing RED value
>>> img.item(10,10,2)
59
# modifying RED value
>>> img.itemset((10,10,2),100)
>>> img.item(10,10,2)
100
获取图像基本特征
>>> print( img.shape )
(342, 548, 3)
可以利用直接使得像素相等的方法来对Image进行操作
Here I am selecting the ball and copying it to another region in the image
>>> ball = img[280:340, 330:390]
>>> img[273:333, 100:160] = ball
Image Addition(图像相加、重叠)
利用了相叠加的公式
dst=α⋅img1+β⋅img2+γ
img1 = cv.imread('ml.png')
img2 = cv.imread('opencv-logo.png')
dst = cv.addWeighted(img1,0.7,img2,0.3,0)
cv.imshow('dst',dst)
cv.waitKey(0)
cv.destroyAllWindows()