Skip to content

Instantly share code, notes, and snippets.

@jakeoung
Last active January 19, 2020 16:50
Show Gist options
  • Select an option

  • Save jakeoung/eaba02f4cc46086ca2d9bce39da0c5d8 to your computer and use it in GitHub Desktop.

Select an option

Save jakeoung/eaba02f4cc46086ca2d9bce39da0c5d8 to your computer and use it in GitHub Desktop.
Effect of normalization in Laplacian of Gaussian
using Plots
using SpecialFunctions
function GoS(x)
-(1 .- erf.(x))
end
function G(x, sigma)
exp.(-x.^2 ./ (2*sigma^2))
end
function dG(x, sigma)
-x ./ sigma^2 .* exp.(-x.^2 ./ (2*sigma^2))
end
function LoG(x, sigma)
(x.^2 / sigma^4 .- 1 / sigma^2) .* exp.(-x.^2 / (2*sigma^2) )
end
x = -10:0.1:10
k = sqrt(2)
sigma0 = 0.5
nsigma=6
sigmas = zeros(nsigma)
for i=1:nsigma
sigmas[i] = i * k * sigma0
end
anim = @animate for sigma in sigmas
plot(x, G(x, sigma), label="G(x)")
plot!(x, dG(x, sigma), label="G'")
a = plot!(x, LoG(x, sigma), label="LoG")
plot(x, G(x, sigma), label="G(x)")
plot!(x, sigma*dG(x, sigma), label="sG'")
c = plot!(x, sigma^2*LoG(x, sigma), label="s^2LoG")
plot(a, c)
title!("sigma:($sigma)")
end
gif(anim, "~/Desktop/anim.gif", fps = 0.5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment