opencv 读取照片就是二维矩阵,由weight【长】、height【宽】2个维度组成的像素数组矩阵;
矩阵元素为 pixel【像素点】,由Bule、Green、Red三个颜色组成;
既然是图片本质上可以抽象成矩阵,那么根据矩阵的特性和numpy数组提供的方法,都可以对图片进行矩阵变换;
import cv2 as cv
img=cv.imread("../sources/cyq.jpg")
print(img.shape)
img1=img[0:2,0:2,:]
img2=img[100:102,100:102,:]
print("[img1]:----------")
print(img1)
print("[img2]:----------")
print(img2)
print("[img1+img2]:----------")
print(img1+img2)
import cv2 as cv
img=cv.imread("../sources/cyq.jpg")
print(img.shape)
img1=img[0:2,0:2,:]
img2=img[100:102,100:102,:]
print("[img1]:----------")
print(img1)
print("[img2]:----------")
print(img2)
print("[img1-img2]:----------")
print(img1-img2)
import cv2 as cv
img=cv.imread("../sources/cyq.jpg")
print(img.shape)
img2=img[100:102,100:102,:]
print("[img2]:----------")
print(img2)
print("[img1*2]:----------")
print(img2*2)