Skip to content

Commit

Permalink
Merge pull request #43 from JuliaImages/teh/gaussian_width0
Browse files Browse the repository at this point in the history
Fix KernelFactors.gaussian for sigma = 0
  • Loading branch information
timholy authored Nov 5, 2017
2 parents d7328d0 + 3bd42d5 commit f9195cc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/kernelfactors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ in each direction from the center. `l` must be odd.
function gaussian::Real, l = 4*ceil(Int,σ)+1)
isodd(l) || throw(ArgumentError("length must be odd"))
w = l>>1
g = [exp(-x^2/(2*σ^2)) for x=-w:w]
g = σ == 0 ? [exp(0/(2*oftype(σ, 1)^2))] : [exp(-x^2/(2*σ^2)) for x=-w:w]
centered(g/sum(g))
end

Expand Down
3 changes: 3 additions & 0 deletions test/specialty.jl
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,9 @@ using Base.Test
for k = (Kernel.gaussian((2,3)), Kernel.gaussian([2,3]), Kernel.gaussian([2,3], [9,7]))
@test sum(k) 1
end
# Bug noticed in Images issue #674
k = KernelFactors.gaussian((3, 3, 0))
@test k[3].data == OffsetArray([1.0], 0:0)
end

@testset "DoG" begin
Expand Down

0 comments on commit f9195cc

Please sign in to comment.