Skip to content

Commit

Permalink
changed normalization of BesslJ1 hologram method to match python's
Browse files Browse the repository at this point in the history
  • Loading branch information
marcsgil committed Aug 11, 2024
1 parent e7819d0 commit ed5be2f
Showing 1 changed file with 38 additions and 2 deletions.
40 changes: 38 additions & 2 deletions src/holograms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ inverse_besselj1(x) = zero_order_interpolation(x, xs_besselj1, ys_besselj1)
*
sin((kx * x[i] + ky * y[j]) + angle(relative)))

dest[i, j] = round(two_pi_modulation / 1.17 */ y_max_besselj1 + 1) / 2)
dest[i, j] = round(two_pi_modulation * 0.586 */ y_max_besselj1 + 1) / 2)
end

@kernel function hologram_kernel!(dest, desired, incoming, x, y, two_pi_modulation, M, kx, ky, ::Type{Simple})
Expand Down Expand Up @@ -305,8 +305,44 @@ J. Opt. Soc. Am. A 24, 3500-3507 (2007)
"Comparison of beam generation techniques using a phase only spatial light modulator,"
Opt. Express 24, 6249-6264 (2016)
"""

function generate_hologram(desired, incoming, x, y, max_modulation, x_period, y_period, method::Type{T}=BesselJ1) where {T<:HologramMethod}
dest = similar(desired, UInt8)
generate_hologram!(dest, desired, incoming, x, y, max_modulation, x_period, y_period, method)
dest
end
end

"""function convert2angle(x)
return mod.(x .+ π, 2π) .- π
end
function normalize(holo, max_modulation)
m = minimum(holo)
M = maximum(holo)
return round.(UInt8, max_modulation .* (holo .- m) ./ (M - m))
end
function psi(phi, a, ::Type{Simple})
return a .* convert2angle(phi)
end
function psi(phi, a, ::Type{BesselJ1})
inverse_besselj1.(a * 0.5818) .* sin.(phi)
end
function generate_hologram(desired, incoming, x, y, max_modulation::Int, xperiod, yperiod, ::Type{T}=BesselJ1) where {T<:HologramMethod}
relative = desired ./ incoming
a = abs.(relative)
a ./= maximum(a)
lx = xperiod * (x[2] - x[1])
ly = yperiod * (y[2] - y[1])
phi = angle.(relative) .+ 2π .* (x ./ lx .+ y' ./ ly)
if T == BesselJ1
max_modulation *= 0.586
end
return normalize(psi(phi, a, T), round(max_modulation))
end"""

0 comments on commit ed5be2f

Please sign in to comment.