代码实现
# -*- coding:utf-8 -*-import cv2import numpy as npr_range = 255image_wh = 530center_xy = image_wh // 2image = np.zeros((image_wh, image_wh, 3), dtype=np.uint8)for x in range(image_wh):for y in range(image_wh):# xy是否在圆内if (x - center_xy) ** 2 + (y - center_xy) ** 2 <= r_range ** 2:r = np.sqrt((x - center_xy) ** 2 + (y - center_xy) ** 2)theta = np.rad2deg(np.arctan2((y - center_xy), (x - center_xy)))theta += 180# [int(theta // 2), int(r), 255] hsvbgr = cv2.cvtColor(np.array([[[int(theta // 2), int(r), 255]]], dtype=np.uint8), cv2.COLOR_HSV2BGR)color = tuple([int(x) for x in bgr[0][0]])image[x, y] = colorcv2.namedWindow('img', 0)cv2.imshow('img', image)cv2.waitKey()