| Crates.io | glint-mask-tools |
| lib.rs | glint-mask-tools |
| version | 0.1.1 |
| created_at | 2025-07-04 16:57:19.49406+00 |
| updated_at | 2025-07-04 16:58:50.383637+00 |
| description | Rust implementation of glint mask generation tools for UAV and aerial imagery |
| homepage | |
| repository | https://github.com/tayden/glint-mask-tools-rs |
| max_upload_size | |
| id | 1738212 |
| size | 226,569 |
A Rust implementation of glint mask generation tools for UAV and aerial imagery. This library detects and masks specular reflections (glint) in imagery from various sensor types.
cargo install glint-mask-tools
cargo install --git https://github.com/tayden/glint-mask-tools-rs.git
git clone https://github.com/tayden/glint-mask-tools-rs.git
cd glint-mask-tools-rs
cargo build --release
Process RGB images:
glint-mask rgb input_dir output_dir
Process with custom thresholds:
glint-mask rgb input_dir output_dir --thresholds 0.9,0.8,0.7
Process with pixel buffering:
glint-mask p4ms input_dir output_dir --pixel-buffer 2
List available sensors:
glint-mask list-sensors
Show sensor information:
glint-mask sensor-info rgb
use glint_mask_tools::{
core::masker::MaskerBuilder,
algorithms::ThresholdAlgorithm,
loaders::SingleFileLoader,
sensors::definitions,
};
// Create RGB masker
let rgb_sensor = definitions::rgb_sensor();
let algorithm = ThresholdAlgorithm::new(vec![0.9, 0.8, 0.7])?;
let loader = SingleFileLoader::rgb()?;
let masker = MaskerBuilder::new()
.with_sensor(rgb_sensor)
.with_algorithm(Box::new(algorithm))
.with_loader(Box::new(loader))
.build()?;
// Process images
let stats = masker.process_directory(&input_dir, &output_dir, None)?;
| Sensor | ID | Bands | Bit Depth | Description |
|---|---|---|---|---|
| RGB Camera | rgb |
3 (R,G,B) | 8-bit | Standard RGB cameras |
| PhaseOne CIR | cir |
4 (R,G,B,NIR) | 8-bit | Color infrared cameras |
| DJI P4MS | p4ms |
5 (B,G,R,RE,NIR) | 16-bit | Phantom 4 Multispectral |
| DJI M3M | m3m |
4 (G,R,RE,NIR) | 16-bit | Mavic 3 Multispectral |
| MicaSense RedEdge | msre |
5 (B,G,R,RE,NIR) | 16-bit | RedEdge multispectral |
| MicaSense RedEdge-MX Dual | msre_dual |
10 (CB,B,G1,G2,R1,R2,RE1,RE2,RE3,NIR) | 16-bit | RedEdge-MX Dual multispectral |
The library is built around three main abstractions:
ImageLoader: Handles different sensor file formats (single-file, multi-file, big-tiff)GlintAlgorithm: Implements glint detection algorithms (currently threshold-based)PostProcessor: Processes generated masks (pixel buffering, format conversion)Masker: Main orchestrator that composes loader, algorithm, and post-processorMaskerBuilder: Type-safe builder for constructing processing pipelinesSensorRegistry: Registry system for managing sensor configurationsSensor: Configuration defining bands, thresholds, and loader typecore/: Core traits and orchestration (masker, sensor registry)algorithms/: Algorithm implementations (threshold detection)loaders/: Loader implementations (single-file, multi-file, big-tiff)config/: Configuration management and sensor definitionsYou can create custom sensor configurations by editing the sensors.toml file, which is automatically created in your system's configuration directory:
Configuration File Location:
~/Library/Application Support/glint-mask-tools/sensors.toml~/.config/glint-mask-tools/sensors.toml%APPDATA%\glint-mask-tools\sensors.tomlThe configuration file is automatically created with default sensor definitions when you first run the tool. You can then modify it to add custom sensors or override existing ones.
Example Custom Sensor Configuration:
version = "1.0"
[[sensors]]
id = "custom_rgb"
name = "Custom RGB Camera"
description = "RGB camera with custom thresholds"
bit_depth = 8
loader_type = "single_file"
[[sensors.bands]]
name = "Red"
default_threshold = 0.95
wavelength = 650.0
[[sensors.bands]]
name = "Green"
default_threshold = 0.85
wavelength = 560.0
[[sensors.bands]]
name = "Blue"
default_threshold = 0.75
wavelength = 475.0
[sensors.loader_config]
extensions = "jpg,jpeg,png,tif,tiff"
After modifying the configuration file, your custom sensors will be available in the CLI. Use glint-mask list-sensors to see all available sensors including your custom ones.
cargo build
cargo test
cargo run --example basic_usage
cargo bench
The Rust implementation provides significant performance benefits:
MIT License - see LICENSE for details.