Skip to content

Commit

Permalink
Initial commit after cleaning, adding functionality from ISETBIO, and…
Browse files Browse the repository at this point in the history
… deciding to go free for noncommercial folks.
  • Loading branch information
wandell committed Feb 20, 2018
1 parent 2f4a03f commit ce7609d
Show file tree
Hide file tree
Showing 1,464 changed files with 136,433 additions and 0 deletions.
74 changes: 74 additions & 0 deletions ISET.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
% ISET -- Script to start ISET (Image Systems Evaluation Toolbox)
%
% This script initializes the ISET (Image Systems Evaluation Tool) program.
% The script checks for the existence of an isetSession file (saved from a
% previous session).
%
% The script
% * Checks the current version of Matlab, which should be 6.5 or higher
% * Initiates the ISET Session window
% * Initiates the vcSESSION (global) variable used by ISET windows
%
% Copyright ImagEval Consultants, LLC, 2003.

%% Initialize variables
% If the user already has a vcSESSION, clear it. We are going to load the
% new one from the isetSession file.
clear vcSESSION;

% Define vc global variables and structures. vc[UPPERCASE] are globals.
global vcSESSION;

% thisVersion = 1.001; % Until October 11, 2005
% this Version = 1.01; % Started Feb. 20, 2006
% thisVersion = 3.0; % Started September, 2007
thisVersion = 4.0; % Started August, 2009

ieSessionSet('version',thisVersion);

%%
version = ver('Matlab');
v = version.Version(1:3);
if v < 7.0
warning('ISET compatible with version 7.0 or greater. This version is %f\n',v)
end

disp(['ISET ',num2str(vcSESSION.VERSION),', Matlab ',version.Version]);

clear expectedMatlabVersion version matlabVersion

%% Default session file name.
% We check for a session file named iset-dateTime
%
% * If one exists, we load it.
% * If several exist, we load the latest one
% * The user can load a sessison file with a different name from the Main
% Window.

sessionFileName = 'isetSession.mat';
d = dir('iset-*.mat');
if ~isempty(d), sessionFileName = d(end).name; end

% sessionDir = pwd;
year = date; year = year(end-3:end);
fprintf('------------------\n');
fprintf('Copyright ImagEval Consulting, LLC, 2003-%s\n',year);

ieInitSession;
ieSessionSet('dir',pwd);
ieSessionSet('name',sessionFileName);

% wp = ieSessionGet('whitePoint');
% fprintf('White point for Scene/OI rendering set to %s\n',wp);

clear sessionFileName
clear thisVersion
clear sessionDir
clear v

%% Hand off control to the main ISET window
% This window lets the user bring up the scene, optics, and other windows
% This function was named ieMainWindow until December, 2008.
ieMainW

%% End
74 changes: 74 additions & 0 deletions camera/cameraAcutance.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
function acutance = cameraAcutance(camera,plotFlag)
%Compute and possibly plot the acutance of a camera using CPIQ formula
%
% acutance = cameraAcutance(camera,plotFlag)
%
% Input:
% camera: A camera model
% plotFlag: Put up a graph (or not) of the CPIQ and Camera MTF
%
% Runs ISOAcutance
%
% Returns
% Acutance, and it may produce a plot showing the CPIQ MTF along with the
% camera MTF. The acutance is the camera MTF weighted by the CPIQ MTF.
%
% Example:
% camera = cameraCreate;
% cameraAcutance(camera)
% cameraAcutance(camera,false)
%
% camera = cameraCreate('monochrome');
% cameraAcutance(camera)
%
% See also: cameraMTF, s_metricsAcutance
%
% Copyright Imageval LLC, 2014


%%
if ieNotDefined('camera'), error('camera required'); end
if ieNotDefined('plotFlag'), plotFlag = true; end

%% Compute acutance

% First, compute the MTF. Get the luminance term.
cMTF = cameraMTF(camera);
if size(cMTF.mtf,2) == 4
lumMTF = cMTF.mtf(:,4);
elseif size(cMTF.mtf,2) == 1
lumMTF = cMTF.mtf;
else
error('Unexpected cMTF %f',cMTF);
end

