-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcurveFilter.m
74 lines (63 loc) · 2.13 KB
/
curveFilter.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
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
function [L, im_xx, im_yy] = curveFilter( im, filterWidth )
% curveFilter : calculates the curvatures of an image.
%
% INPUT :
% im : image to be filtered
% filterWidth : filter width
% OUTPUT :
% M_ : Mean curvature of the image without negative values
% G_ : Gaussian curvature of the image without negative values
% C1_ : Principal curvature 1 of the image without negative values
% C2_ : Principal curvature 2 of the image without negative values
% M : Mean curvature of the image
% G : Gaussian curvature of the image
% C1 : Principal curvature 1 of the image
% C2 : Principal curvature 2 of the image
% im_xx :
% im_yy :
% im_xy :
%
% Copyright (C) 2016 Wiggins Lab
% Written by Connor Brennan & Paul Wiggins.
% University of Washington, 2016
% This file is part of SuperSegger.
%
% SuperSegger is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% SuperSegger is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with SuperSegger. If not, see <http://www.gnu.org/licenses/>.
oldflag = true;
im = double(im);
% filter width
if ~exist( 'filterWidth', 'var' ) || isempty( filterWidth )
filterWidth = 1.5;
end
% Make filter
x = -floor(7*filterWidth):floor(7*filterWidth);
%x = -10:10;
[X,Y] = meshgrid( x, x);
R2 = X.^2+Y.^2;
v = filterWidth^2;
gau = 1/(2*pi*v) * exp( -R2/(2*v) );
if oldflag
f_xx = (2*pi*v^2)*((X/v).^2-1/v).*gau;
f_yy = (2*pi*v^2)*((Y/v).^2-1/v).*gau;
f_xy = (2*pi*v^2)*X.*Y.*gau/v^2;
else
f_xx = ((X/v).^2-1/v).*gau;
f_yy = ((Y/v).^2-1/v).*gau;
f_xy = X.*Y.*gau/v^2;
end
% Do filtering
im_xx = imfilter( im, f_xx, 'replicate' );
im_yy = imfilter( im, f_yy, 'replicate' );
L = im_xx + im_yy;
end