pub struct ScanContext { /* private fields */ }Expand description
The spectral model of the scan.
Implementations§
Source§impl ScanContext
impl ScanContext
Sourcepub fn new() -> Self
pub fn new() -> Self
Examples found in repository?
18fn main() {
19 let placeholder = PrintContext::new([1.2, 1.1, 1.0]);
20 let real = PrintContext::new([1.2, 1.1, 1.0]).with_dyes([
21 read("vision3_500t_cyan"),
22 read("vision3_500t_magenta"),
23 read("vision3_500t_yellow"),
24 ]);
25
26 println!(
27 "{:<10} {:>22} {:>22}",
28 "density", "placeholder gains", "measured gains"
29 );
30 for step in 1..=10 {
31 let density = 0.2 * f64::from(step);
32 let a = placeholder.balance_gain(density);
33 let b = real.balance_gain(density);
34 println!(
35 "{density:<10.1} [{:>6.3} {:>6.3} {:>6.3}] [{:>6.3} {:>6.3} {:>6.3}]",
36 a[0], a[1], a[2], b[0], b[1], b[2]
37 );
38 }
39
40 let full = PrintContext::new([1.2, 1.1, 1.0]).with_spectra(
41 [
42 read("vision3_500t_cyan"),
43 read("vision3_500t_magenta"),
44 read("vision3_500t_yellow"),
45 ],
46 [
47 read("paper_endura_metallic_sensitivity_cyan"),
48 read("paper_endura_metallic_sensitivity_magenta"),
49 read("paper_endura_metallic_sensitivity_yellow"),
50 ],
51 );
52 let masked = PrintContext::new([1.2, 1.1, 1.0])
53 .with_spectra(
54 [
55 read("vision3_500t_cyan"),
56 read("vision3_500t_magenta"),
57 read("vision3_500t_yellow"),
58 ],
59 [
60 read("paper_endura_metallic_sensitivity_cyan"),
61 read("paper_endura_metallic_sensitivity_magenta"),
62 read("paper_endura_metallic_sensitivity_yellow"),
63 ],
64 )
65 .with_base_density(read("vision3_500t_minimum_density"));
66
67 println!();
68 println!("solving the enlarger filter pack on the measured model:");
69 let solved = masked.solve_filters(1.0);
70 println!(
71 " solved {:.0}Y {:.0}M {:.0}C (Kodak CC units)",
72 solved[0], solved[1], solved[2]
73 );
74 let filtered = masked.clone().with_filters(solved);
75 for density in [0.5, 1.0, 1.5, 2.0] {
76 let g = filtered.balance_gain(density);
77 let spread = g.iter().copied().fold(f64::NEG_INFINITY, f64::max)
78 - g.iter().copied().fold(f64::INFINITY, f64::min);
79 println!(
80 " D={density:>3.1}: gains [{:>5.3} {:>5.3} {:>5.3}] spread {spread:.3}",
81 g[0], g[1], g[2]
82 );
83 }
84
85 println!();
86 println!("measured film dyes + papers + minimum density (the mask):");
87 for step in 1..=10 {
88 let density = 0.2 * f64::from(step);
89 let g = masked.balance_gain(density);
90 let spread = g.iter().copied().fold(f64::NEG_INFINITY, f64::max)
91 - g.iter().copied().fold(f64::INFINITY, f64::min);
92 println!(
93 " {density:>4.1}: gains [{:>5.3} {:>5.3} {:>5.3}] spread {spread:.3}",
94 g[0], g[1], g[2]
95 );
96 }
97
98 println!();
99 println!("measured film dyes + measured paper layers:");
100 for step in 1..=10 {
101 let density = 0.2 * f64::from(step);
102 let g = full.balance_gain(density);
103 let spread = g.iter().copied().fold(f64::NEG_INFINITY, f64::max)
104 - g.iter().copied().fold(f64::INFINITY, f64::min);
105 println!(
106 " {density:>4.1}: gains [{:>5.3} {:>5.3} {:>5.3}] spread {spread:.3}",
107 g[0], g[1], g[2]
108 );
109 }
110
111 println!();
112 println!("paper dyes in the scan, neutral densities (should be neutral):");
113 let scan = ScanContext::new().with_dyes([
114 read("paper_endura_metallic_cyan"),
115 read("paper_endura_metallic_magenta"),
116 read("paper_endura_metallic_yellow"),
117 ]);
118 for step in 1..=6 {
119 let density = 0.3 * f64::from(step);
120 let rgb = scan.scan([density; 3]);
121 let spread = rgb.iter().copied().fold(f64::NEG_INFINITY, f64::max)
122 - rgb.iter().copied().fold(f64::INFINITY, f64::min);
123 println!(
124 " {density:>4.1}: rgb [{:>5.3} {:>5.3} {:>5.3}] spread {spread:.3}",
125 rgb[0], rgb[1], rgb[2]
126 );
127 }
128
129 println!();
130 println!("spread of the gains (1.0 = the balance does nothing):");
131 for step in 1..=10 {
132 let density = 0.2 * f64::from(step);
133 let spread = |g: [f64; 3]| {
134 g.iter().copied().fold(f64::NEG_INFINITY, f64::max)
135 - g.iter().copied().fold(f64::INFINITY, f64::min)
136 };
137 println!(
138 " {density:>4.1}: placeholder {:.3} measured {:.3}",
139 spread(placeholder.balance_gain(density)),
140 spread(real.balance_gain(density))
141 );
142 }
143}Sourcepub fn measured() -> Self
pub fn measured() -> Self
Replace the placeholder image dyes with measured spectra.
Build the context the renderer uses: the paper’s dyes are measured.
§Panics
Cannot panic: the tables are compile-time constants on the internal grid.
Sourcepub fn measured_with(dyes: &[[f64; 71]; 3]) -> Self
pub fn measured_with(dyes: &[[f64; 71]; 3]) -> Self
As Self::measured, on the dyes of a particular paper.
Sourcepub fn with_dyes(self, dye: [Spectrum; 3]) -> Self
pub fn with_dyes(self, dye: [Spectrum; 3]) -> Self
White, the neutral-axis table and every derived quantity are recomputed, because all three depend on the dyes.
Examples found in repository?
18fn main() {
19 let placeholder = PrintContext::new([1.2, 1.1, 1.0]);
20 let real = PrintContext::new([1.2, 1.1, 1.0]).with_dyes([
21 read("vision3_500t_cyan"),
22 read("vision3_500t_magenta"),
23 read("vision3_500t_yellow"),
24 ]);
25
26 println!(
27 "{:<10} {:>22} {:>22}",
28 "density", "placeholder gains", "measured gains"
29 );
30 for step in 1..=10 {
31 let density = 0.2 * f64::from(step);
32 let a = placeholder.balance_gain(density);
33 let b = real.balance_gain(density);
34 println!(
35 "{density:<10.1} [{:>6.3} {:>6.3} {:>6.3}] [{:>6.3} {:>6.3} {:>6.3}]",
36 a[0], a[1], a[2], b[0], b[1], b[2]
37 );
38 }
39
40 let full = PrintContext::new([1.2, 1.1, 1.0]).with_spectra(
41 [
42 read("vision3_500t_cyan"),
43 read("vision3_500t_magenta"),
44 read("vision3_500t_yellow"),
45 ],
46 [
47 read("paper_endura_metallic_sensitivity_cyan"),
48 read("paper_endura_metallic_sensitivity_magenta"),
49 read("paper_endura_metallic_sensitivity_yellow"),
50 ],
51 );
52 let masked = PrintContext::new([1.2, 1.1, 1.0])
53 .with_spectra(
54 [
55 read("vision3_500t_cyan"),
56 read("vision3_500t_magenta"),
57 read("vision3_500t_yellow"),
58 ],
59 [
60 read("paper_endura_metallic_sensitivity_cyan"),
61 read("paper_endura_metallic_sensitivity_magenta"),
62 read("paper_endura_metallic_sensitivity_yellow"),
63 ],
64 )
65 .with_base_density(read("vision3_500t_minimum_density"));
66
67 println!();
68 println!("solving the enlarger filter pack on the measured model:");
69 let solved = masked.solve_filters(1.0);
70 println!(
71 " solved {:.0}Y {:.0}M {:.0}C (Kodak CC units)",
72 solved[0], solved[1], solved[2]
73 );
74 let filtered = masked.clone().with_filters(solved);
75 for density in [0.5, 1.0, 1.5, 2.0] {
76 let g = filtered.balance_gain(density);
77 let spread = g.iter().copied().fold(f64::NEG_INFINITY, f64::max)
78 - g.iter().copied().fold(f64::INFINITY, f64::min);
79 println!(
80 " D={density:>3.1}: gains [{:>5.3} {:>5.3} {:>5.3}] spread {spread:.3}",
81 g[0], g[1], g[2]
82 );
83 }
84
85 println!();
86 println!("measured film dyes + papers + minimum density (the mask):");
87 for step in 1..=10 {
88 let density = 0.2 * f64::from(step);
89 let g = masked.balance_gain(density);
90 let spread = g.iter().copied().fold(f64::NEG_INFINITY, f64::max)
91 - g.iter().copied().fold(f64::INFINITY, f64::min);
92 println!(
93 " {density:>4.1}: gains [{:>5.3} {:>5.3} {:>5.3}] spread {spread:.3}",
94 g[0], g[1], g[2]
95 );
96 }
97
98 println!();
99 println!("measured film dyes + measured paper layers:");
100 for step in 1..=10 {
101 let density = 0.2 * f64::from(step);
102 let g = full.balance_gain(density);
103 let spread = g.iter().copied().fold(f64::NEG_INFINITY, f64::max)
104 - g.iter().copied().fold(f64::INFINITY, f64::min);
105 println!(
106 " {density:>4.1}: gains [{:>5.3} {:>5.3} {:>5.3}] spread {spread:.3}",
107 g[0], g[1], g[2]
108 );
109 }
110
111 println!();
112 println!("paper dyes in the scan, neutral densities (should be neutral):");
113 let scan = ScanContext::new().with_dyes([
114 read("paper_endura_metallic_cyan"),
115 read("paper_endura_metallic_magenta"),
116 read("paper_endura_metallic_yellow"),
117 ]);
118 for step in 1..=6 {
119 let density = 0.3 * f64::from(step);
120 let rgb = scan.scan([density; 3]);
121 let spread = rgb.iter().copied().fold(f64::NEG_INFINITY, f64::max)
122 - rgb.iter().copied().fold(f64::INFINITY, f64::min);
123 println!(
124 " {density:>4.1}: rgb [{:>5.3} {:>5.3} {:>5.3}] spread {spread:.3}",
125 rgb[0], rgb[1], rgb[2]
126 );
127 }
128
129 println!();
130 println!("spread of the gains (1.0 = the balance does nothing):");
131 for step in 1..=10 {
132 let density = 0.2 * f64::from(step);
133 let spread = |g: [f64; 3]| {
134 g.iter().copied().fold(f64::NEG_INFINITY, f64::max)
135 - g.iter().copied().fold(f64::INFINITY, f64::min)
136 };
137 println!(
138 " {density:>4.1}: placeholder {:.3} measured {:.3}",
139 spread(placeholder.balance_gain(density)),
140 spread(real.balance_gain(density))
141 );
142 }
143}Sourcepub fn illuminant(&self) -> &Spectrum
pub fn illuminant(&self) -> &Spectrum
The viewing illuminant.
Sourcepub fn neutral_rgb(&self) -> &[[f64; 3]]
pub fn neutral_rgb(&self) -> &[[f64; 3]]
RGB along the neutral axis, evenly spaced in density from zero to the
span Self::model reports as neutral_max_density.
Sourcepub fn model(&self) -> Option<ScanModel>
pub fn model(&self) -> Option<ScanModel>
The constants this context integrates with, flattened for another backend.
None when a table is not on the model’s grid, which Self::new rules
out but Self::with_dyes does not have to.
Sourcepub fn scan(&self, density_cmy: [f64; 3]) -> [f64; 3]
pub fn scan(&self, density_cmy: [f64; 3]) -> [f64; 3]
Linear-light RGB for a set of print densities.
White is normalised to 1.0 per channel and the result is clamped to
[0, 1]; the paper cannot reflect more than it receives.
Examples found in repository?
18fn main() {
19 let placeholder = PrintContext::new([1.2, 1.1, 1.0]);
20 let real = PrintContext::new([1.2, 1.1, 1.0]).with_dyes([
21 read("vision3_500t_cyan"),
22 read("vision3_500t_magenta"),
23 read("vision3_500t_yellow"),
24 ]);
25
26 println!(
27 "{:<10} {:>22} {:>22}",
28 "density", "placeholder gains", "measured gains"
29 );
30 for step in 1..=10 {
31 let density = 0.2 * f64::from(step);
32 let a = placeholder.balance_gain(density);
33 let b = real.balance_gain(density);
34 println!(
35 "{density:<10.1} [{:>6.3} {:>6.3} {:>6.3}] [{:>6.3} {:>6.3} {:>6.3}]",
36 a[0], a[1], a[2], b[0], b[1], b[2]
37 );
38 }
39
40 let full = PrintContext::new([1.2, 1.1, 1.0]).with_spectra(
41 [
42 read("vision3_500t_cyan"),
43 read("vision3_500t_magenta"),
44 read("vision3_500t_yellow"),
45 ],
46 [
47 read("paper_endura_metallic_sensitivity_cyan"),
48 read("paper_endura_metallic_sensitivity_magenta"),
49 read("paper_endura_metallic_sensitivity_yellow"),
50 ],
51 );
52 let masked = PrintContext::new([1.2, 1.1, 1.0])
53 .with_spectra(
54 [
55 read("vision3_500t_cyan"),
56 read("vision3_500t_magenta"),
57 read("vision3_500t_yellow"),
58 ],
59 [
60 read("paper_endura_metallic_sensitivity_cyan"),
61 read("paper_endura_metallic_sensitivity_magenta"),
62 read("paper_endura_metallic_sensitivity_yellow"),
63 ],
64 )
65 .with_base_density(read("vision3_500t_minimum_density"));
66
67 println!();
68 println!("solving the enlarger filter pack on the measured model:");
69 let solved = masked.solve_filters(1.0);
70 println!(
71 " solved {:.0}Y {:.0}M {:.0}C (Kodak CC units)",
72 solved[0], solved[1], solved[2]
73 );
74 let filtered = masked.clone().with_filters(solved);
75 for density in [0.5, 1.0, 1.5, 2.0] {
76 let g = filtered.balance_gain(density);
77 let spread = g.iter().copied().fold(f64::NEG_INFINITY, f64::max)
78 - g.iter().copied().fold(f64::INFINITY, f64::min);
79 println!(
80 " D={density:>3.1}: gains [{:>5.3} {:>5.3} {:>5.3}] spread {spread:.3}",
81 g[0], g[1], g[2]
82 );
83 }
84
85 println!();
86 println!("measured film dyes + papers + minimum density (the mask):");
87 for step in 1..=10 {
88 let density = 0.2 * f64::from(step);
89 let g = masked.balance_gain(density);
90 let spread = g.iter().copied().fold(f64::NEG_INFINITY, f64::max)
91 - g.iter().copied().fold(f64::INFINITY, f64::min);
92 println!(
93 " {density:>4.1}: gains [{:>5.3} {:>5.3} {:>5.3}] spread {spread:.3}",
94 g[0], g[1], g[2]
95 );
96 }
97
98 println!();
99 println!("measured film dyes + measured paper layers:");
100 for step in 1..=10 {
101 let density = 0.2 * f64::from(step);
102 let g = full.balance_gain(density);
103 let spread = g.iter().copied().fold(f64::NEG_INFINITY, f64::max)
104 - g.iter().copied().fold(f64::INFINITY, f64::min);
105 println!(
106 " {density:>4.1}: gains [{:>5.3} {:>5.3} {:>5.3}] spread {spread:.3}",
107 g[0], g[1], g[2]
108 );
109 }
110
111 println!();
112 println!("paper dyes in the scan, neutral densities (should be neutral):");
113 let scan = ScanContext::new().with_dyes([
114 read("paper_endura_metallic_cyan"),
115 read("paper_endura_metallic_magenta"),
116 read("paper_endura_metallic_yellow"),
117 ]);
118 for step in 1..=6 {
119 let density = 0.3 * f64::from(step);
120 let rgb = scan.scan([density; 3]);
121 let spread = rgb.iter().copied().fold(f64::NEG_INFINITY, f64::max)
122 - rgb.iter().copied().fold(f64::INFINITY, f64::min);
123 println!(
124 " {density:>4.1}: rgb [{:>5.3} {:>5.3} {:>5.3}] spread {spread:.3}",
125 rgb[0], rgb[1], rgb[2]
126 );
127 }
128
129 println!();
130 println!("spread of the gains (1.0 = the balance does nothing):");
131 for step in 1..=10 {
132 let density = 0.2 * f64::from(step);
133 let spread = |g: [f64; 3]| {
134 g.iter().copied().fold(f64::NEG_INFINITY, f64::max)
135 - g.iter().copied().fold(f64::INFINITY, f64::min)
136 };
137 println!(
138 " {density:>4.1}: placeholder {:.3} measured {:.3}",
139 spread(placeholder.balance_gain(density)),
140 spread(real.balance_gain(density))
141 );
142 }
143}Trait Implementations§
Source§impl Clone for ScanContext
impl Clone for ScanContext
Source§impl Debug for ScanContext
impl Debug for ScanContext
Auto Trait Implementations§
impl Forget for ScanContext
impl Freeze for ScanContext
impl Move for ScanContext
impl RefUnwindSafe for ScanContext
impl Send for ScanContext
impl Sync for ScanContext
impl Unpin for ScanContext
impl UnsafeUnpin for ScanContext
impl UnwindSafe for ScanContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more