summaryrefslogtreecommitdiffstats
path: root/SD-VBS/benchmarks/mser/src/matlab/script_run_profile.m
blob: ec06539a14d964ca09071f1eaa98b26b48a92386 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
function script_run_profile(dataDir, resultDir, type, common,toolDir)

mser_compile;
path(path, common);

% MSER_DEMO  Demonstrates MSER 

% AUTORIGHTS
% Copyright (C) 2006 Regents of the University of California
% All rights reserved
% 
% Written by Andrea Vedaldi (UCLA VisionLab).
% 
% Redistribution and use in source and binary forms, with or without
% modification, are permitted provided that the following conditions are met
% 
%     * Redistributions of source code must retain the above copyright
%       notice, this list of conditions and the following disclaimer.
%     * Redistributions in binary form must reproduce the above copyright
%       notice, this list of conditions and the following disclaimer in the
%       documentation and/or other materials provided with the distribution.
%     * Neither the name of the University of California, Berkeley nor the
%       names of its contributors may be used to endorse or promote products
%       derived from this software without specific prior written permission.
% 
% THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
% EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
% DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
% (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
% LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
% ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
% (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
% SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

which_image = 3 ;

% --------------------------------------------------------------------
%                                                          Create data
% --------------------------------------------------------------------
switch which_image
  case 1
    I   = rand(200,200) ;
    I   = imsmooth(I,10) ;
    I   = I-min(I(:)) ;
    I   = I/max(I(:)) ;
    lev = 10 ;
    I   = uint8(round(I*lev)) ;
  
  case 2    
    I = zeros(200,200) ;
    I(50:150,50:150)=5 ;
    I = imsmooth(I,10) ;
    I = uint8(round(I)) ;
    
  case 3
    Files = dir([dataDir,'/1.bmp']);
    I=readImage(fullfile(dataDir,Files(1).name));
end

% --------------------------------------------------------------------
%                                                        Compute MSERs
% --------------------------------------------------------------------

%% Self check params
tol = 0.1;
elapsed = zeros(1,2);

rows = size(I,1);
cols = size(I,2);

fprintf(1,'Input size\t\t- (%dx%d)\n', rows, cols);

%% Timing
start = photonStartTiming;

[idx] = mser(uint8(I), 2) ;

%% Timing
stop = photonEndTiming;
    
temp = photonReportTiming(start, stop);
elapsed(1) = elapsed(1) + temp(1);
elapsed(2) = elapsed(2) + temp(2);

 %% Self checking
 writeMatrix(idx, dataDir);

%% Timing
photonPrintTiming(elapsed);

%% --------------------------------------------------------------------
%%                                                                Plots
%% --------------------------------------------------------------------
%[i,j] = ind2sub(size(I),idx) ;
%
%figure(100) ; clf ; imagesc(I) ; hold on ;
%set(gca,'Position',[0 0 1 1]) ;
%plot(j,i,'g*') ; colormap gray ;
%
%% swap x with y
%ell = ell([2 1 5 4 3],:) ;
%
%for k=1:size(ell,2)
%  E = ell(:,k) ;
%  c = E(1:2) ;
%  A = zeros(2) ;
%  A(1,1) = E(3) ;
%  A(1,2) = E(4) ;
%  A(2,2) = E(5) ;  
%  A = A + A' - diag(diag(A)) ;
%  
%  [V,D] = eig(A) ;
%  A = 2.5*V*sqrt(D) ;
%  
%  X = A*[cos(linspace(0,2*pi,30)) ; sin(linspace(0,2*pi,30)) ;] ;
%  X(1,:) = X(1,:) + c(1) ;
%  X(2,:) = X(2,:) + c(2) ;
%
%  plot(X(1,:),X(2,:),'r-','LineWidth',2) ;
%  plot(c(1),c(2),'r.') ;
%  plot(j(k),i(k),'g*') ;
%end
%
%line([j'; ell(1,:)],[i'; ell(2,:)],'color','b') ;