Raw-rs: add post-processing steps (#1923)

* add convert_to_rgb step

* add code to generate gamma correction curve

* add gamma correction step

* fix clippy warnings and cargo fmt

* remove unnecessary dependencies

* Code review 1

* Code review 2

* fix the order of operations

* Code review 3

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
Elbert Ronnie
2024-08-21 18:34:27 -07:00
committed by GitHub
co-authored by Keavon Chambers
parent 40fd4473a7
commit a7840b252d
13 changed files with 281 additions and 99 deletions
-11
View File
@@ -6,7 +6,6 @@ use raw_rs::RawImage;
use image::codecs::png::{CompressionType, FilterType, PngEncoder};
use image::{ColorType, ImageEncoder};
use libraw::Processor;
use palette::{LinSrgb, Srgb};
use std::collections::HashMap;
use std::fmt::Write;
use std::fs::{read_dir, File};
@@ -69,16 +68,6 @@ fn test_images_match_with_libraw() {
}
fn store_image(path: &Path, suffix: &str, data: &mut [u8], width: usize, height: usize) {
if suffix == "raw_rs" {
for pixel in data.chunks_mut(3) {
let lin_srgb: LinSrgb<f64> = LinSrgb::new(pixel[0], pixel[1], pixel[2]).into_format();
let output: Srgb<u8> = Srgb::from_linear(lin_srgb);
pixel[0] = output.red;
pixel[1] = output.green;
pixel[2] = output.blue;
}
}
let mut output_path = PathBuf::new();
if let Some(parent) = path.parent() {
output_path.push(parent);