Deterministic color family classifier across HSL, HSV, Lab, and LCH
Project description
ShadeSorter
Deterministic color family classifier across HSL, HSV, Lab, and LCH color spaces.
ShadeSorter uses the same scoring-based classification logic used in Tintelligence's paint management system. It analyzes colors across multiple color spaces (HSL, HSV, LAB, LCH) to accurately classify colors into 13 color families.
Features
- Multiple color space support: Accept input as HEX, HSL, HSV, LAB, or LCH
- Comprehensive classification: Analyzes colors across all four color spaces simultaneously
- Accurate results: Uses the same proven scoring algorithm from Tintelligence
- Detailed output: Returns family ID, name, and detailed scoring breakdown
Installation
pip install ShadeSorter
Quick Start
from shade_sorter import classify_from_hex
result = classify_from_hex("#FF0000")
print(result)
# {'family_id': 6, 'family_name': 'Red', 'scores': {...}}
Usage Examples
From HEX
from shade_sorter import classify_from_hex
result = classify_from_hex("#1A1A1A")
# {'family_id': 1, 'family_name': 'Black', 'scores': {...}}
result = classify_from_hex("FF0000") # Works with or without #
# {'family_id': 6, 'family_name': 'Red', 'scores': {...}}
From HSL
from shade_sorter import classify_from_hsl
# h in degrees (0-360), s and l in 0-1
result = classify_from_hsl(210.0, 0.35, 0.45)
From HSV
from shade_sorter import classify_from_hsv
# h in degrees (0-360), s and v in 0-1
result = classify_from_hsv(210.0, 0.40, 0.55)
From LAB
from shade_sorter import classify_from_lab
# L in 0-100, a and b can be negative
result = classify_from_lab(52.3, -8.1, -18.2)
From LCH
from shade_sorter import classify_from_lch
# L in 0-100, C >= 0, H in degrees (0-360)
result = classify_from_lch(52.3, 20.0, 245.0)
From All Color Spaces
from shade_sorter import classify_from_all
# Provide values from any or all color spaces
result = classify_from_all(
hsl=(210.0, 0.35, 0.45),
lab=(52.3, -8.1, -18.2),
lch=(52.3, 20.0, 245.0),
hsv=(210.0, 0.40, 0.55),
)
Color Families
ShadeSorter classifies colors into 13 families:
- Black
- White / Off White
- Grey
- Brown
- Green
- Red
- Pink
- Orange
- Yellow
- Turquoise / Teal
- Blue
- Purple / Violet
- Unknown (if no family matches)
API Reference
classify_from_hex(hex_str: str) -> dict
Classify color family from HEX color string.
Parameters:
hex_str(str): HEX color string (e.g., "#FF0000" or "FF0000")
Returns:
dictwith keys:family_id(int): Color family ID (1-13)family_name(str): Color family namescores(dict): Scores for all color families
classify_from_hsl(h: float | None, s: float, l: float) -> dict
Classify color family from HSL values.
Parameters:
h(float | None): HSL hue in degrees (0-360), can be None for greyss(float): HSL saturation (0-1)l(float): HSL lightness (0-1)
Returns: Same as classify_from_hex
classify_from_hsv(h: float | None, s: float, v: float) -> dict
Classify color family from HSV values.
Parameters:
h(float | None): HSV hue in degrees (0-360), can be None for greyss(float): HSV saturation (0-1)v(float): HSV value (0-1)
Returns: Same as classify_from_hex
classify_from_lab(L: float, a: float, b: float) -> dict
Classify color family from LAB values.
Parameters:
L(float): LAB lightness (0-100)a(float): LAB a component (can be negative)b(float): LAB b component (can be negative)
Returns: Same as classify_from_hex
classify_from_lch(L: float, C: float, H: float) -> dict
Classify color family from LCH values.
Parameters:
L(float): LCH lightness (0-100)C(float): LCH chroma (>=0)H(float): LCH hue in degrees (0-360)
Returns: Same as classify_from_hex
classify_from_all(hsl=None, hsv=None, lab=None, lch=None) -> dict
Classify color family from all available color spaces. Requires at least one color space to be provided.
Parameters:
hsl(tuple | None): Tuple(h, s, l)where h in degrees (0-360), s/l in 0-1hsv(tuple | None): Tuple(h, s, v)where h in degrees (0-360), s/v in 0-1lab(tuple | None): Tuple(L, a, b)where L in 0-100, a/b can be negativelch(tuple | None): Tuple(L, C, H)where L in 0-100, C>=0, H in degrees (0-360)
Returns: Same as classify_from_hex
Raises:
ValueError: If no color space is provided
Dependencies
tintelligence-color-utils>=0.1.0: For color space conversions
License
MIT
Contributing
This package is part of the Tintelligence project. Contributions are welcome!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file shadesorter-0.1.0.tar.gz.
File metadata
- Download URL: shadesorter-0.1.0.tar.gz
- Upload date:
- Size: 12.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e62b95b4e73c663a70a2ada894ddb969dc03788cd82c15ec9c6a4a17caf469eb
|
|
| MD5 |
1c63673c95d4152e2f44fe868e1849e2
|
|
| BLAKE2b-256 |
68810d3fd484430883d43e3bb4fe1b3dd569646354b89fdd0452be3378e1f88f
|
File details
Details for the file shadesorter-0.1.0-py3-none-any.whl.
File metadata
- Download URL: shadesorter-0.1.0-py3-none-any.whl
- Upload date:
- Size: 13.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a1328797a454435c3f3e830b4c681f930462eb9b4bb8af914f4cc12d29ef789d
|
|
| MD5 |
172d985636d972d188676aac547d7367
|
|
| BLAKE2b-256 |
dd15889075a3f2c06a5a39d4bc0979bfa331206e7398d0776517398b83a4a214
|