function mmbench( count ) % MMBENCH benchmarking main functions of the toolbox. % % MMBENCH( COUNT ) % % Input: % COUNT - Number of repetitions of each function. DEFAULT: 10. % % MMBENCH measures the speed of many of SDC Morphology Toolbox % functions in seconds. At the end, it evaluates the speed of this % computer compared to the Sun Sparc 2, using the same benchmark of % the MATLAB BENCH function. An illustrative example of the output % of MMBENCH is, for a MS-Windows ME Pentium III, 850MHz, 60MB RAM % machine: % % % SDC Morphology Toolbox V1.00 Benchmark % Made on 28-Nov-2001 computer=PCWIN % image filename=csample.jpg, width=640, height=480 % This machine is 12.50000 faster than Sun Sparc 2 % Function time (sec.) % 1. Union binary 0.054000 % 2. Union gray-scale 0.017000 % 3. Dilation bin, mmsecross 0.044000 % 4. Dilation gray-scale, mmsecross 0.022000 % 5. Dilation gray, non-flat 3x3 SE 0.050000 % 6. Open binary, mmsecross 0.060000 % 7. Open gray-scale, mmsecross 0.044000 % 8. Open gray, non-flat 3x3 SE 0.099000 % 9. Distance mmsecross 0.104000 % 10. Distance Euclidean 0.121000 % 11. Geodesic distance mmsecross 0.132000 % 12. Geodesic distance Euclidean 1.357000 % 13. Area open bin 0.247000 % 14. Area open gray-scale 0.434000 % 15. Label mmsecross 0.153000 % 16. Regional maximum, mmsecross 0.160000 % 17. Open by rec, gray, mmsecross 0.160000 % 18. ASF by rec, oc, mmsecross, 1 0.291000 % 19. Gradient, gray-scale, mmsecross 0.061000 % 20. Thinning 0.362000 % 21. Watershed transform 0.544000 % Average 0.215048 % begin of the default argument automatic treatment if ~exist('count','var') count = 10; end % end of the default argument automatic treatment 1 filename = 'csample.jpg'; f=mmreadgray(filename); fbin=mmthreshad(f,uint8(150)); se = mmimg2se(mmbinary(uint8([0 1 0; 1 1 1; 0 1 0])),'NON-FLAT',uint8([0 1 0; 1 2 1; 0 1 0])); tasks = str2mat( ... ' 1. Union bin',... ' 2. Union gray-scale',... ' 3. Dilation bin, mmsecross',... ' 4. Dilation gray, mmsecross',... ' 5. Dilation gray, non-flat 3x3 SE',... ' 6. Open bin, mmsecross',... ' 7. Open gray-scale, mmsecross',... ' 8. Open gray, non-flat 3x3 SE',... ' 9. Distance mmsecross',... '10. Distance Euclidean',... '11. Geodesic distance mmsecross',... '12. Geodesic distance Euclidean',... '13. Area open bin',... '14. Area open gray-scale',... '15. Label mmsecross',... '16. Regional maximum, mmsecross',... '17. Open by rec, gray, mmsecross',... '18. ASF by rec, oc, mmsecross, 1',... '19. Gradient, gray-scale, mmsecross',... '20. Thinning',... '21. Watershed'); if nargin < 1, count = 10; end; disp('1. Union bin'); tic; for k=1:count mmunion(fbin,fbin); end mmt(1)=toc; disp('2. Union gray-scale'); tic; for k=1:count mmunion(f,f); end mmt(2)=toc; disp('3. Dilation bin, mmsecross'); tic; for k=1:count mmdil(fbin); end mmt(3)=toc; disp('4. Dilation gray-scale, mmsecross'); tic; for k=1:count mmdil(f); end mmt(4)=toc; disp('5. Dilation gray-scale, generic non-flat 3x3 SE'); tic; for k=1:count mmdil(f,se); end mmt(5)=toc; disp('6. Open bin, mmsecross'); tic; for k=1:count mmopen(fbin); end mmt(6)=toc; disp('7. Open gray-scale, mmsecross'); tic; for k=1:count mmopen(f); end mmt(7)=toc; disp('8. Open gray-scale, generic non-flat 3x3 SE'); tic; for k=1:count mmopen(f,se); end mmt(8)=toc; disp('9. Distance mmsecross'); tic; for k=1:count mmdist(fbin); end mmt(9)=toc; disp('10. Distance Euclidean'); tic; for k=1:count mmdist(fbin,mmsebox,'EUCLIDEAN'); end mmt(10)=toc; disp('11. Geodesic distance mmsecross'); m = mmthin(fbin); tic; for k=1:count mmgdist(fbin,m); end mmt(11)=toc; disp('12. Geodesic distance Euclidean'); tic; for k=1:count mmgdist(fbin,m,mmsebox,'EUCLIDEAN'); end mmt(12)=toc; disp('13. Area open bin'); tic; for k=1:count mmareaopen(fbin,100); end mmt(13)=toc; disp('14. Area open gray-scale'); tic; for k=1:count mmareaopen(f,100); end mmt(14)=toc; disp('15. Label mmsecross'); tic; for k=1:count mmlabel(fbin); end mmt(15)=toc; disp('16. Regional maximum, mmsecross'); tic; for k=1:count mmregmax(f); end mmt(16)=toc; disp('17. Open by reconstruction, gray-scale mmsecross, mmsecross'); tic; for k=1:count mmopenrec(f); end mmt(17)=toc; disp('18. ASF by reconstruction, oc, mmsecross, 1'); tic; for k=1:count mmasfrec(f); end mmt(18)=toc; disp('19. Gradient, gray-scale, mmsecross'); tic; for k=1:count mmgradm(f); end mmt(19)=toc; disp('20. Thinning'); tic; for k=1:count mmthin(fbin); end mmt(20)=toc; disp('21. Watershed'); tic; for k=1:count mmcwatershed(f,fbin); end mmt(21)=toc; result = mmt/count; % Display report in new figure fprintf(1,'%s Benchmark\n',mmversion); fprintf(1,'Made on %s computer=%s\n',date,computer); fprintf(1,'image filename=%s, width=%d, height=%d\n',filename,size(f,2),size(f,1)); fprintf(1,' Function time (sec.)\n'); m=size(mmt,2); for j=1:m fprintf(1,'%s\t%f\n',tasks(j,:),result(j)); end fprintf(1,' Average %f\n',mean(result)); % Detemine the indice of this computer, based on Matlab bench close all force t = 0; fig1 = figure; set(fig1,'pos','default') axes('pos',[0 0 1 1]) axis off n = 375; A = []; r = 1; tic for k = 1:count for j = 1:n clear A; r = rem(pi*r,1); m = fix(100*r); A = zeros(m,m); end end t(1) = toc; % LU cla text(.5,.5,'MATLAB Benchmark','horizontal','center','fontsize',16) text(.50,.42,'LU','horizontal','center','fontsize',16) drawnow n = 167; A = randn(n,n); tic for k = 1:count lu(A); end t(2) = toc; % Sparse cla text(.5,.5,'MATLAB Benchmark','horizontal','center','fontsize',16) text(.50,.42,'Sparse','horizontal','center','fontsize',16) drawnow n = 36; A = delsq(numgrid('L',n)); b = sum(A)'; spparms('autommd',0); tic for k = 1:count x = A\b; end t(3) = toc; % 3-D clf reset set(gcf,'renderer','zbuffer') n = 24; [x,y,z] = peaks(n); ax = [-3 3 -3 3 -8 8]; tic for k = 1:count surf(x,y,z); axis(ax); view(-44+2*k,30) drawnow; end t(4) = toc; % 2-D clf set(gcf,'renderer','painters') n = 52; tic for k = 1:count plot(fft(eye(n))); axis('square') drawnow; end t(5) = toc; times = 10/count*t; totals = sum(times')'; speeds = 50./totals; fprintf(1,'This machine is %f faster than Sun Sparc 2\n',speeds); % Copyright (c) 1998-2001 by SDC Information Systems.