Last active
December 10, 2015 11:28
-
-
Save lanpa/4427645 to your computer and use it in GitHub Desktop.
This file contains 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
%2013/1/1 | |
%Tzu-Wei Huang | |
%demo of 'derivative of Gaussian', Difference of Gaussians and | |
%'Laplacian of Gaussian' in matlab. | |
close all; | |
[x,y] = meshgrid(-5:0.1:5,-5:0.1:5); | |
%gaussian with sigma = 1 | |
z = (1/sqrt(2*pi))./exp((x.^2+y.^2)/2); | |
%gaussian with sigma = 2 | |
z_another = (1/(2*sqrt(2*pi)))./exp((x.^2+y.^2)/8); | |
surf(x,y,z);title('2D gaussian with sigma = 1'); | |
dz_y = z*0; | |
for j=1:size(z,2) | |
for i=2:size(z,1)-1 | |
dz_y(i,j) = z(i,j)-z(i-1,j); | |
end | |
end | |
dz_x = dz_y'; | |
figure; | |
surf(x,y,dz_x);title('derivative of Gaussian x'); | |
figure; | |
surf(x,y,dz_y);title('derivative of Gaussian y'); | |
ddz_yy = z*0; | |
for j=1:size(z,2) | |
for i=2:size(z,1)-1 | |
ddz_yy(i,j) = dz_y(i,j)-dz_y(i-1,j); | |
end | |
end | |
ddz_xx = ddz_yy'; | |
figure; | |
surf(x,y,ddz_xx+ddz_yy);title('Laplacian of Gaussian'); | |
figure; | |
surf(x,y,z_another-z);title('Difference of Gaussians'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment