如何利用 Python 建立點陣圖 (廣東話)

Subscribers:
5,680
Published on ● Video Link: https://www.youtube.com/watch?v=eHNpl6BUbBI



Duration: 4:17
118 views
2


Requirements:
Install Python, PyCharm
In PyCharm, install the modules opencv-python and numpy

Source codes:
# create a bitmap image with Python

import cv2
import numpy as np

# image height 300, width 400
img = np.zeros((300, 400, 3), np.uint8) # unsigned integer 8 bit (0-255)

print(img)

for row in img:
for pixel in row:
pixel[0] = 32 # blue
pixel[1] = 32 # green
pixel[2] = 32 # red

cv2.imshow("Image", img)
cv2.waitKey(0)