Python 基于OpenCV 在一张图片上叠加点
1、安装 OpenCV
pip install opencv-python
2、cv2.circle 用法
cv2.circle(img, center, radius, color[, thickness[, lineType[, shift]]])
作用
- 根据给定的圆心和半径等画圆
参数说明
- img:输入的图片
- center:圆心位置,如 (100, 100)
- radius:圆的半径,如 10
- color:圆的颜色,如 (0, 0, 255) 红色,BGR
- thickness:圆形轮廓的粗细(如果为正)。负厚度表示要绘制实心圆。
- lineType: 圆边界的类型。
- shift:中心坐标和半径值中的小数位数。
3、代码
#-*-coding:utf-8-*-
import cv2 as cv
from netCDF4 import Dataset
index = [(95, 143), (143, 158), (134, 164), (1348, 327), (1351, 338), (1137, 411), (1019, 459), (1357, 520), (1319, 635), (1366, 655), (1357, 701)]
path = r"D:\work\fire_point\fy\china_standard.png"
image = cv.imread(path)
print(image.shape)
# 循环列表,添加多个点到图片上
for coor in index:
#print(coor)
cv.circle(image,coor, 10, (0,0,255), -1) #中心坐标,半径,颜色(BGR),线宽(若为-1,即为填充颜色)
# 保存图片
cv.imwrite(r"D:\work\fire_point\fire_point\out\fy.png", image)
4、结果图
https://blog.csdn.net/u011520181/article/details/83933325?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.channel_param&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.channel_param