-
Notifications
You must be signed in to change notification settings - Fork 0
/
RecoverCSSwithLED.m
59 lines (46 loc) · 1.36 KB
/
RecoverCSSwithLED.m
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
%Summary
% The function is to recover the camera spectral sensitivity given (the
% spectral reflectance of the samples,) the eigenvectors of the camera
% sensitivity, and the illuminant spectrum
%
%[IN]
% ill: the light source spectrum
% reflSet: the spectral reflectance of samples
% w: wavelength range
% XYZSet: the radiance captured by the camera
% e: eigenvector of the camera spectral sensitivity
%
%[OUT]
% X: the recovered camera spectral sensitivity
% A, b: Ax=b
%
function [X,A,b]=RecoverCSSwithLED(whiteImageCh, whiteSpectrum, roisCh, spectrumLED, eCh)
numLEDs = size(roisCh, 1);
A = zeros(numLEDs, size(eCh,2)); % size(eCh,2) is 3 because of 3 principal components (and not because of 3 channels!)
b = zeros(size(A,1), 1);
% deltaLambda=10;
for i=1:numLEDs
a1 = spectrumLED(i,:); %diag(spectrumLED(i,:));
a2 = eCh;
b1 = roisCh(i);
A(i,:) = spectrumLED(i,:) * eCh;% .* deltaLambda;
b(i) = roisCh(i);
end
% numRefl=size(reflSet,2);
%
% A=zeros(numRefl,size(e,2));
% b=zeros(size(A,1),1);
%
% deltaLambda=10;
%
% for i=1:numRefl
% A(i,:)=reflSet(:,i)' * diag(ill) * e .* deltaLambda;
% b(i)=XYZSet(i);
% end
% I = C * L * R; % pixel_value = camera_spectral_sensitivity * illuminant * reflectance
% I = sigma * E * L * R;
% A = ELR; % eigenvectors * illuminant * reflectance
% b = ik;
X = A \ b;
X = eCh * X;
end