-
opencv绘制简单图片
import cv2 as cv
import numpy as np
# img = np.zeros((图片高度, 图片宽度, 三维矩阵), np.uint8)
img = np.zeros((512, 512, 3), np.uint8)
"""img类型为<class 'numpy.ndarray'>"""
for x in range(512):
for y in range(512):
if x <= 512//3:
img[x][y] = [0, 0, 255]
elif x <= 2*521//3:
img[x][y] = [0, 255, 0]
elif x <= 521:
img[x][y] = [255, 0, 0]
print(type(img))
cv.imshow("Image", img)
cv.waitKey(0)
cv.destroyAllWindows()