rawloader
This is a rust library to extract the raw data and some metadata from digital camera images. Given an image in a supported format and camera you will be able to get everything needed to process the image:
- Identification of the camera that produced the image (both the EXIF name and a clean/canonical name)
- The raw pixels themselves, exactly as encoded by the camera
- The number of pixels to crop on the top, right, bottom, left of the image to only use the actual image area
- The black and white points of each of the color channels
- The multipliers to apply to the color channels for the white balance
- A conversion matrix between the camera color space and XYZ
- The description of the bayer pattern itself so you'll know which pixels are which color
Additionally it includes a simple set of basic raw processing steps that can be used to get decent RGB output out of the raw data:
- Black and whitelevel application
- Whitebalance
- Demosaic
- Color conversion from image colorspace
- Curve application to go from linear
- Gamma application for output
Current State
The library is still in its very beginning with only a few formats implemented:
- Minolta MRW
- Sony ARW, SRF and SR2
Usage
Here's a simple sample program that uses this library:
use env;
use File;
use *;
use BufWriter;
extern crate rawloader;
use decoders;
To do the image decoding decode the image the same way but then do:
let decoded = imageops::simple_decode(&image);
let mut f = BufWriter::new(File::create(format!("{}.ppm",file)).unwrap());
let preamble = format!("P6 {} {} {}\n", image.width, image.height, 255).into_bytes();
f.write_all(&preamble).unwrap();
for pix in decoded {
let pixel = ((pix.max(0.0)*255.0).min(255.0)) as u8;
f.write_all(&[pixel]).unwrap();
}
}
And this will write out an 8bit RGB image.
Contributing
Bug reports and pull requests welcome at https://github.com/pedrocr/rawloader