| Crates.io | munsellspace |
| lib.rs | munsellspace |
| version | 1.2.3 |
| created_at | 2025-08-15 22:08:54.964585+00 |
| updated_at | 2026-01-03 19:40:57.198097+00 |
| description | High-precision sRGB to Munsell color space conversion with 100% reference accuracy |
| homepage | https://github.com/chrisgve/MunsellSpace |
| repository | https://github.com/chrisgve/MunsellSpace |
| max_upload_size | |
| id | 1797580 |
| size | 3,554,217 |
High-precision sRGB to Munsell color space conversion library with ISCC-NBS color naming system support.
MunsellSpace is a high-performance Rust library for converting sRGB colors to Munsell color notation and ISCC-NBS color names. This implementation is based on the mathematical algorithms from the Python Colour Science library, providing accurate color space transformations with comprehensive thread safety support.
Send + Sync support for concurrent processingAdd to your Cargo.toml:
[dependencies]
munsellspace = "1.0"
use munsellspace::{MunsellConverter, IsccNbsClassifier};
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create converter for Munsell notation
let converter = MunsellConverter::new()?;
// Convert RGB to Munsell
let munsell = converter.srgb_to_munsell([255, 0, 0])?;
println!("Pure red: {}", munsell); // Output: 7.9R 5.2/20.5
// Create ISCC-NBS classifier
let classifier = IsccNbsClassifier::new()?;
// Classify color to ISCC-NBS name
let color_name = classifier.classify_rgb([255, 0, 0])?;
println!("Color name: {:?}", color_name); // Output: vivid red
Ok(())
}
The Munsell color system describes colors using three perceptually uniform dimensions:
Notation Format: HUE VALUE/CHROMA (e.g., 5R 4.0/14.0)
The Inter-Society Color Council - National Bureau of Standards (ISCC-NBS) system provides standardized color names for 267 distinct color categories. Each color is defined by:
The library supports three color naming systems, each with increasing specificity:
These are the official ISCC-NBS color name components, organized by hue progression:
| Hue Region | Base Colors |
|---|---|
| R (Red) | pink, red, yellowish pink, purplish pink, purplish red |
| YR (Yellow-Red) | reddish orange, reddish brown, orange, brown, orange yellow, yellowish brown |
| Y (Yellow) | yellow, greenish yellow, olive brown |
| GY (Green-Yellow) | olive, yellow green, olive green |
| G (Green) | yellowish green, green |
| BG (Blue-Green) | bluish green |
| B (Blue) | greenish blue, blue |
| PB (Purple-Blue) | purplish blue, violet |
| P (Purple) | purple, reddish purple |
| Neutral | white, gray, black |
These provide more recognizable alternatives for compound ISCC-NBS names:
| Extended Name | Replaces | Hue Family |
|---|---|---|
| lime | yellow green | GY |
| teal | greenish blue | BG-B |
| turquoise | bluish green | BG |
Use BaseColorSet::Extended to get these names instead of the compound forms.
30 color names derived from fabric samples, providing natural language color terms. Sorted by hue progression:
| Category | Colors (by hue) |
|---|---|
| Basic (10) | red, orange, yellow, green, blue, purple, pink, brown, gray, white |
| Non-basic (20) | wine, rust, coral, peach, tan, beige, gold, sand, taupe, teal, aqua, turquoise, navy, lavender, violet, magenta, fuchsia, mauve, lilac, rose |
Modifiers combine with base colors to form the 267 ISCC-NBS categories:
| Type | Modifiers |
|---|---|
| Saturation | vivid, brilliant, strong, deep, very deep |
| Lightness | light, very light, moderate, dark, very dark |
| Desaturation | pale, very pale, grayish, dark grayish, blackish, brownish |
| Compound | {color}ish white, {color}ish gray, {color}ish black, light {color}ish gray, dark {color}ish gray |
Example outputs: "vivid red", "pale yellow", "dark grayish blue", "pinkish white"
The library implements a sophisticated color conversion pipeline:
All public types implement Send + Sync for safe concurrent usage:
use munsellspace::{MunsellConverter, IsccNbsClassifier};
use std::sync::Arc;
use std::thread;
let converter = Arc::new(MunsellConverter::new()?);
let classifier = Arc::new(IsccNbsClassifier::new()?);
let mut handles = vec![];
for thread_id in 0..4 {
let conv = Arc::clone(&converter);
let class = Arc::clone(&classifier);
let handle = thread::spawn(move || {
let munsell = conv.srgb_to_munsell([255, 0, 0])?;
let color_name = class.classify_rgb([255, 0, 0])?;
println!("Thread {}: {} -> {:?}", thread_id, munsell, color_name);
Ok::<(), Box<dyn std::error::Error + Send + Sync>>(())
});
handles.push(handle);
}
for handle in handles {
handle.join().unwrap()?;
}
For detailed API documentation, visit docs.rs/munsellspace.
Key modules:
converter: Core Munsell conversion functionalityiscc: ISCC-NBS classification systemtypes: Color type definitions and validationilluminants: Illuminant definitions and adaptationmathematical: Mathematical conversion algorithms# Clone repository
git clone https://github.com/chrisgve/MunsellSpace.git
cd MunsellSpace
# Build library
cargo build --release
# Run tests
cargo test
# Run benchmarks
cargo bench
# Generate documentation
cargo doc --open
# Run all tests
cargo test
# Run with output
cargo test -- --nocapture
# Run specific test
cargo test test_name
# Run benchmarks
cargo bench
This library builds upon decades of color science research and open-source contributions:
colour-science library, specifically the Munsell color notation conversion functions. We are deeply grateful for their comprehensive and well-documented implementation.We welcome contributions! Please see CONTRIBUTING.md for guidelines.
This project is licensed under the MIT License - see the LICENSE file for details.
MunsellSpace - High-precision color space conversion for Rust 🦀