ex01.py 294 B

123456
  1. import numpy #向量与矩阵运算库
  2. import cv2 #opencv-python opencv-contrib-python:图像处理
  3. #生成数组
  4. img_array = [[[0,255,0,128]for i in range(255)]for j in range(255)]#255*255的图像,图像像素[0,255,0,128]
  5. img_numpy = numpy.array(img_array)
  6. cv2.imwrite("1.jpg",img_numpy)