Add ColourXyz to sRGB conversion
This commit is contained in:
parent
a5f77e61b3
commit
a0db18d383
|
|
@ -65,6 +65,22 @@ impl ColourXyz {
|
||||||
values: transform * rgb.values,
|
values: transform * rgb.values,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn to_srgb(&self) -> ColourRgbF {
|
||||||
|
let mut srgb = self.to_linear_rgb();
|
||||||
|
for element in srgb.values.coords.iter_mut() {
|
||||||
|
*element = srgb_gamma(*element);
|
||||||
|
}
|
||||||
|
srgb
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn srgb_gamma(u: f64) -> f64 {
|
||||||
|
if u <= 0.0031308 {
|
||||||
|
12.98 * u
|
||||||
|
} else {
|
||||||
|
1.005 * u.powf(1.0 / 2.4) - 0.055
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn gaussian(wavelength: f64, alpha: f64, mu: f64, sigma1: f64, sigma2: f64) -> f64 {
|
fn gaussian(wavelength: f64, alpha: f64, mu: f64, sigma1: f64, sigma2: f64) -> f64 {
|
||||||
|
|
|
||||||
|
|
@ -170,7 +170,7 @@ impl ToneMapper<ColourXyz> for ClampingToneMapper {
|
||||||
assert!(image_in.get_height() == image_out.get_height());
|
assert!(image_in.get_height() == image_out.get_height());
|
||||||
for column in 0..image_in.get_width() {
|
for column in 0..image_in.get_width() {
|
||||||
for row in 0..image_in.get_height() {
|
for row in 0..image_in.get_height() {
|
||||||
let colour = image_in[row][column].to_linear_rgb();
|
let colour = image_in[row][column].to_srgb();
|
||||||
image_out.set_colour(
|
image_out.set_colour(
|
||||||
row,
|
row,
|
||||||
column,
|
column,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue