code implementation
# -*- coding:utf-8 -*-
import cv2
import numpy as np
r_range = 255
image_wh = 530
center_xy = image_wh // 2
image = np.zeros((image_wh, image_wh, 3), dtype=np.uint8)
for x in range(image_wh):
for y in range(image_wh):
# whether xy is inside the circle
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] hsv
bgr = 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] = color
cv2.namedWindow('img', 0)
cv2.imshow('img', image)
cv2.waitKey()
Effect display
Read More:
- [Solved] cv2.error: OpenCV(4.6.0) D:\a\opencv-python\opencv-python\opencv\modules\……
- [Solved] Pyinstaller package opencv error: ImportError: OpenCV loader: missing configuration file: [‘config.py’]. Check OpenCV installation.
- Opencv Python realizes the paint filling function in PS, one click filling color and the possible reasons for opencv’s frequent errors
- How to Solve Opencv Reads Video Error: cv2.error
- Python+OpenCV: How to Use Background Subtraction Methods
- Matplotlib draw error: Fail to allocate bitmap [How to Solve]
- [Solved] cv2.error: OpenCV(4.5.3) :-1: error: (-5:Bad argument) in function ‘circle‘
- Opencv-python Install is Stuck Error: running setup.py bdist_wheel for opencv-python
- [Solved] opencv-python: recipe for target ‘modules/python3/CMakeFiles/opencv_python3.dir/all‘ failed
- [Solved] Matplotlib scatter Draw Error: TypeError: ufunc ‘sqrt‘ not supported for the input types…rule ‘‘safe‘‘
- CV: How to extracts the part of the picture with the specified color
- [Solved] python opencv Error: findContours() Can only use the Grayscale
- [Solved] OpenCV Import Error: ImportError: numpy.core.multiarray failed to import
- Raspberry pie import opencv error: ImportError: numpy.core.multiarray failed to import
- Detailed explanation of OpenCV approxpolydp() function
- How to Solve cv2.applyColorMap Error
- [Solved] error: OpenCV(4.5.2) :-1: error: (-5:Bad argument) in function ‘copyMakeBorder‘
- [Solved] ERROR: Failed building wheel for opencv-python-headless
- [Solved] Python opencv imshow Error: Assertion failed (size.width>0 && size.height>0) in cv::imshow