Download libraries/rawkit/src/postprocessing/record_histogram.rs from openfree/graphite2: direct link, hf CLI and curl.
- Browser
- Download file 645 Bytes
-
https://huggingface.co/spaces/openfree/graphite2/resolve/main/libraries/rawkit/src/postprocessing/record_histogram.rs
- Command line
-
hf download hf://spaces/openfree/graphite2/libraries/rawkit/src/postprocessing/record_histogram.rs
-
curl -L -o record_histogram.rs https://huggingface.co/spaces/openfree/graphite2/resolve/main/libraries/rawkit/src/postprocessing/record_histogram.rs
645 Bytes
| use crate::{CHANNELS_IN_RGB, Histogram, Pixel, PixelTransform, RawImage}; | |
| impl RawImage { | |
| pub fn record_histogram_fn(&self) -> RecordHistogram { | |
| RecordHistogram::new() | |
| } | |
| } | |
| pub struct RecordHistogram { | |
| pub histogram: Histogram, | |
| } | |
| impl RecordHistogram { | |
| fn new() -> RecordHistogram { | |
| RecordHistogram { | |
| histogram: [[0; 0x2000]; CHANNELS_IN_RGB], | |
| } | |
| } | |
| } | |
| 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); | |
| pixel.values | |
| } | |
| } | |