Rust library for converting RGB colors to the CIE-L*a*b* color space

AppVeyor Build Status

```rust extern crate lab; use lab::Lab;

let pinkinlab = Lab::from_rgb(&[253, 120, 138]); // Lab { l: 66.639084, a: 52.251457, b: 14.860654 } ```

```rust extern crate lab; extern crate image;

use lab::Lab; use image::Rgba;

let pixel: Rgba = Rgba { data: [253, 120, 138, 255] }; let lab = Lab::from_rgba(&pixel.data); // Lab { l: 66.639084, a: 52.251457, b: 14.860654 } ```

Experimental SIMD functions

The lab::simd module is compiled for the x86_64 cpu architecture. If the current cpu can run AVX and SSE 4.1 operations, it can make use of the exported functions.

```rust extern crate lab; use lab::Lab;

[cfg(targetarch = "x8664")]

use lab::simd;

fn convertrgbs(rgbs: &[[u8; 3]]) -> Vec { // It's boilerplate, but it's also experimental. So. #[cfg(targetarch = "x8664")] { if isx86featuredetected!("avx") && isx86featuredetected!("sse4.1") { return simd::rgbstolabs(rgbs); } } rgbs.iter().map(Lab::fromrgb).collect() } ```

Performance increase over a serial map is wildly variable across CPUs, suggesting that there are still some optimizations to perform. A 2013 Macbook Air sees a \~25% decrease in benchmark times converting Labs to RGBs, and a \~40% decrease converting RGBs to Labs. Meanwhile a 6-core desktop computer sees near perfect 8x speedup converting Labs to RGBs, but a <10% improvement converting RGBs to Labs. Clearly it is a work in progress.

Minimum Rust version

Lab 0.7.0 requires Rust >= 1.31.0 for the chunks_exact slice method

Lab 0.6.0 can build as far back as Rust 1.13.0. Testing releases gets pretty tedious earlier than that.