3
3
% Refit the gamma data from a calibration.
5
% See also CalDemo, CalibrateFitGamma, SetGammaMethod, GamutToSettings
5
7
% 3/27/02 dhb Wrote it.
6
8
% 8/26/03 dhb, jl Allow changing dacsize of calibraiton. Useful for dropping from 10 to 8.
7
9
% 2/2/05 dhb, dam Ask for filename to save to, rather than automatically overwrite.
17
19
% 5/28/10 dhb Add yoked fitting routine to calls. Should have no effect when yoked isn't set, but do the right thing when it is.
18
20
% 6/5/10 dhb Update type list provided to user.
19
21
% dhb Better plots, using plot subroutines.
22
% 5/26/12 dhb Added ability to use raw measured data as the fit gamma table. See comment where that's done below.
22
defaultFileName = 'monitor';
25
defaultFileName = 'PTB3TestCal';
23
26
thePrompt = sprintf('Enter calibration filename [%s]: ',defaultFileName);
24
27
newFileName = input(thePrompt,'s');
25
28
if (isempty(newFileName))
43
46
fprintf('Old gamma fit type was: %s\n',cal.describe.gamma.fitType);
44
47
oldType = cal.describe.gamma.fitType;
45
48
fprintf('Possible fit types are defined by routine CalibrateFitGamma\n');
46
fprintf('See "help CalibrateFitGamma for most up to date options\n');
47
fprintf('Current (June, 2010) options are:\n');
49
fprintf('See "help CalibrateFitGamma for most up to date options (except for rawdata)\n');
50
fprintf('Current (May 2012) options are:\n');
48
51
fprintf('\tsimplePower\n');
49
52
fprintf('\tcrtLinear\n');
50
53
fprintf('\tcrtPolyLinear\n');
77
81
cal = CalibrateFitLinMod(cal);
78
82
cal = CalibrateFitYoked(cal);
79
cal = CalibrateFitGamma(cal,2^cal.describe.dacsize);
84
% Switch about whether to call standard routine
85
switch (gamma.fitType)
86
% Literally use the measured data as the fit data.
87
% You only want to do this under very unusual circumstances.
88
% The reason I'm putting it in is to deal with a DLP projector
89
% whose filter wheel I ripped out, and for which the light output
90
% is highly non-monotonic with input. So, I'll measure at every
91
% possible input settings and then use exhaustive search of the
92
% gamma table to invert. This is where the output of the standard
93
% calibration program pushes the raw data into the typical field.
95
% This is probably a fairly fragile bit of code and should only be used
96
% with caution and knowledge aforethought.
98
% I put this here rather than in CalibrateFitGamma to avoid a lot of
99
% massaging done by that routine, which we do not want.
101
if (size(cal.rawdata.rawGammaTable,2) ~= cal.nDevices*cal.nPrimaryBases)
102
error('Dimensions of raw data are not correct, given number of devices and linear model size')
104
cal.gammaInput = cal.rawdata.rawGammaInput;
105
cal.gammaTable = cal.rawdata.rawGammaTable;
106
cal.gammaTable(cal.gammaTable < 0) = 0;
107
cal.gammaTable(cal.gammaTable > 1) = 1;
109
% Fit the measured data using standard PTB methods
111
cal = CalibrateFitGamma(cal,2^cal.describe.dacsize);
81
114
% Put up a plot of the essential data
82
115
CalibratePlotSpectra(cal,figure(1));