python 图像的绘制源代码

import numpy as np
import c<a href="https://www.knrjk.com/tag/1479" target="_blank">v</a>2 as cv
import matplotlib.pyplot as plt
# 1 创建一个空白的图像
img = np.zeros((512, 512, 3), np.uint8)
# 2 绘制图形
cv.line(img, (0, 0), (511, 511), (255, 0, 0), 5)
cv.rectangle(img, (384, 0), (510, 128), (0, 255, 0), 3)
cv.circle(img, (447, 63), 63, (0, 0, 255), -1)
font = cv.FONT_HERSHEY_SIMPLE<a href="https://www.knrjk.com/tag/1481" target="_blank">X</a>
cv.putText(img, 'OPENCV', (10, 500), font, 4, (255, 255, 0), 2, cv.LINE_AA)
# 3 图像展示
plt.rc("font", family='Microsoft YaHei')
plt.imshow(img[:, :, ::-1])
plt.title('匹配结果'), plt.xticks([]), plt.yticks([])
plt.show()
import numpy as np
import c<a href="https://www.knrjk.com/tag/1479" target="_blank">v</a>2 as cv
import matplotlib.pyplot as plt

# 1 创建一个空白的图像

img = np.zeros((512, 512, 3), np.uint8)

# 2 绘制图形

cv.line(img, (0, 0), (511, 511), (255, 0, 0), 5)

cv.rectangle(img, (384, 0), (510, 128), (0, 255, 0), 3)

cv.circle(img, (447, 63), 63, (0, 0, 255), -1)

font = cv.FONT_HERSHEY_SIMPLE<a href="https://www.knrjk.com/tag/1481" target="_blank">X</a>

cv.putText(img, 'OPENCV', (10, 500), font, 4, (255, 255, 0), 2, cv.LINE_AA)

# 3 图像展示
plt.rc("font", family='Microsoft YaHei')

plt.imshow(img[:, :, ::-1])

plt.title('匹配结果'), plt.xticks([]), plt.yticks([])

plt.show()
import numpy as np import cv2 as cv import matplotlib.pyplot as plt # 1 创建一个空白的图像 img = np.zeros((512, 512, 3), np.uint8) # 2 绘制图形 cv.line(img, (0, 0), (511, 511), (255, 0, 0), 5) cv.rectangle(img, (384, 0), (510, 128), (0, 255, 0), 3) cv.circle(img, (447, 63), 63, (0, 0, 255), -1) font = cv.FONT_HERSHEY_SIMPLEX cv.putText(img, 'OPENCV', (10, 500), font, 4, (255, 255, 0), 2, cv.LINE_AA) # 3 图像展示 plt.rc("font", family='Microsoft YaHei') plt.imshow(img[:, :, ::-1]) plt.title('匹配结果'), plt.xticks([]), plt.yticks([]) plt.show()
python 图像的绘制源代码插图
THE END