Created
November 1, 2018 06:43
-
-
Save enijkamp/4201e26b178b90d6e5fa27317734505c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case 'log' % Laplacian of Gaussian | |
% first calculate Gaussian | |
siz = (p2-1)/2; | |
std2 = p3^2; | |
[x,y] = meshgrid(-siz(2):siz(2),-siz(1):siz(1)); | |
arg = -(x.*x + y.*y)/(2*std2); | |
h = exp(arg); | |
h(h<eps*max(h(:))) = 0; | |
sumh = sum(h(:)); | |
if sumh ~= 0, | |
h = h/sumh; | |
end; | |
% now calculate Laplacian | |
h1 = h.*(x.*x + y.*y - 2*std2)/(std2^2); | |
h = h1 - sum(h1(:))/prod(p2); % make the filter sum to zero | |
case 'gaussian' % Gaussian filter | |
siz = (p2-1)/2; | |
std = p3; | |
[x,y] = meshgrid(-siz(2):siz(2),-siz(1):siz(1)); | |
arg = -(x.*x + y.*y)/(2*std*std); | |
h = exp(arg); | |
h(h<eps*max(h(:))) = 0; | |
sumh = sum(h(:)); | |
if sumh ~= 0, | |
h = h/sumh; | |
end; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment