如下图所示,在图片上依次绘制多个圆绘制
实现代码如下:
import os
import cv2
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
from PIL import Image
import matplotlib.image as mpimg
# 读图像
img_1 = cv2.imread(f'图像路径')
h = img_1.shape[0] #图像高度
w = img_1.shape[1] #图像宽度
#中心点坐标
x0 = round(w / 2)
y0 = round(h / 2)
#内切圆半径
if x0 >= y0:
R = y0 - 2
else:
R = x0 - 2
for i in range(0 ,10):
cv2.circle(img_1, (x0, y0), R-round(i*R/10),(0, 255, 0), 1) #绘制10个内切圆
cv2.imshow("image", img_1) # 显示图片
#保存路径,路径不能有中文
save_path = 'AAV5-D1-GA-U-20230712-0001empty37.jpg'
cv2.imwrite(save_path, img_1)
cv2.waitKey(0) #等待按键
画好的图像如下图所示: