/
structensorsvd.m
46 lines (43 loc) · 2.41 KB
/
structensorsvd.m
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
% Copyright (c) 2017 The Johns Hopkins University/Applie?d Physics Laboratory
% This software was developed at The Johns Hopkins University/Applied Physics
% Laboratory (“JHU/APL”) that is the author thereof under the “work made for hire”
% provisions of the copyright law. Permission is hereby granted, free of charge,
% to any person obtaining a copy of this software and associated documentation
% (the “Software”), to use the Software without restriction, including without
% limitation the rights to copy, modify, merge, publish, distribute, sublicense,
% and/or sell copies of the Software, and to permit others to do so, subject to
% the following conditions:
% 1. This LICENSE AND DISCLAIMER, including the copyright notice,
% shall be included in all copies of the Software,
% including copies of substantial portions of the Software;
%
% 2. JHU/APL assumes no obligation to provide support of any kind with regard to the Software.
% This includes no obligation to provide assistance in using the Software nor to
% provide updated versions of the Software; and
%
% 3. THE SOFTWARE AND ITS DOCUMENTATION ARE PROVIDED AS IS AND WITHOUT ANY
% EXPRESS OR IMPLIED WARRANTIES WHATSOEVER. ALL WARRANTIES INCLUDING, BUT NOT
% LIMITED TO, PERFORMANCE, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
% AND NONINFRINGEMENT ARE HEREBY DISCLAIMED. USERS ASSUME THE ENTIRE RISK AND
% LIABILITY OF USING THE SOFTWARE. USERS ARE ADVISED TO TEST THE SOFTWARE
% THOROUGHLY BEFORE RELYING ON IT. IN NO EVENT SHALL THE JOHNS HOPKINS UNIVERSITY
% BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING, WITHOUT LIMITATION, ANY
% LOST PROFITS, LOST SAVINGS OR OTHER INCIDENTAL OR CONSEQUENTIAL DAMAGES,
% ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE.”
% Shi/Tomassi eigendecomposition for structure tensor
%
% Version History:
% 09/08/2016 Marc Bosch Initial version
function [eigval,eigval2,T,D]=structensorsvd(im,sigma)
[Ix, Iy] = derivative5(im, 'x', 'y');
Ix2 = Ix.^2;
Iy2 = Iy.^2;
Ixy = Ix.*Iy;
% [Ix2,fieldweight]=bilatfilt(Ix.^2,im(:,:,1),7,sigma,0);
% [Iy2,fieldweight]=bilatfilt(Iy.^2,im(:,:,1),7,sigma,0);
% [Ixy,fieldweight]=bilatfilt(Ix.*Iy,im(:,:,1),7,sigma,0);
%
T = Ix2 + Iy2; % trace
D = Ix2.*Iy2 - Ixy.^2; % determinant
eigval = T/2 - sqrt(T.^2/4 - D);
eigval2 = T/2 + sqrt(T.^2/4 - D);