% cycles/mm is the default for the ISO12233 MTF. We would like to compute
% cy/deg, which is related by cpd = (cycles/mm) *(1/degPerMM)
% For the sensor, degrees is related to distance on the sensor with respect
% to the focal distance to the optics.
sensor = cameraGet(camera,'sensor');
oi = cameraGet(camera,'oi');
degPerMM = sensorGet(sensor,'h deg per distance','mm',[],oi);
cpd = cMTF.freq / degPerMM;

% Acutance is an ISO Standard.
acutance = ISOAcutance(cpd,lumMTF);

% The CPIQ is a representation of someone's idea of the human contrast
% sensitivity function. The camera MTF is a representation of what the
% camera sees. To compute acutance we need the cpiq and the camera MTF.
% Here, we plot the MTF and the cpiq, and then we calculate the acutance
% inside the function below. We put this in the title of the figure.
if plotFlag
vcNewGraphWin;
cpiq = cpiqCSF(cpd);
plot(cpd, cpiq, '-k', cpd, lumMTF,'--r');
grid on;
hold on;
xlabel('Cycles per degree'); ylabel('SFR');
title(sprintf('Acutance %.2f',acutance))
legend('CPIQ','Camera MTF')
end


%% End
22 changes: 22 additions & 0 deletions camera/cameraClearData.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
function camera = cameraClearData(camera)
% Clear the data fields from the camera structure
%
% camera = cameraClearData(camera)
%
% Calls oiClearData, sensorClearData, and L3ClearData
%
% Copyright Imageval Consulting, 2015

if ieNotDefined('camera'), error('Camera required.'); end

oi = oiClearData(cameraGet(camera,'oi'));
sensor = sensorClearData(cameraGet(camera,'sensor'));
ip = ipClearData(cameraGet(camera,'ip'));
L3 = L3ClearData(cameraGet(camera,'ip L3'));

camera = cameraSet(camera,'oi',oi);
camera = cameraSet(camera,'sensor',sensor);
camera = cameraSet(camera,'ip',ip);
camera = cameraSet(camera,'ip L3',L3);

end
63 changes: 63 additions & 0 deletions camera/cameraColorAccuracy.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
function [eAnalysis,camera] = cameraColorAccuracy(camera,lum,varargin)
% Analyze the color accuracy of a camera design
%
% [eAnalysis, camera] = ieCameraColorAccuracy(camera,lum,varargin)
%
% Copyright Imageval, LLC 2012

%% Argument checking here

if ieNotDefined('lum'), lum = 100; end % Candelas for the scene

%% Set up the MCC scene
oi = cameraGet(camera,'oi');
sensor = cameraGet(camera,'sensor');
sDist = 1000; % distance of imager from scene (m)
fov = sensorGet(sensor,'fov',sDist,oi);

mcc = sceneCreate;

% MCC scene properties
mcc = sceneAdjustLuminance(mcc,lum);
mcc = sceneSet(mcc,'fov',fov);
mcc = sceneSet(mcc,'distance',sDist);
% ieAddObject(mcc); sceneWindow;

camera = cameraCompute(camera,mcc);

%% Plot the error metric

vci = cameraGet(camera,'vci');
% ieAddObject(vci); ipWindow;

% The mcc image runs all the way horizontally, but is a few pixels short in
% the y-dimension.
sz = ipGet(vci,'size');
xMin = 1; xMax = sz(2);
yMin = 1 + 5; yMax = sz(1) - 5;
cornerPoints = [ xMin yMax; xMax yMax; xMax yMin; xMin yMin];
vci = ipSet(camera.vci,'mcc corner points',cornerPoints);
% ieAddObject(vci); ipWindow;

% If you change the size of the sensor or other spatial parameters, you may
% have to adjust these. You can use this routine to interactively click on
% the four corners of the MCC. See the message in the processor window
% that tells you the order to click on the corners.
%
% [mRGB, mLocs, pSize, pointLoc] = macbethSelect(vci);
%
% You can see the selection of rects for the patches by
% vci = macbethDrawRects(vci,'on');
% Turn them off with
% vci = macbethDrawRects(vci,'off');
%

% Compute the delta E values
% This produces a plot with several evaluations of the errors
[macbethLAB, macbethXYZ, deltaE] = macbethColorError(vci,'D65',cornerPoints);

% Store results.
eAnalysis.deltaE = deltaE;
eAnalysis.vci = vci;

return
Loading

0 comments on commit ce7609d

Please sign in to comment.