Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- error
- 프로그래머스
- Docker
- Numpy
- 기타 연주
- C
- Python
- 핑거스타일
- SSH
- 오류
- Selenium
- JSON
- pytorch
- windows forms
- YOLO
- pandas
- Visual Studio
- Linux
- 채보
- OpenCV
- nvidia-smi
- paramiko
- ubuntu
- VS Code
- C++
- pip
- label
- C#
- mysql
- 컨테이너
Archives
- Today
- Total
기계는 거짓말하지 않는다
Python colorsys 모듈을 이용한 일정한 분포의 색상 생성 함수 본문
Python에서 colorsys 모듈을 이용하여 지정된 개수만큼의 색상을
일정하게 분포된 색상 팔레트를 생성하는 간단한 함수이다.
import colorsys def generate_colors(num_classes: int, alpha=1): """ list of tuple: (R, G, B, A) 0~255 """ colors = [] for i in range(num_classes): hue = i / num_classes # S=1.0, V=1.0 rgb = colorsys.hsv_to_rgb(hue, 1.0, 1.0) # # RGB 0~255 # r, g, b = [int(x * 255) for x in rgb] # RGB 0~1 r, g, b = [x for x in rgb] # alpha a = alpha # 128 # 50% colors.append((r, g, b, a)) return colors
'Python' 카테고리의 다른 글
Python tracemalloc 모듈 메모리 할당 추적 (0) | 2025.02.16 |
---|---|
Python faulthandler 모듈 Segmentation Fault 진단 (0) | 2025.01.25 |
Python configparser config file 주석(comment) 유지 (0) | 2025.01.21 |
Python open 함수 파일 모드(mode) (3) | 2024.09.03 |
Python paramiko 프롬프트 상호작용 invoke_shell (0) | 2024.08.20 |