Skip to content

Instantly share code, notes, and snippets.

@sbesson
Created July 11, 2012 07:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sbesson/3088736 to your computer and use it in GitHub Desktop.
Save sbesson/3088736 to your computer and use it in GitHub Desktop.
Assess performance of bfsave with regard to Matlab built-in imwrite
%% Compare bfsave with imwrite
bfCheckJavaPath()
path = '/tmp/test.ome.tiff';
N = [10 20 50 100 200 500];
T = [10 20 50 100 200 500];
r= zeros(numel(N),numel(T));
for i = 1:numel(N)
for j = 1:numel(T)
I = uint8(rand(N(i),N(i),1,1,T(j))*(2^8-1));
% Run bfsave
tic
bfsave(I,path);
t1 = toc;
delete(path)
tic
for ti = 1:T(j)
imwrite(I(:,:,:,:,ti),path);
end
t2=toc;
r(i,j) = t1/t2;
% Run bfsave
delete(path)
end
end
% define small and large fonts for graphical output
tfont = {'FontName', 'Helvetica', 'FontSize', 14, 'FontAngle', 'italic'};
sfont = {'FontName', 'Helvetica', 'FontSize', 18};
lfont = {'FontName', 'Helvetica', 'FontSize', 22};
% Plot results
figure('PaperPositionMode', 'auto','Position',[50 50 500 500]); % enable resizing
hold on;
plot(T, r ,'o-' ,'Linewidth',2)
axis square
% Set thickness of axes, ticks and assign tick labels
box on
set(gca, 'LineWidth', 1.5, sfont{:}, 'Layer', 'top');
size_legend = arrayfun(@(x) [num2str(x) 'x' num2str(x)], N, 'Unif',0);
legend(size_legend, tfont{:})
xlabel('Number of planes', lfont{:});
ylabel('Time ratio bfsave/imwrite', lfont{:});
set(gca,'LooseInset',get(gca,'TightInset'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment