Opencv notes-image attributes and pixel point modification

Image attributes:

  • shape: image shape
  • size: image size
  • dtype: data type
import numpy as np
import cv2 as cv
import matplotlib.pyplot as plt

# 读取图像
img1 = cv.imread("img/img1.jpeg")

print(img1.shape)       # 图像形状
print(img1.size)        # 图像大小
print(img1.dtype)       # 数据类型

Insert picture description hereImage pixel modification:

import numpy as np
import cv2 as cv
import matplotlib.pyplot as plt

# 载入图片
img = np.zeros((512,512,3),np.uint8)
# 操作像素点
img[100,100] = (0,0,255)
plt.imshow(img[:,:,::-1])
plt.show()

Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_45666249/article/details/114903949