Hi,
I’m trying to create and visualize a Gabor kernel.
First I used Kernel.gabor from ImageFiltering.jl and it worked, I think (I still have to learn how to use it to convolve with an image, but okay).
gabor = Kernel.gabor(10, 10, 2, 22.5, 2, 1, 0)
colorview(RGB, zeroarray, gabor[1], zeroarray)
But since I’ll be working with image processing, I need/want to get a better grasp of it.
So I’m following this guide for python (Notebook), and I made this far:
function gen_gabor(siz, ω, θ)
# siz(e) = width x height; A amplitude; ω frequency = 2πf; ρ phase
radius = [floor(Int, siz[1]/2.), floor(Int, siz[2]/2.)]
iter = CartesianIndices((-radius[1]:radius[1]+1, -radius[2]:radius[2]+1))
x1 = [Tuple(iter[i])[1] for i = 1:length(iter)]
y1 = [Tuple(iter[i])[2] for i = 1:length(iter)]
x = x1.*cos(θ) + y1.*sin(θ)
y = -x1.*sin(θ) + y1.*cos(θ)
gauss = (((ω^2)/(4pi^3))*exp((-ω^2)/(8pi^2))).*(4(x.^2 + y.^2))
sinusoid = cos.(ω.*x).*exp((pi^2)/2)
gabor = gauss.*sinusoid
ga = reshape(gauss, size(iter))
si = reshape(sinusoid, size(iter))
gb = reshape(gabor, size(iter))
return ga, si, gb
end
siz = (256, 256)
ω = .3
θ = pi/4
(gauss, sinusoid, gabor) = gen_gabor(siz, ω, θ)
Gray.(gabor)
My question then is, why it doesn’t work?
If you have another approach to it, please I’d love to know.
Thanks,