Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
elbertronnie committed Oct 12, 2024
1 parent f685b5e commit 376a84b
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 13 deletions.
2 changes: 1 addition & 1 deletion libraries/raw-rs/src/demosaicing/linear_demosaicing.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{Pixel, RawImage ,Captures};
use crate::{Captures, Pixel, RawImage};

fn average(data: &[u16], indexes: impl Iterator<Item = i64>) -> u16 {
let mut sum = 0;
Expand Down
14 changes: 10 additions & 4 deletions libraries/raw-rs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,12 @@ impl RawImage {

pub fn demosaic_and_apply(self, mut transform: impl PixelTransform) -> Image<u16> {
let mut image = vec![0; self.width * self.height * 3];
for Pixel { values, row, column } in self.linear_demosaic_iter().map(|mut pixel| { pixel.values = transform.apply(pixel); pixel }) {
for Pixel { values, row, column } in self.linear_demosaic_iter().map(|mut pixel| {
pixel.values = transform.apply(pixel);
pixel
}) {
let pixel_index = row * self.width + column;
image[3 * pixel_index..3 * (pixel_index+1)].copy_from_slice(&values);
image[3 * pixel_index..3 * (pixel_index + 1)].copy_from_slice(&values);
}

Image {
Expand Down Expand Up @@ -169,9 +172,12 @@ impl Image<u16> {
pub fn transform_and_apply(self, mut transform: impl PixelTransform) -> Image<u16> {
let mut image = vec![0; self.width * self.height * 3];
let (width, height, iter) = self.transform_iter();
for Pixel { values, row, column } in iter.map(|mut pixel| { pixel.values = transform.apply(pixel); pixel }) {
for Pixel { values, row, column } in iter.map(|mut pixel| {
pixel.values = transform.apply(pixel);
pixel
}) {
let pixel_index = row * width + column;
image[3 * pixel_index..3 * (pixel_index+1)].copy_from_slice(&values);
image[3 * pixel_index..3 * (pixel_index + 1)].copy_from_slice(&values);
}

Image {
Expand Down
7 changes: 5 additions & 2 deletions libraries/raw-rs/src/postprocessing/convert_to_rgb.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{Pixel, PixelTransform, RawImage, CHANNELS_IN_RGB, Histogram};
use crate::{Histogram, Pixel, PixelTransform, RawImage, CHANNELS_IN_RGB};

impl RawImage {
pub fn convert_to_rgb_fn(&self) -> impl Fn(Pixel) -> [u16; CHANNELS_IN_RGB] {
Expand Down Expand Up @@ -30,7 +30,10 @@ impl RecordHistogram {

impl PixelTransform for &mut RecordHistogram {
fn apply(&mut self, pixel: Pixel) -> [u16; CHANNELS_IN_RGB] {
self.histogram.iter_mut().zip(pixel.values.iter()).for_each(|(histogram, &value)| histogram[value as usize >> CHANNELS_IN_RGB] += 1);
self.histogram
.iter_mut()
.zip(pixel.values.iter())
.for_each(|(histogram, &value)| histogram[value as usize >> CHANNELS_IN_RGB] += 1);
pixel.values
}
}
6 changes: 2 additions & 4 deletions libraries/raw-rs/src/postprocessing/gamma_correction.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{Image, Pixel, Histogram, CHANNELS_IN_RGB};
use crate::{Histogram, Image, Pixel, CHANNELS_IN_RGB};
use std::f64::consts::E;

impl Image<u16> {
Expand All @@ -20,9 +20,7 @@ impl Image<u16> {

let curve = generate_gamma_curve(0.45, 4.5, (white << 3) as f64);

move |pixel: Pixel| {
pixel.values.map(|value| curve[value as usize])
}
move |pixel: Pixel| pixel.values.map(|value| curve[value as usize])
}
}

Expand Down
4 changes: 2 additions & 2 deletions libraries/raw-rs/src/postprocessing/transform.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{Image, Transform, Captures, Pixel};
use crate::{Captures, Image, Pixel, Transform};

impl Image<u16> {
pub fn transform_iter(&self) -> (usize, usize, impl Iterator<Item = Pixel> + Captures<&'_ ()>) {
Expand Down Expand Up @@ -37,7 +37,7 @@ impl Image<u16> {
index = (index.0 + row_step.0, index.1 + row_step.1);

temp
})
}),
)
}
}
Expand Down

0 comments on commit 376a84b

Please sign in to comment.