Skip to content
Snippets Groups Projects
Commit 61fd01dc authored by Ben Heasly's avatar Ben Heasly
Browse files

refactor rtbRunEpicComparison around new, smaller functions

parent f3e508bc
No related branches found
No related tags found
No related merge requests found
......@@ -13,6 +13,7 @@ parser = inputParser();
parser.KeepUnmatched = true;
parser.addRequired('comparisons', @isstruct);
parser.addParameter('fig', figure());
parser.addParameter('figureWidth', 1000, @isnumeric);
parser.addParameter('nRows', 25, @isnumeric);
parser.addParameter('correlationMin', 0.8, @isnumeric);
parser.addParameter('correlationStep', 0.05, @isnumeric);
......@@ -21,6 +22,7 @@ parser.addParameter('errorStep', 0.5, @isnumeric);
parser.parse(comparisons, varargin{:});
comparisons = parser.Results.comparisons;
fig = parser.Results.fig;
figureWidth = parser.Results.figureWidth;
nRows = parser.Results.nRows;
correlationMin = parser.Results.correlationMin;
correlationStep = parser.Results.correlationStep;
......@@ -28,22 +30,26 @@ errorMax = parser.Results.errorMax;
errorStep = parser.Results.errorStep;
%% Summarize only good comparisons.
%% Sort the summary by size of error.
goodComparisons = comparisons([comparisons.isGoodComparison]);
relNormDiff = [goodComparisons.relNormDiff];
errorStat = [relNormDiff.max];
[~, order] = sort(errorStat);
goodComparisons = goodComparisons(order);
%% Set up the figure.
figureName = sprintf('Summary of %d rendering comparisons', ...
numel(goodComparisons));
set(fig, ...
'Name', figureName, ...
'NumberTitle', 'off');
%% Sort the summary by size of error.
relNormDiff = [goodComparisons.relNormDiff];
errorStat = [relNormDiff.max];
[~, order] = sort(errorStat);
goodComparisons = goodComparisons(order);
position = get(fig, 'Position');
if position(3) < figureWidth
position(3) = figureWidth;
set(fig, 'Position', position);
end
%% Summary of correlation coefficients.
correlationTicks = correlationMin : correlationStep : 1;
......@@ -68,7 +74,14 @@ line(correlation, 1:nLines, ...
'LineStyle', 'none', ...
'Marker', 'o', ...
'Color', [0 0 1])
title(ax(1), 'correlation');
xlabel(ax(1), 'correlation');
%% Overall title.
name = sprintf('%s vs %s', ...
goodComparisons(1).renderingA.sourceFolder, ...
goodComparisons(1).renderingB.sourceFolder);
title(ax(1), name, 'Interpreter', 'none');
%% Summary of mean and max subpixel differences.
......@@ -101,7 +114,7 @@ line(means, 1:nLines, ...
'Marker', 'o', ...
'Color', [0 0 0])
legend(ax(2), 'max', 'mean', 'Location', 'northeast');
title(ax(2), 'relative diff');
xlabel(ax(2), 'relative diff');
%% Let the user scroll both axes at the same time.
......
......@@ -46,10 +46,14 @@ set(fig, ...
ax = subplot(2, 2, 2, 'Parent', fig);
imshow(uint8(rgbA), 'Parent', ax);
title(ax, 'A');
xlabel(ax, comparison.renderingA.sourceFolder, ...
'Interpreter', 'none');
ax = subplot(2, 2, 3, 'Parent', fig);
imshow(uint8(rgbB), 'Parent', ax);
title(ax, 'B');
xlabel(ax, comparison.renderingB.sourceFolder, ...
'Interpreter', 'none');
ax = subplot(2, 2, 1, 'Parent', fig);
imshow(uint8(rgbAminusB), 'Parent', ax);
......
......@@ -45,7 +45,7 @@ parser.addRequired('folderB', @ischar);
parser.addParameter('plotSummary', true, @islogical);
parser.addParameter('closeSummary', false, @islogical);
parser.addParameter('plotImages', false, @islogical);
parser.addParameter('closeImages', true, @islogical);
parser.addParameter('closeImages', false, @islogical);
parser.addParameter('figureFolder', '', @ischar);
parser.parse(folderA, folderB, varargin{:});
folderA = parser.Results.folderA;
......@@ -56,11 +56,55 @@ plotImages = parser.Results.plotImages;
closeImages = parser.Results.closeImages;
figureFolder = parser.Results.figureFolder;
matchInfo = [];
unmatchedA = {};
unmatchedB = {};
figs = [];
%% Run the grand comparison.
[comparisons, matchInfo] = rtbCompareManyRecipes(folderA, folderB, ...
varargin{:});
%% Plot the summary.
if plotSummary
summaryFig = rtbPlotManyRecipeComparisons(comparisons, ...
varargin{:});
if ~isempty(figureFolder);
imageFileName = fullfile(figureFolder, 'epic-summary');
saveFigure(summaryFig, imageFileName);
end
if closeSummary
close(summaryFig);
else
figs = [figs summaryFig];
end
end
%% Plot the detail images for each rendering.
if plotImages
nComparisons = numel(comparisons);
imageFigs = cell(1, nComparisons);
for cc = 1:nComparisons
imageFig = rtbPlotRenderingComparison(comparisons(cc), ...
varargin{:});
if ~isempty(figureFolder);
identifier = comparisons(cc).renderingA.identifier;
imageFileName = fullfile(figureFolder, identifier);
saveFigure(imageFig, imageFileName);
end
if closeImages
close(imageFig);
else
imageFigs{cc} = imageFig;
end
end
figs = [figs imageFigs{:}];
end
%% Save a figure to file, watch out for things like uicontrols.
function saveFigure(fig, fileName)
......@@ -79,10 +123,10 @@ if 7 ~= exist(filePath, 'dir')
end
% save a png and a figure
figName = fullfile(imageCompPath, [fileName '.fig']);
figName = fullfile(filePath, [fileName '.fig']);
saveas(fig, figName, 'fig');
pngName = fullfile(imageCompPath, [fileName '.png']);
pngName = fullfile(filePath, [fileName '.png']);
set(fig, 'PaperPositionMode', 'auto');
saveas(fig, pngName, 'png');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment