Created
July 11, 2012 07:30
-
-
Save sbesson/3088736 to your computer and use it in GitHub Desktop.
Assess performance of bfsave with regard to Matlab built-in imwrite
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%% 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