summaryrefslogtreecommitdiffstats
path: root/SD-VBS/benchmarks/mser/src/matlab/old/mser_demo3.m
diff options
context:
space:
mode:
Diffstat (limited to 'SD-VBS/benchmarks/mser/src/matlab/old/mser_demo3.m')
-rwxr-xr-xSD-VBS/benchmarks/mser/src/matlab/old/mser_demo3.m117
1 files changed, 0 insertions, 117 deletions
diff --git a/SD-VBS/benchmarks/mser/src/matlab/old/mser_demo3.m b/SD-VBS/benchmarks/mser/src/matlab/old/mser_demo3.m
deleted file mode 100755
index 4669437..0000000
--- a/SD-VBS/benchmarks/mser/src/matlab/old/mser_demo3.m
+++ /dev/null
@@ -1,117 +0,0 @@
1% MSER_DEMO3 Demonstrates MSER on a volumetric image
2
3% AUTORIGHTS
4% Copyright (C) 2006 Regents of the University of California
5% All rights reserved
6%
7% Written by Andrea Vedaldi (UCLA VisionLab).
8%
9% Redistribution and use in source and binary forms, with or without
10% modification, are permitted provided that the following conditions are met
11%
12% * Redistributions of source code must retain the above copyright
13% notice, this list of conditions and the following disclaimer.
14% * Redistributions in binary form must reproduce the above copyright
15% notice, this list of conditions and the following disclaimer in the
16% documentation and/or other materials provided with the distribution.
17% * Neither the name of the University of California, Berkeley nor the
18% names of its contributors may be used to endorse or promote products
19% derived from this software without specific prior written permission.
20%
21% THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
22% EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24% DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
25% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26% (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27% LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
28% ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29% (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30% SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
32% --------------------------------------------------------------------
33% Create data
34% --------------------------------------------------------------------
35
36% volumetric coordinate (x,y,z)
37x = linspace(-1,1,50) ;
38[x,y,z] = meshgrid(x,x,x) ;
39
40% create funny volumetric image
41I = sin(4*x).*cos(4*y).*sin(z) ;
42I = I-min(I(:)) ;
43I = I/max(I(:)) ;
44
45% quantize the image in 10 levels
46lev = 10 ;
47I = lev*I ;
48Ir = round(I) ;
49
50% --------------------------------------------------------------------
51% Compute regions
52% --------------------------------------------------------------------
53[idx,ell,p] = mser(uint8(Ir),1);
54
55% --------------------------------------------------------------------
56% Plots
57% --------------------------------------------------------------------
58
59% The image is quantized; store in LEV its range.
60lev = unique(Ir(idx)) ;
61
62figure(100); clf;
63K=min(length(lev),4) ;
64
65r=.99 ;
66
67% one level per time
68for k=1:K
69 tightsubplot(K,k) ;
70 [i,j,m] = ind2sub(size(I), idx(Ir(idx)==lev(k)) ) ;
71
72 % compute level set of level LEV(k)
73 Is = double(Ir<=lev(k)) ;
74
75 p1 = patch(isosurface(Is,r), ...
76 'FaceColor','blue','EdgeColor','none') ;
77 p2 = patch(isocaps(Is,r),...
78 'FaceColor','interp','EdgeColor','none') ;
79 isonormals(I,p1)
80 hold on ;
81
82 view(3); axis vis3d tight
83 camlight; lighting phong ;
84
85 % find regions that have this level
86 sel = find( Ir(idx) == lev(k) ) ;
87
88 % plot fitted ellipsoid
89 for r=sel'
90 E = ell(:,r) ;
91 c = E(1:3) ;
92 A = zeros(3) ;
93 A(1,1) = E(4) ;
94 A(1,2) = E(5) ;
95 A(2,2) = E(6) ;
96 A(1,3) = E(7) ;
97 A(2,3) = E(8) ;
98 A(3,3) = E(9) ;
99
100 A = A + A' - diag(diag(A)) ;
101
102 % correct var. order
103 perm = [0 1 0 ; 1 0 0 ; 0 0 1] ;
104 A = perm*A*perm ;
105
106 [V,D] = eig(A) ;
107 A = 2.5*V*sqrt(D) ;
108
109 [x,y,z]=sphere ;
110 [P,Q]=size(x) ;
111 X=A*[x(:)';y(:)';z(:)'] ;
112 x=reshape(X(1,:),P,Q)+c(2) ;
113 y=reshape(X(2,:),P,Q)+c(1) ;
114 z=reshape(X(3,:),P,Q)+c(3) ;
115 surf(x,y,z,'FaceAlpha',.5) ;
116 end
117end
n> return status; } static int clk_vf_point_construct_freq(struct gk20a *g, struct boardobj **ppboardobj, u16 size, void *pargs) { struct boardobj *ptmpobj = (struct boardobj *)pargs; struct clk_vf_point_freq *pclkvfpoint; struct clk_vf_point_freq *ptmpvfpoint = (struct clk_vf_point_freq *)pargs; int status = 0; if (BOARDOBJ_GET_TYPE(pargs) != CTRL_CLK_CLK_VF_POINT_TYPE_FREQ) { return -EINVAL; } ptmpobj->type_mask = BIT(CTRL_CLK_CLK_VF_POINT_TYPE_FREQ); status = clk_vf_point_construct_super(g, ppboardobj, size, pargs); if (status) { return -EINVAL; } pclkvfpoint = (struct clk_vf_point_freq *)*ppboardobj; pclkvfpoint->super.super.pmudatainit = _clk_vf_point_pmudatainit_freq; clkvfpointfreqmhzset(g, &pclkvfpoint->super, clkvfpointfreqmhzget(g, &ptmpvfpoint->super)); return status; } struct clk_vf_point *construct_clk_vf_point(struct gk20a *g, void *pargs) { struct boardobj *board_obj_ptr = NULL; int status; nvgpu_log_info(g, " "); switch (BOARDOBJ_GET_TYPE(pargs)) { case CTRL_CLK_CLK_VF_POINT_TYPE_FREQ: status = clk_vf_point_construct_freq(g, &board_obj_ptr, sizeof(struct clk_vf_point_freq), pargs); break; case CTRL_CLK_CLK_VF_POINT_TYPE_VOLT: status = clk_vf_point_construct_volt(g, &board_obj_ptr, sizeof(struct clk_vf_point_volt), pargs); break; default: return NULL; } if (status) { return NULL; } nvgpu_log_info(g, " Done"); return (struct clk_vf_point *)board_obj_ptr; } static int _clk_vf_point_pmudatainit_super(struct gk20a *g, struct boardobj *board_obj_ptr, struct nv_pmu_boardobj *ppmudata) { int status = 0; struct clk_vf_point *pclk_vf_point; struct nv_pmu_clk_clk_vf_point_boardobj_set *pset; nvgpu_log_info(g, " "); status = boardobj_pmudatainit_super(g, board_obj_ptr, ppmudata); if (status != 0) { return status; } pclk_vf_point = (struct clk_vf_point *)board_obj_ptr; pset = (struct nv_pmu_clk_clk_vf_point_boardobj_set *) ppmudata; pset->vfe_equ_idx = pclk_vf_point->vfe_equ_idx; pset->volt_rail_idx = pclk_vf_point->volt_rail_idx; return status; } static int clk_vf_point_update(struct gk20a *g, struct boardobj *board_obj_ptr, struct nv_pmu_boardobj *ppmudata) { struct clk_vf_point *pclk_vf_point; struct nv_pmu_clk_clk_vf_point_boardobj_get_status *pstatus; nvgpu_log_info(g, " "); pclk_vf_point = (struct clk_vf_point *)board_obj_ptr; pstatus = (struct nv_pmu_clk_clk_vf_point_boardobj_get_status *) ppmudata; if (pstatus->super.type != pclk_vf_point->super.type) { nvgpu_err(g, "pmu data and boardobj type not matching"); return -EINVAL; } /* now copy VF pair */ memcpy(&pclk_vf_point->pair, &pstatus->pair, sizeof(struct ctrl_clk_vf_pair)); return 0; } /*get latest vf point data from PMU */ int clk_vf_point_cache(struct gk20a *g) { struct clk_vf_points *pclk_vf_points; struct boardobjgrp *pboardobjgrp; struct boardobjgrpmask *pboardobjgrpmask; struct nv_pmu_boardobjgrp_super *pboardobjgrppmu; struct boardobj *pboardobj = NULL; struct nv_pmu_boardobj_query *pboardobjpmustatus = NULL; int status; u8 index; nvgpu_log_info(g, " "); pclk_vf_points = &g->clk_pmu.clk_vf_pointobjs; pboardobjgrp = &pclk_vf_points->super.super; pboardobjgrpmask = &pclk_vf_points->super.mask.super; status = pboardobjgrp->pmugetstatus(g, pboardobjgrp, pboardobjgrpmask); if (status) { nvgpu_err(g, "err getting boardobjs from pmu"); return status; } pboardobjgrppmu = pboardobjgrp->pmu.getstatus.buf; BOARDOBJGRP_FOR_EACH(pboardobjgrp, struct boardobj*, pboardobj, index) { status = pboardobjgrp->pmustatusinstget(g, (struct nv_pmu_boardobjgrp *)pboardobjgrppmu, &pboardobjpmustatus, index); if (status) { nvgpu_err(g, "could not get status object instance"); return status; } status = clk_vf_point_update(g, pboardobj, (struct nv_pmu_boardobj *)pboardobjpmustatus); if (status) { nvgpu_err(g, "invalid data from pmu at %d", index); return status; } } return 0; }