1 unstable release
| 0.1.0 | Jan 27, 2026 |
|---|
#1488 in Algorithms
92KB
2K
SLoC
wagahai-lut
A Rust-based CUBE LUT parser and image processing library with SIMD optimization
License
This project is licensed under the MIT License.
Features
- CUBE LUT format v1.0 support (Adobe specification)
- 1D and 3D LUT parsing with optimized data structures
- Image processing with
image::DynamicImageandimage::ImageBuffer - Multiple LUT types (Fixed and Other sizes)
Supported Image Types
image::DynamicImage- Dynamic image type that handles all formatsimage::ImageBuffer<T, Vec<u8>>- Specific typed image buffers:ImageBuffer<Luma<u8>, Vec<u8>>- GrayscaleImageBuffer<LumaA<u8>, Vec<u8>>- Grayscale with alphaImageBuffer<Rgb<u8>, Vec<u8>>- RGBImageBuffer<Rgba<u8>, Vec<u8>>- RGB with alpha
Architecture
The library is organized into several modules:
lut::common- Shared utilities (RGB type, trilinear interpolation)lut::lut_1d- 1D LUT data structureslut::lut_1d_processing- 1D LUT image processinglut::lut_3d- 3D LUT data structureslut::lut_3d_processing- 3D LUT image processingparser- CUBE LUT file parsing
Usage
Quick Start
use wagahai_lut::CubeParser;
use image::{ImageBuffer, Rgb};
// Load LUT and RGB image
let lut = CubeParser::from_file("lut.cube")?;
let image: ImageBuffer<Rgb<u8>, Vec<u8>> = image::open("input.jpg")?.to_rgb8();
// Apply LUT (auto-detects 1D/3D and Fixed/Other types)
let result = wagahai_lut::apply_rgb(&lut, &image);
// Save result
result.save("output.jpg")?;
For more detailed usage examples, see docs/USAGE.md
Performance
Benchmark results (Stable Rust, M4 Max):
1D LUT (1920×1080): 14.39ms/iteration
3D LUT (1920×1080): 19.40ms/iteration
1D LUT (6000×4000): 159.91ms/iteration
3D LUT (6000×4000): 223.15ms/iteration
1D LUT (8144×5424): 294.34ms/iteration
3D LUT (8144×5424): 417.09ms/iteration
Command Line Interface
Run example code:
# Parse and display LUT info
cargo run --example basic_usage path/to/lut.cube
# Apply LUT to image
cargo run --example basic_usage path/to/lut.cube input.jpg output.jpg
# Benchmark performance
cargo run --release --example benchmark
LUT Types
1D LUT Types
- Bit10: 1024 points (10-bit precision)
- Bit12: 4096 points (12-bit precision)
- Bit14: 16384 points (14-bit precision)
- Bit16: 65536 points (16-bit precision)
- Other: Custom size (2-65536 points)
3D LUT Types
- Size17: 17³ points (most common)
- Size33: 33³ points
- Size65: 65³ points
- Other: Custom size (2-256³ points)
Fixed vs Other
Fixed types (Bit10-16, Size17-65) use specialized heap-allocated arrays for optimal performance and unchecked access.
Other types use Vec for flexibility with checked access.
Dependencies
~11MB
~228K SLoC