Mat is actually a matrix, which may contain multiple channels. If there is only one channel, it has two colors, black and white, which is a two-dimensional matrix. If it is a full-color image, it is a matrix of three channels.
What are the benefits of Mat?
Numpy can be used to access in the form of matrix, which is easy to operate.
Attributes of Mat

Mat Copy

Mat can be divided into deep copy and shallow copy
To access the properties of an image (Mat):
Shape: the height, length and number of channels of the picture
size:图片占用多大空间=高度*长度*通道数
Dtype: bit depth of each element in the image
import numpy as np import cv2 img=cv2.imread('你的图片') # 图片的高度、长度和通道数 print(img.shape) # 图片占用多大空间=高度*长度*通道数 print(img.size) # 图像中每个元素的位深 print(img.dtype) # 浅拷贝 img2=img # 深拷贝 img3=img.copy() img[10:100,10:100]=[0,0,255] cv2.imshow('img1',img) cv2.imshow('img2',img2) cv2.imshow('img3',img3) cv2.waitKey(0) cv2.destroyAllWindows()