Skip to content

Commit

Permalink
using factored filters for gaussian and the global scharr
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolau Leal Werneck committed Jul 18, 2023
1 parent a38d47e commit 0a5da6e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 23 deletions.
18 changes: 10 additions & 8 deletions src/akaze.jl
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
using Images: Kernel
using Images: Kernel, KernelFactors, centered

using ImageTransformations: imresize
using ImageFiltering: imfilter!
using ImageFiltering: imfilter!, kernelfactors

fy, fx = Kernel.scharr()
fy .*=32
fx .*=32
using StaticArrays: SVector

## Scharr filter scaled by 32.0
s32f1 = centered(SVector(3.0, 10.0, 3.0)*2)
s32f2 = centered(SVector(-1.0, 0.0, 1.0)/2)
fy = kernelfactors((s32f2, s32f1))
fx = kernelfactors((s32f1, s32f2))

# fy, fx = Kernel.ando3()
# fy, fx = Kernel.ando5()

################################################################
struct AKAZE
Expand Down Expand Up @@ -471,5 +473,5 @@ function AkazeGauss(sigma)
if ((ksize_x % 2) == 0)
ksize_x += 1
end
Kernel.gaussian((sigma,sigma), (ksize_x, ksize_x))
KernelFactors.gaussian((sigma,sigma), (ksize_x, ksize_x))
end
20 changes: 5 additions & 15 deletions src/nonlinear-diffusion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -172,34 +172,24 @@ function compute_derivative_kernels(scale)

ksize = 3 + 2*(scale-1)

## The usual Scharr kernel
if (scale == 1)
# Kernel.scharr()
fx, fy = Kernel.scharr()
# (fx.*32, fy.*32)
(fx, fy)
end
# ## The usual Scharr kernel
# if (scale == 1)
# return KernelFactors.scharr()
# end

kx = centered(zeros(ksize))
ky = centered(zeros(ksize))

w = 10.0/3.0
norm = 1.0/(2.0*scale*(w+2.0))

# ky[1+0] = norm
# ky[1+ksize÷2] = w*norm
# ky[1+ksize-1] = norm

# kx[1+0] = -1
# kx[1+ksize÷2] = 0
# kx[1+ksize-1] = 1
ky[-ksize÷2] = norm
ky[0] = w*norm
ky[ksize÷2] = norm

kx[-ksize÷2] = -1
kx[0] = 0
kx[ksize÷2] = 1
# (kernelfactors((ky, kx)), kernelfactors((kx, ky)))

(kernelfactors((ky, kx)), kernelfactors((kx, ky)))
end

0 comments on commit 0a5da6e

Please sign in to comment.