Skip to content

odak.learn.wave.point_wise

Naive point-wise hologram calculation method. For more information, refer to Maimone, Andrew, Andreas Georgiou, and Joel S. Kollin. "Holographic near-eye displays for virtual and augmented reality." ACM Transactions on Graphics (TOG) 36.4 (2017): 1-16.

Parameters:

Name Type Description Default
target torch.float

float input target to be converted into a hologram (Target should be in range of 0 and 1).

required
wavelength float

Wavelength of the electric field.

required
distance float

Propagation distance.

required
dx float

Size of one single pixel in the field grid (in meters).

required
device torch.device

Device type (cuda or cpu)`.

required
lens_size int

Size of lens for masking sub holograms(in pixels).

401

Returns:

Type Description
torch.cfloat

Calculated complex hologram.

Source code in odak/learn/wave/classical.py
def point_wise(target, wavelength, distance, dx, device, lens_size=401):
    """
    Naive point-wise hologram calculation method. For more information, refer to Maimone, Andrew, Andreas Georgiou, and Joel S. Kollin. "Holographic near-eye displays for virtual and augmented reality." ACM Transactions on Graphics (TOG) 36.4 (2017): 1-16.

    Parameters
    ----------
    target           : torch.float
                       float input target to be converted into a hologram (Target should be in range of 0 and 1).
    wavelength       : float
                       Wavelength of the electric field.
    distance         : float
                       Propagation distance.
    dx               : float
                       Size of one single pixel in the field grid (in meters).
    device           : torch.device
                       Device type (cuda or cpu)`.
    lens_size        : int
                       Size of lens for masking sub holograms(in pixels).

    Returns
    -------
    hologram         : torch.cfloat
                       Calculated complex hologram.
    """
    target = zero_pad(target)
    nx, ny = target.shape
    k = wavenumber(wavelength)
    ones = torch.ones(target.shape, requires_grad=False).to(device)
    x = torch.linspace(-nx/2, nx/2, nx).to(device)
    y = torch.linspace(-ny/2, ny/2, ny).to(device)
    X, Y = torch.meshgrid(x, y, indexing='ij')
    Z = (X**2+Y**2)**0.5
    mask = (torch.abs(Z) <= lens_size)
    mask[mask > 1] = 1
    fz = quadratic_phase_function(nx, ny, k, focal=-distance, dx=dx).to(device)
    A = torch.nan_to_num(target**0.5, nan=0.0)
    fz = mask*fz
    FA = torch.fft.fft2(torch.fft.fftshift(A))
    FFZ = torch.fft.fft2(torch.fft.fftshift(fz))
    H = torch.mul(FA, FFZ)
    hologram = torch.fft.ifftshift(torch.fft.ifft2(H))
    hologram = crop_center(hologram)
    return hologram

Notes

To optimize a phase-only hologram using point wise algorithm, please follow and observe the below example:

import torch
from odak.learn.wave import point_wise
wavelength               = 0.000000515
dx                       = 0.000008
distance                 = 0.15
resolution               = [1080,1920]
cuda                     = True
device                   = torch.device("cuda" if cuda else "cpu")
target                   = torch.zeros(resolution[0],resolution[1]).to(device)
target[540:600,960:1020] = 1
hologram                 = point_wise(
                                      target,
                                      wavelength,
                                      distance,
                                      dx,
                                      device,
                                      lens_size=401
                                     )

See also