pub struct PrintContext { /* private fields */ }Expand description
The spectral model of the enlarger and the paper.
Implementations§
Source§impl PrintContext
impl PrintContext
Sourcepub fn new(reference_density: [f64; 3]) -> Self
pub fn new(reference_density: [f64; 3]) -> Self
Build the context, anchoring the output on a reference negative density.
The anchor is what makes the print balance solvable: everything is reported relative to the light the reference negative passes, so a mid-grey negative lands at log exposure 0 on every layer.
§Panics
Cannot panic: the grid is a valid constant.
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 with_dyes(self, dye: [Spectrum; 3]) -> Self
pub fn with_dyes(self, dye: [Spectrum; 3]) -> Self
Replace only the dye spectra, keeping the paper layers.
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 balance_gain(&self, neutral_density: f64) -> [f64; 3]
pub fn balance_gain(&self, neutral_density: f64) -> [f64; 3]
The gain the grey balance applies at a neutral density, per layer.
A diagnostic: if real dyes are neutral by design, these gains should be close to 1 and the numerical balance is doing nothing.
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 with_enlarger(self, pack: FilterPack, glass: Option<HeatGlass>) -> Self
pub fn with_enlarger(self, pack: FilterPack, glass: Option<HeatGlass>) -> Self
The enlarger, from measured spectra instead of the placeholder bands.
The three Gaussian filter_bands and the equal-energy illuminant are
the model from before the data existed. This replaces the illuminant with
lamp × heat glass × pack, in that order, normalised to its own peak — the
print’s exposure is solved, so a common factor is an exposure time and not
a measurement.
The reference is not recomputed, and that is the modelling choice:
the grey balance stands in for dye and coupler design (see balanced),
so it is computed for the print as the film and paper make it, without
the enlarger. A pack therefore arrives as an imbalance — the cast a
printer sees and dials away — instead of being absorbed into the
material’s own correction. Zero pack and no glass leave the model exactly
as it was, equal-energy light included.
Sourcepub fn with_filters(self, filters: [f64; 3]) -> Self
pub fn with_filters(self, filters: [f64; 3]) -> Self
Set the enlarger filter pack, in Kodak colour-correction units.
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 solve_filters(&self, density: f64) -> [f64; 3]
pub fn solve_filters(&self, density: f64) -> [f64; 3]
Solve for the filter pack that makes a neutral negative print neutral.
The filters change the ratio of the three layer responses, which is exactly what a printer adjusts with test strips. Two unknowns, two ratios, so a coarse grid followed by a refinement is enough and is easier to trust than a gradient step on a function with clamps in it.
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(reference_density: [f64; 3]) -> Self
pub fn measured(reference_density: [f64; 3]) -> Self
Build the context the renderer uses: every spectrum measured.
The dyes, the paper’s layers and the mask are the digitised curves from
crate::measured; the mask is coupled, so it is consumed where the cyan
dye forms. This is the model, and Self::new is what it is compared
against.
§Panics
Cannot panic: the tables are compile-time constants on the internal grid.
Sourcepub fn measured_with(
reference_density: [f64; 3],
film_dyes: &[[f64; 71]; 3],
film_mask: &[f64; 71],
paper_layers: &[[f64; 71]; 3],
) -> Self
pub fn measured_with( reference_density: [f64; 3], film_dyes: &[[f64; 71]; 3], film_mask: &[f64; 71], paper_layers: &[[f64; 71]; 3], ) -> Self
As Self::measured, on one film’s spectra and one paper’s layers.
Both are properties of the stock — the dye set and the layer speeds differ between products — so the caller passes them rather than this taking whichever sheet was digitised first. The film’s dyes are what the print sees; the paper’s layers are what it responds with.
Sourcepub fn with_base_density(self, base: Spectrum) -> Self
pub fn with_base_density(self, base: Spectrum) -> Self
Add the film’s minimum density: base, fog and the orange mask.
The published dye curves have D-min subtracted, so the mask is not in them. Without it a neutral negative does not print neutral, and the grey balance is left compensating for a physical layer that was removed from the data.
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 with_masking(self, masking: Masking) -> Self
pub fn with_masking(self, masking: Masking) -> Self
Let the base density be destroyed as the dyes form.
Without this the mask is a constant, which is what an unexposed frame looks like and not what an exposed one does.
Sourcepub fn with_spectra(self, dye: [Spectrum; 3], paper: [Spectrum; 3]) -> Self
pub fn with_spectra(self, dye: [Spectrum; 3], paper: [Spectrum; 3]) -> Self
Replace the placeholder bands with measured spectra.
The spectra are resampled onto the internal grid, so anything digitised on a uniform grid can be passed in. The reference response is recomputed, because the anchor depends 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 expose(&self, density_cmy: [f64; 3]) -> [f64; 3]
pub fn expose(&self, density_cmy: [f64; 3]) -> [f64; 3]
log10 of the paper’s layer response, relative to the reference negative.
Sourcepub fn model(&self) -> Option<PrintModel>
pub fn model(&self) -> Option<PrintModel>
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_spectra does not have to.
Trait Implementations§
Source§impl Clone for PrintContext
impl Clone for PrintContext
Auto Trait Implementations§
impl Forget for PrintContext
impl Freeze for PrintContext
impl Move for PrintContext
impl RefUnwindSafe for PrintContext
impl Send for PrintContext
impl Sync for PrintContext
impl Unpin for PrintContext
impl UnsafeUnpin for PrintContext
impl UnwindSafe for PrintContext
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