-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfilterEffectExplainer.m
141 lines (111 loc) · 3.22 KB
/
filterEffectExplainer.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
% Explainer
close all; clearvars
load('trans_bbFilters.mat')
wls = (380:780)';
filtIdx = 5;
% Load D_65
load spd_D65.mat
spd_D65 = SplineSpd(S_D65, spd_D65, wls);
spd_D65 = spd_D65./max(spd_D65);
spd_D65_filt = spd_D65.*trans_bbFilters(:, filtIdx);
% V(lambda) attenuation
subplot(1, 4, 1);
tmp = csvread('ciexyz64_1.csv');
T_xyz = 683*[tmp(find(tmp(:, 1) == 380):find(tmp(:, 1) == 780), 2:4)];
T_xyz = T_xyz';
T_V = T_xyz(2, :);
T_V = T_V/max(T_V);
T_a1 = T_V.*spd_D65';
plot(wls, spd_D65); hold on
area(wls, T_a1)
xlim([380 780]);
T_a2 = T_V.*spd_D65_filt';
plot(wls, spd_D65_filt); hold on
area(wls, T_a2)
xlim([380 780]);
ylim([0 1.01]);
set(gca, 'XTick', [400:50:800]);
title(num2str(nansum(T_a2)/nansum(T_a1)))
plot(wls, trans_bbFilters(:, filtIdx));
pbaspect([1 1 1]);
set(gca, 'TickDir', 'out');
xlabel('Wavelength [nm]');
box off;
% Mel attenuation
subplot(1, 4, 2);
tmp = GetCIES026;
T_mel = tmp(5, :);
T_a1 = T_mel.*spd_D65';
plot(wls, spd_D65); hold on
area(wls, T_a1)
xlim([380 780]);
T_a2 = T_mel.*spd_D65_filt';
plot(wls, spd_D65_filt); hold on
area(wls, T_a2)
xlim([380 780]);
ylim([0 1.01]);
set(gca, 'XTick', [400:50:800]);
title(num2str(nansum(T_a2)/nansum(T_a1)))
plot(wls, trans_bbFilters(:, filtIdx));
pbaspect([1 1 1]);
set(gca, 'TickDir', 'out');
xlabel('Wavelength [nm]');
box off;
% Colour shift
% Make EEW
spd = ones(size(wls_bbFilters));
% Calculate the ratio
XYZ = (T_xyz*spd_D65_filt);
uvY = XYZTouvY(XYZ);
uv = uvY(1:2, :);
XYZ0 = (T_xyz*(spd));
uvY0 = XYZTouvY(XYZ0);
uv0 = uvY0(1:2, :);
chromDiff = sqrt(sum((uv0-uv).^2));
% Generate spectral locus for uv
theWls = [700 400:700];
for ii = 1:length(theWls)
spd = zeros(size(wls_bbFilters));
spd(theWls(ii) == wls_bbFilters) = 1;
% Get ref
XYZref = (T_xyz*(spd));
uvYref = XYZTouvY(XYZref);
uvref(:, ii) = uvYref(1:2, :);
end
% Plot chromaticity diagram
subplot(1, 4, 3);
plot(uvref(1, :), uvref(2, :), ':k'); hold on;
plot(uv(1), uv(2), 'sk', 'MarkerFaceColor', 'w');
plot(uv0(1), uv0(2), '+r');
pbaspect([1 1 1]);
xlim([0 0.61]); ylim([0 0.61]);
set(gca, 'XTick', 0:0.2:0.6);
set(gca, 'YTick', 0:0.2:0.7);
box off; set(gca, 'TickDir', 'out');
xlabel('CIE u'); ylabel('CIE v');
% Colour gamut
reflectances = xlsread('99Reflectances.xlsx');
srf_cie = SplineSpd([380 5 81], reflectances, wls_bbFilters);
subplot(1, 4, 4);
XYZsrf = (T_xyz*(srf_cie .* spd_D65));
uvYsrf = XYZTouvY(XYZsrf);
uvsrf = uvYsrf(1:2, :);
[idx_cvhull, area_cvhull] = convhull(uvsrf(1, :), uvsrf(2, :));
XYZsrf_filt = (T_xyz*(srf_cie .* spd_D65_filt));
uvYsrf_filt = XYZTouvY(XYZsrf_filt);
uvsrf_filt = uvYsrf_filt(1:2, :);
[idx_cvhull_filt, area_cvhull_filt] = convhull(uvsrf_filt(1, :), uvsrf_filt(2, :));
plot(uvref(1, :), uvref(2, :), ':k'); hold on;
plot(uvsrf(1, :), uvsrf(2, :), '.r'); hold on
plot(uvsrf(1, idx_cvhull), uvsrf(2, idx_cvhull), 'r'); hold on
plot(uvsrf_filt(1, :), uvsrf_filt(2, :), '.k');
plot(uvsrf_filt(1, idx_cvhull_filt), uvsrf_filt(2, idx_cvhull_filt), '-k');
pbaspect([1 1 1]);
xlim([0 0.61]); ylim([0 0.61]);
set(gca, 'XTick', 0:0.2:0.6);
set(gca, 'YTick', 0:0.2:0.7);
box off; set(gca, 'TickDir', 'out');
xlabel('CIE u'); ylabel('CIE v');
set(gcf, 'PaperPosition', [0 0 25 15]);
set(gcf, 'PaperSize', [25 15]);
saveas(gcf, 'xProducts/Fig4.pdf', 'pdf');