-
Notifications
You must be signed in to change notification settings - Fork 2
/
density levels.py
68 lines (54 loc) · 1.06 KB
/
density levels.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# script to demonstrate calculation of white balance and density balance from two gray patches on a negative scan
# by Aaron Buchler, 2023
# https://github.com/abpy/color-neg-resources
from math import log10
# darker gray patch, lower density (light) negative
r1 = .094
g1 = .131
b1 = .050
# lighter gray patch, higher density (dark) negative
r2 = 0.048
g2 = 0.054
b2 = 0.016
r1 = log10(1 / r1)
g1 = log10(1 / g1)
b1 = log10(1 / b1)
r2 = log10(1 / r2)
g2 = log10(1 / g2)
b2 = log10(1 / b2)
rs = 1 / (r2 - r1)
gs = 1 / (g2 - g1)
bs = 1 / (b2 - b1)
# green channel is 1.0
div = gs
rs = rs / div
gs = gs / div
bs = bs / div
rd = r1 * rs
gd = g1 * gs
bd = b1 * bs
# green channel is 1.0
md = gd
ra = (md - rd) / rs
ga = (md - gd) / gs
ba = (md - bd) / bs
rm = 1 / (10 ** ra)
gm = 1 / (10 ** ga)
bm = 1 / (10 ** ba)
# density add
print("density add")
print(ra)
print(ga)
print(ba)
print()
# linear multiply
print("linear multiply")
print(rm)
print(gm)
print(bm)
print()
# density multiply / linear power
print("density multiply/linear power")
print(rs)
print(gs)
print(bs)