zhiqingstudy

Be a young person with knowledge and content

What is Mat?
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, an important structure of Opencv
Mat Copy
Mat, an important structure of Opencv
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()
comment
head sculpture
Code:
Related

Why you shouldn't stay at a job for more than 2 years?

3 harsh facts long-distance relationships

how to keep your girlfriend interested in a long-distance relationship




Unless otherwise specified, all content on this website is original. If the reprinted content infringes on your rights, please contact the administrator to delete it
Contact Email:2380712278@qq.com

Filing number:皖ICP备19012824号