diff options
Diffstat (limited to 'SD-VBS/benchmarks/mser/src/matlab/old/mser_demo3.m')
| -rwxr-xr-x | SD-VBS/benchmarks/mser/src/matlab/old/mser_demo3.m | 117 |
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) | ||
| 37 | x = linspace(-1,1,50) ; | ||
| 38 | [x,y,z] = meshgrid(x,x,x) ; | ||
| 39 | |||
| 40 | % create funny volumetric image | ||
| 41 | I = sin(4*x).*cos(4*y).*sin(z) ; | ||
| 42 | I = I-min(I(:)) ; | ||
| 43 | I = I/max(I(:)) ; | ||
| 44 | |||
| 45 | % quantize the image in 10 levels | ||
| 46 | lev = 10 ; | ||
| 47 | I = lev*I ; | ||
| 48 | Ir = 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. | ||
| 60 | lev = unique(Ir(idx)) ; | ||
| 61 | |||
| 62 | figure(100); clf; | ||
| 63 | K=min(length(lev),4) ; | ||
| 64 | |||
| 65 | r=.99 ; | ||
| 66 | |||
| 67 | % one level per time | ||
| 68 | for 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 | ||
| 117 | end | ||
