ex01.py 381 B

1234567
  1. import numpy # 向量与矩阵运算库(线性代数运算库) 1.19.5
  2. import cv2 #opencv-python opencv-contrib-python:图像处理
  3. # 生成数组
  4. img_array = [[[0, 225, 225, 50] for i in range(50)] for j in range(50)] # 225 *225的图像,图像的像素[0, 225,0,128]
  5. # cv2中只支持numpy的格式
  6. img_numpy = numpy.array(img_array)
  7. cv2.imwrite("1.jpg",img_numpy)