Reputation: 381
I have read the paper by Eric Dubois https://www.site.uottawa.ca/~edubois/icassp01/anaglyphdubois.pdf but don't understand from it how to calculate the two 3 x 3 matrices for a particular pair of colored filters and display device. Dubois gives matrices designed for red/cyan glasses and CRT/plasma display at https://www.site.uottawa.ca/~edubois/anaglyph/LeastSquaresHowToPhotoshop.pdf.
What is most puzzling is that the paper says "The approximation is carried out independently at each sample location", implying that the calculation is image-dependent, whereas the matrices are presented as being applicable to any image.
Upvotes: 1
Views: 275
Reputation: 381
The calculation is clearly explained by Sanders and McAllister at https://www.researchgate.net/publication/2852372_Producing_Anaglyphs_from_Synthetic_Images. (They create a 6 x 3 matrix instead of two 3 x 3 matrices.) I have reproduced their matrix B with this Python script:-
import numpy as np
AL = np.array([[5.42327, .807004, .047325], # Left anaglyph filter
[2.70972, .50201, .0250529],
[.0000550941, .000411221, .00240686]])
AR = np.array([[.180431, 1.6395, 2.00309], # Right anaglyph filter
[.448214, 6.31551, 1.35757],
[.289201, 2.3925, 11.062]])
R = np.concatenate((AL, AR))
C = np.array([[11.6638, 8.3959, 4.65843], # CRT spectral distribution
[7.10807, 16.6845, 2.45008],
[.527874, 3.79124, 24.0604]])
Z = np.array([[0, 0, 0],
[0, 0, 0],
[0, 0, 0]])
D = np.concatenate((np.concatenate((C, Z), 1), np.concatenate((Z, C), 1)))
B = np.dot(np.dot(np.linalg.inv(np.dot(R.transpose(), R)), R.transpose()), D)
N = np.diagflat([1 / sum(B[0]), 1 / sum(B[1]), 1 / sum(B[2])])
print(np.dot(N, B))
[[ 0.45610004 0.50048381 0.17638087 -0.0434706 -0.08793882 -0.00155529]
[-0.04008216 -0.03782458 -0.01575895 0.37847603 0.73363998 -0.01845032]
[-0.01521607 -0.02059714 -0.00546856 -0.07215268 -0.11296065 1.2263951 ]]
Upvotes: 1