Skip to content

Commit 6030216

Browse files
committed
First draft of gamut figure code
1 parent 28a1b0e commit 6030216

File tree

1 file changed

+34
-31
lines changed

1 file changed

+34
-31
lines changed
Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
% Make a figure showing our monitor gamut in the LS contrast plane
22

3+
% Initialize
4+
clear; close all;
5+
36
% Load typical calibration file from the experiment
47
resourcesDir = getpref('ColorTracking','CalDataFolder');
58
load(fullfile(resourcesDir,'ViewSonicG220fb_670.mat'),'cals');
@@ -25,44 +28,44 @@
2528
calObj.set('P_ambient',zeros(size(calObj.get('P_ambient'))));
2629
end
2730

28-
%% Cone fundamentals and XYZ CMFs.
31+
% Cone fundamentals
2932
psiParamsStruct.coneParams = DefaultConeParams('cie_asano');
3033
psiParamsStruct.coneParams.fieldSizeDegrees = 2;
3134
psiParamsStruct.coneParams.ageYears = 30;
3235
T_cones = ComputeObserverFundamentals(psiParamsStruct.coneParams,Scolor);
33-
3436
SetSensorColorSpace(calObj,T_cones,Scolor);
35-
bgPrimary = [0.5 0.5 0.5]';
36-
bgSettings = PrimaryToSettings(calObj,bgPrimary);
37-
D.bgd = bgPrimary';
38-
39-
% Gamma Correct
40-
D.correctedBgd = bgSettings';
4137

42-
S.lookupTableSettings = [];
43-
for i = 1:length(targetContrastAngle)
44-
[lookupTableSettings,badIndex] = makeLookUpTableForCC(calObj,targetContrast(i),targetContrastAngle(i),D.correctedBgd');
45-
if any(badIndex ~= 0)
46-
warning('WARNING: %2.2f is out of gamut\n',targetContrast(i));
47-
end
48-
S.lookupTableSettings(:,:,i) = lookupTableSettings';
49-
end
38+
% Compute the background
39+
bgPrimary = [0.5 0.5 0.5]';
40+
bgCones = PrimaryToSensor(calObj,bgPrimary);
5041

51-
% MAKE INITIAL GAMMA TABLE
52-
lookupTableDesiredMonochromeContrastsCal = [linspace(-1,-2/256,256/2-1) 0 linspace(2/256,1,256/2)];
53-
lookupTableDesiredContrastCal = 1*[1;1;1]*lookupTableDesiredMonochromeContrastsCal;
54-
bgExcitations = SettingsToSensor(calObj,bgSettings);
55-
lookupTableDesiredExcitationsCal = ContrastToExcitation(lookupTableDesiredContrastCal,bgExcitations);
56-
[lookupTableSettingsInit, ~] = SensorToSettings(calObj,lookupTableDesiredExcitationsCal);
57-
S.lookupTableSettingsInit = lookupTableSettingsInit';
42+
% Find maximum in gamut contrast for a set of color directions. We
43+
% are not going to worry about device quantization since we used
44+
% high-bit depth hardware
45+
nAngles = 1000;
46+
theAngles = linspace(0,2*pi,nAngles);
47+
for aa = 1:nAngles
48+
unitContrastDir = [cos(theAngles(aa)) 0 sin(theAngles(aa))]';
49+
unitConesDir = unitContrastDir .* bgCones;
50+
unitPrimaryDir = SensorToPrimary(calObj,unitConesDir + bgCones) - SensorToPrimary(calObj,bgCones);
5851

59-
% *** REPLACE THIS WHEN THE PROPER STIMULUS IS READY ***
60-
t = 1;
61-
stm = generateStimContrastProfile(S.imgSzXYdeg(t,:),S.smpPerDeg(t),S.frqCpdL(t),S.ortDeg(t),S.phsDegL(t),bandwidthOct2sigma(S.frqCpdL(t),S.BWoct(t)));
62-
stm = stm./2 + 0.5;
63-
stm = round(stm.*255);
64-
% *******
52+
[s,sPos,sNeg] = MaximizeGamutContrast(unitPrimaryDir,bgPrimary);
53+
gamutPrimaryDir = s*unitPrimaryDir;
6554

66-
S.stmLE = stm;
67-
S.stmRE = stm;
55+
gamutCones = PrimaryToSensor(calObj,gamutPrimaryDir + bgPrimary);
56+
gamutContrast(:,aa) = (gamutCones-bgCones) ./ bgCones;
57+
vectorLengthContrast(aa) = norm(gamutContrast(:,aa));
58+
end
59+
%gamutContrast
6860

61+
% Make a plot of the gamut in the LS contrast plane
62+
figure; clf; hold on;
63+
%plot(100*gamutContrast(1,:),100*gamutContrast(3,:),'ko','MarkerSize',8);
64+
plot([-100 100],[0 0],'k:','LineWidth',0.5);
65+
plot([0 0],[-100 100],'k:','LineWidth',0.5);
66+
plot(100*gamutContrast(1,:),100*gamutContrast(3,:),'k','LineWidth',1);
67+
xlim([-100 100])
68+
ylim([-100 100]);
69+
axis('square');
70+
xlabel('L Cone Contrast (%)')
71+
ylabel('S Cone Contrast (%)');

0 commit comments

Comments
 (0)