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/>.
0001 function [M_, G_, C1_, C2_, M, G, C1, C2, im_xx, im_yy, im_xy] = curveFilter( im, filterWidth ) 0002 % curveFilter : calculates the curvatures of an image. 0003 % 0004 % INPUT : 0005 % im : image to be filtered 0006 % filterWidth : filter width 0007 % OUTPUT : 0008 % M_ : Mean curvature of the image without negative values 0009 % G_ : Gaussian curvature of the image without negative values 0010 % C1_ : Principal curvature 1 of the image without negative values 0011 % C2_ : Principal curvature 2 of the image without negative values 0012 % M : Mean curvature of the image 0013 % G : Gaussian curvature of the image 0014 % C1 : Principal curvature 1 of the image 0015 % C2 : Principal curvature 2 of the image 0016 % im_xx : 0017 % im_yy : 0018 % im_xy : 0019 % 0020 % Copyright (C) 2016 Wiggins Lab 0021 % Written by Connor Brennan & Paul Wiggins. 0022 % University of Washington, 2016 0023 % This file is part of SuperSegger. 0024 % 0025 % SuperSegger is free software: you can redistribute it and/or modify 0026 % it under the terms of the GNU General Public License as published by 0027 % the Free Software Foundation, either version 3 of the License, or 0028 % (at your option) any later version. 0029 % 0030 % SuperSegger is distributed in the hope that it will be useful, 0031 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0032 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0033 % GNU General Public License for more details. 0034 % 0035 % You should have received a copy of the GNU General Public License 0036 % along with SuperSegger. If not, see <http://www.gnu.org/licenses/>. 0037 0038 im = double(im); 0039 0040 % filter width 0041 if ~exist( 'filterWidth', 'var' ) || isempty( filterWidth ) 0042 filterWidth = 1.5; 0043 end 0044 0045 0046 % Make filter 0047 x = -floor(7*filterWidth):floor(7*filterWidth); 0048 %x = -10:10; 0049 [X,Y] = meshgrid( x, x); 0050 R2 = X.^2+Y.^2; 0051 0052 v = filterWidth^2; 0053 0054 gau = 1/(2*pi*v) * exp( -R2/(2*v) ); 0055 f_xx = (2*pi*v^2)*((X/v).^2-1/v).*gau; 0056 f_yy = (2*pi*v^2)*((Y/v).^2-1/v).*gau; 0057 f_xy = (2*pi*v^2)*X.*Y.*gau/v^2; 0058 0059 % Do filtering 0060 im_xx = imfilter( im, f_xx, 'replicate' ); 0061 im_yy = imfilter( im, f_yy, 'replicate' ); 0062 im_xy = imfilter( im, f_xy, 'replicate' ); 0063 0064 % gaussian curvature 0065 G = im_xx.*im_yy-im_xy.^2; 0066 0067 % mean curvature 0068 M = -(im_xx+im_yy)/2; 0069 0070 % compute principal curvatures 0071 C1 = (M-sqrt(abs(M.^2-G))); 0072 C2 = (M+sqrt(abs(M.^2-G))); 0073 0074 % remove negative values 0075 G_ = G; 0076 G_(G<0) = 0; 0077 0078 M_ = M; 0079 M_(M<0) = 0; 0080 0081 C1_ = C1; 0082 C1_(C1<0) = 0; 0083 0084 C2_ = C2; 0085 C2_(C2<0) = 0; 0086 0087 end