odak.learn.wave
angular_spectrum(field, k, distance, dx, wavelength, zero_padding=False, aperture=1.0)
¶
A definition to calculate convolution with Angular Spectrum method for beam propagation.
Parameters:
-
field
–Complex field [m x n].
-
k
–Wave number of a wave, see odak.wave.wavenumber for more.
-
distance
–Propagation distance.
-
dx
–Size of one single pixel in the field grid (in meters).
-
wavelength
–Wavelength of the electric field.
-
zero_padding
–Zero pad in Fourier domain.
-
aperture
–Fourier domain aperture (e.g., pinhole in a typical holographic display). The default is one, but an aperture could be as large as input field [m x n].
Returns:
-
result
(complex
) –Final complex field (MxN).
Source code in odak/learn/wave/classical.py
band_limited_angular_spectrum(field, k, distance, dx, wavelength, zero_padding=False, aperture=1.0)
¶
A definition to calculate bandlimited angular spectrum based beam propagation. For more
Matsushima, Kyoji, and Tomoyoshi Shimobaba. "Band-limited angular spectrum method for numerical simulation of free-space propagation in far and near fields." Optics express 17.22 (2009): 19662-19673
.
Parameters:
-
field
–A complex field. The expected size is [m x n].
-
k
–Wave number of a wave, see odak.wave.wavenumber for more.
-
distance
–Propagation distance.
-
dx
–Size of one single pixel in the field grid (in meters).
-
wavelength
–Wavelength of the electric field.
-
zero_padding
–Zero pad in Fourier domain.
-
aperture
–Fourier domain aperture (e.g., pinhole in a typical holographic display). The default is one, but an aperture could be as large as input field [m x n].
Returns:
-
result
(complex
) –Final complex field [m x n].
Source code in odak/learn/wave/classical.py
custom(field, kernel, zero_padding=False, aperture=1.0)
¶
A definition to calculate convolution based Fresnel approximation for beam propagation.
Parameters:
-
field
–Complex field [m x n].
-
kernel
–Custom complex kernel for beam propagation.
-
zero_padding
–Zero pad in Fourier domain.
-
aperture
–Fourier domain aperture (e.g., pinhole in a typical holographic display). The default is one, but an aperture could be as large as input field [m x n].
Returns:
-
result
(complex
) –Final complex field (MxN).
Source code in odak/learn/wave/classical.py
fraunhofer(field, k, distance, dx, wavelength)
¶
A definition to calculate light transport usin Fraunhofer approximation.
Parameters:
-
field
–Complex field (MxN).
-
k
–Wave number of a wave, see odak.wave.wavenumber for more.
-
distance
–Propagation distance.
-
dx
–Size of one single pixel in the field grid (in meters).
-
wavelength
–Wavelength of the electric field.
Returns:
-
result
(complex
) –Final complex field (MxN).
Source code in odak/learn/wave/classical.py
gerchberg_saxton(field, n_iterations, distance, dx, wavelength, slm_range=6.28, propagation_type='Transfer Function Fresnel')
¶
Definition to compute a hologram using an iterative method called Gerchberg-Saxton phase retrieval algorithm. For more on the method, see: Gerchberg, Ralph W. "A practical algorithm for the determination of phase from image and diffraction plane pictures." Optik 35 (1972): 237-246.
Parameters:
-
field
–Complex field (MxN).
-
distance
–Propagation distance.
-
dx
–Size of one single pixel in the field grid (in meters).
-
wavelength
–Wavelength of the electric field.
-
slm_range
–Typically this is equal to two pi. See odak.wave.adjust_phase_only_slm_range() for more.
-
propagation_type
(str
, default:'Transfer Function Fresnel'
) –Type of the propagation (see odak.learn.wave.propagate_beam).
Returns:
-
hologram
(cfloat
) –Calculated complex hologram.
-
reconstruction
(cfloat
) –Calculated reconstruction using calculated hologram.
Source code in odak/learn/wave/classical.py
get_angular_spectrum_kernel(nu, nv, dx=8e-06, wavelength=5.15e-07, distance=0.0, device=torch.device('cpu'))
¶
Helper function for odak.learn.wave.angular_spectrum.
Parameters:
-
nu
–Resolution at X axis in pixels.
-
nv
–Resolution at Y axis in pixels.
-
dx
–Pixel pitch in meters.
-
wavelength
–Wavelength in meters.
-
distance
–Distance in meters.
-
device
–Device, for more see torch.device().
Returns:
-
H
(float
) –Complex kernel in Fourier domain.
Source code in odak/learn/wave/classical.py
get_band_limited_angular_spectrum_kernel(nu, nv, dx=8e-06, wavelength=5.15e-07, distance=0.0, device=torch.device('cpu'))
¶
Helper function for odak.learn.wave.band_limited_angular_spectrum.
Parameters:
-
nu
–Resolution at X axis in pixels.
-
nv
–Resolution at Y axis in pixels.
-
dx
–Pixel pitch in meters.
-
wavelength
–Wavelength in meters.
-
distance
–Distance in meters.
-
device
–Device, for more see torch.device().
Returns:
-
H
(float
) –Complex kernel in Fourier domain.
Source code in odak/learn/wave/classical.py
get_propagation_kernel(nu, nv, dx=8e-06, wavelength=5.15e-07, distance=0.0, device=torch.device('cpu'), propagation_type='Bandlimited Angular Spectrum', scale=1)
¶
Get propagation kernel for the propagation type.
Parameters:
-
nu
–Resolution at X axis in pixels.
-
nv
–Resolution at Y axis in pixels.
-
dx
–Pixel pitch in meters.
-
wavelength
–Wavelength in meters.
-
distance
–Distance in meters.
-
device
–Device, for more see torch.device().
-
propagation_type
–Propagation type. The options are `Angular Spectrum`, `Bandlimited Angular Spectrum` and `Transfer Function Fresnel`.
-
scale
–Scale factor for scaled beam propagation.
Returns:
-
kernel
(tensor
) –Complex kernel for the given propagation type.
Source code in odak/learn/wave/classical.py
get_transfer_function_fresnel_kernel(nu, nv, dx=8e-06, wavelength=5.15e-07, distance=0.0, device=torch.device('cpu'))
¶
Helper function for odak.learn.wave.transfer_function_fresnel.
Parameters:
-
nu
–Resolution at X axis in pixels.
-
nv
–Resolution at Y axis in pixels.
-
dx
–Pixel pitch in meters.
-
wavelength
–Wavelength in meters.
-
distance
–Distance in meters.
-
device
–Device, for more see torch.device().
Returns:
-
H
(float
) –Complex kernel in Fourier domain.
Source code in odak/learn/wave/classical.py
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
–float input target to be converted into a hologram (Target should be in range of 0 and 1).
-
wavelength
–Wavelength of the electric field.
-
distance
–Propagation distance.
-
dx
–Size of one single pixel in the field grid (in meters).
-
device
–Device type (cuda or cpu)`.
-
lens_size
–Size of lens for masking sub holograms(in pixels).
Returns:
-
hologram
(cfloat
) –Calculated complex hologram.
Source code in odak/learn/wave/classical.py
propagate_beam(field, k, distance, dx, wavelength, propagation_type='Bandlimited Angular Spectrum', kernel=None, zero_padding=[True, False, True], aperture=1.0)
¶
Definitions for various beam propagation methods mostly in accordence with "Computational Fourier Optics" by David Vuelz.
Parameters:
-
field
–Complex field [m x n].
-
k
–Wave number of a wave, see odak.wave.wavenumber for more.
-
distance
–Propagation distance.
-
dx
–Size of one single pixel in the field grid (in meters).
-
wavelength
–Wavelength of the electric field.
-
propagation_type
(str
, default:'Bandlimited Angular Spectrum'
) –Type of the propagation. The options are Transfer Function Fresnel, Angular Spectrum, Bandlimited Angular Spectrum, Fraunhofer.
-
kernel
–Custom complex kernel.
-
zero_padding
–Zero padding the input field if the first item in the list set True. Zero padding in the Fourier domain if the second item in the list set to True. Cropping the result with half resolution if the third item in the list is set to true. Note that in Fraunhofer propagation, setting the second item True or False will have no effect.
Returns:
-
result
(complex
) –Final complex field [m x n].
Source code in odak/learn/wave/classical.py
shift_w_double_phase(phase, depth_shift, pixel_pitch, wavelength, propagation_type='Transfer Function Fresnel', kernel_length=4, sigma=0.5, amplitude=None)
¶
Shift a phase-only hologram by propagating the complex hologram and double phase principle. Coded following in here and Shi, L., Li, B., Kim, C., Kellnhofer, P., & Matusik, W. (2021). Towards real-time photorealistic 3D holography with deep neural networks. Nature, 591(7849), 234-239.
Parameters:
-
phase
–Phase value of a phase-only hologram.
-
depth_shift
–Distance in meters.
-
pixel_pitch
–Pixel pitch size in meters.
-
wavelength
–Wavelength of light.
-
propagation_type
(str
, default:'Transfer Function Fresnel'
) –Beam propagation type. For more see odak.learn.wave.propagate_beam().
-
kernel_length
–Kernel length for the Gaussian blur kernel.
-
sigma
–Standard deviation for the Gaussian blur kernel.
-
amplitude
–Amplitude value of a complex hologram.
Source code in odak/learn/wave/classical.py
597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 |
|
stochastic_gradient_descent(target, wavelength, distance, pixel_pitch, propagation_type='Bandlimited Angular Spectrum', n_iteration=100, loss_function=None, learning_rate=0.1)
¶
Definition to generate phase and reconstruction from target image via stochastic gradient descent.
Parameters:
-
target
–Target field amplitude [m x n]. Keep the target values between zero and one.
-
wavelength
–Set if the converted array requires gradient.
-
distance
–Hologram plane distance wrt SLM plane.
-
pixel_pitch
–SLM pixel pitch in meters.
-
propagation_type
–Type of the propagation (see odak.learn.wave.propagate_beam()).
-
n_iteration
–Number of iteration.
-
loss_function
–If none it is set to be l2 loss.
-
learning_rate
–Learning rate.
Returns:
-
hologram
(Tensor
) –Phase only hologram as torch array
reconstruction_intensity : torch.Tensor Reconstruction as torch array
Source code in odak/learn/wave/classical.py
transfer_function_fresnel(field, k, distance, dx, wavelength, zero_padding=False, aperture=1.0)
¶
A definition to calculate convolution based Fresnel approximation for beam propagation.
Parameters:
-
field
–Complex field (MxN).
-
k
–Wave number of a wave, see odak.wave.wavenumber for more.
-
distance
–Propagation distance.
-
dx
–Size of one single pixel in the field grid (in meters).
-
wavelength
–Wavelength of the electric field.
-
zero_padding
–Zero pad in Fourier domain.
-
aperture
–Fourier domain aperture (e.g., pinhole in a typical holographic display). The default is one, but an aperture could be as large as input field [m x n].
Returns:
-
result
(complex
) –Final complex field (MxN).
Source code in odak/learn/wave/classical.py
holographic_display
¶
A class for simulating a holographic display.
Source code in odak/learn/wave/hardware.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
|
__init__(wavelengths, pixel_pitch=3.74e-06, resolution=[1920, 1080], volume_depth=0.01, number_of_depth_layers=10, image_location_offset=0.005, pinhole_size=1500, pad=[True, True], illumination=None, propagation_type='Bandlimited Angular Spectrum', device=None)
¶
Parameters:
-
wavelengths
–List of wavelengths in meters (e.g., 531e-9).
-
pixel_pitch
–Pixel pitch in meters (e.g., 8e-6).
-
resolution
–Resolution (e.g., 1920 x 1080).
-
volume_depth
–Volume depth in meters.
-
number_of_depth_layers
(int
, default:10
) –Number of depth layers.
-
image_location_offset
–Image location offset in depth.
-
pinhole_size
–Size of the pinhole aperture in pixel in a 4f imaging system.
-
pad
–Set it to list of True bools for zeropadding and cropping each time propagating (avoiding aliasing).
-
illumination
–Provide the amplitude profile of the illumination source.
-
device
–Device to be used (e.g., cuda, cpu).
Source code in odak/learn/wave/hardware.py
forward(input_field, wavelength_id, depth_id)
¶
Function that represents the forward model in hologram optimization.
Parameters:
-
input_field
–Input complex input field.
-
wavelength_id
–Identifying the color primary to be used.
-
depth_id
–Identifying the depth layer to be used.
Returns:
-
output_field
(tensor
) –Propagated output complex field.
Source code in odak/learn/wave/hardware.py
generate_kernels()
¶
Internal function to generate light transport kernels.
Source code in odak/learn/wave/hardware.py
init_amplitude(illumination)
¶
Internal function to set the amplitude of the illumination source.
Source code in odak/learn/wave/hardware.py
init_aperture()
¶
Internal function to initialize aperture.
init_distances()
¶
Internal function to set the image plane distances.
Source code in odak/learn/wave/hardware.py
reconstruct(hologram_phases, laser_powers)
¶
Internal function to reconstruct a given hologram.
Parameters:
-
hologram_phases
–A monochrome hologram phase [m x n].
-
laser_powers
–Laser powers for each hologram phase. Values must be between zero and one.
Returns:
-
reconstruction_intensities
(tensor
) –Reconstructed frames [w x k x l x m x n]. First dimension represents the number of frames. Second dimension represents the depth layers. Third dimension is for the color primaries (each wavelength provided).
Source code in odak/learn/wave/hardware.py
blazed_grating(nx, ny, levels=2, axis='x')
¶
A defininition to generate a blazed grating (also known as ramp grating). For more consult de Blas, Mario García, et al. "High resolution 2D beam steerer made from cascaded 1D liquid crystal phase gratings." Scientific Reports 12.1 (2022): 5145 and Igasaki, Yasunori, et al. "High efficiency electrically-addressable phase-only spatial light modulator." optical review 6 (1999): 339-344.
Parameters:
-
nx
–Size of the output along X.
-
ny
–Size of the output along Y.
-
levels
–Number of pixels.
-
axis
–Axis of glazed grating. It could be `x` or `y`.
Source code in odak/learn/wave/lens.py
linear_grating(nx, ny, every=2, add=None, axis='x')
¶
A definition to generate a linear grating. This could also be interpreted as two levels blazed grating. For more on blazed gratings see odak.learn.wave.blazed_grating() function.
Parameters:
-
nx
–Size of the output along X.
-
ny
–Size of the output along Y.
-
every
–Add the add value at every given number.
-
add
–Angle to be added.
-
axis
–Axis eiter X,Y or both.
Returns:
-
field
(tensor
) –Linear grating term.
Source code in odak/learn/wave/lens.py
prism_grating(nx, ny, k, angle, dx=0.001, axis='x', phase_offset=0.0)
¶
A definition to generate 2D phase function that represents a prism. See Goodman's Introduction to Fourier Optics book or Engström, David, et al. "Improved beam steering accuracy of a single beam with a 1D phase-only spatial light modulator." Optics express 16.22 (2008): 18275-18287. for more.
Parameters:
-
nx
–Size of the output along X.
-
ny
–Size of the output along Y.
-
k
–See odak.wave.wavenumber for more.
-
angle
–Tilt angle of the prism in degrees.
-
dx
–Pixel pitch.
-
axis
–Axis of the prism.
-
phase_offset
(float
, default:0.0
) –Phase offset in angles. Default is zero.
Returns:
-
prism
(tensor
) –Generated phase function for a prism.
Source code in odak/learn/wave/lens.py
quadratic_phase_function(nx, ny, k, focal=0.4, dx=0.001, offset=[0, 0])
¶
A definition to generate 2D quadratic phase function, which is typically use to represent lenses.
Parameters:
-
nx
–Size of the output along X.
-
ny
–Size of the output along Y.
-
k
–See odak.wave.wavenumber for more.
-
focal
–Focal length of the quadratic phase function.
-
dx
–Pixel pitch.
-
offset
–Deviation from the center along X and Y axes.
Returns:
-
function
(tensor
) –Generated quadratic phase function.
Source code in odak/learn/wave/lens.py
multiplane_loss
¶
Loss function for computing loss in multiplanar images. Unlike, previous methods, this loss function accounts for defocused parts of an image.
Source code in odak/learn/wave/loss.py
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 |
|
__call__(image, target, plane_id=None)
¶
Calculates the multiplane loss against a given target.
Parameters:
-
image
–Image to compare with a target [3 x m x n].
-
target
–Target image for comparison [3 x m x n].
-
plane_id
–Number of the plane under test.
Returns:
-
loss
(tensor
) –Computed loss.
Source code in odak/learn/wave/loss.py
__init__(target_image, target_depth, blur_ratio=0.25, target_blur_size=10, number_of_planes=4, weights=[1.0, 2.1, 0.6, 0.0], multiplier=1.0, scheme='defocus', reduction='mean', device=torch.device('cpu'))
¶
Parameters:
-
target_image
–Color target image [3 x m x n].
-
target_depth
–Monochrome target depth, same resolution as target_image.
-
target_blur_size
–Maximum target blur size.
-
blur_ratio
–Blur ratio, a value between zero and one.
-
number_of_planes
–Number of planes.
-
weights
–Weights of the loss function.
-
multiplier
–Multiplier to multipy with targets.
-
scheme
–The type of the loss, `naive` without defocus or `defocus` with defocus.
-
reduction
–Reduction can either be 'mean', 'none' or 'sum'. For more see: https://pytorch.org/docs/stable/generated/torch.nn.MSELoss.html#torch.nn.MSELoss
-
device
–Device to be used (e.g., cuda, cpu, opencl).
Source code in odak/learn/wave/loss.py
add_defocus_blur()
¶
Internal function for adding defocus blur to the multiplane targets. Users can query the results with get_targets() within the same class.
Source code in odak/learn/wave/loss.py
get_targets()
¶
Returns:
-
targets
(tensor
) –Returns a copy of the targets.
-
target_depth
(tensor
) –Returns a copy of the normalized quantized depth map.
Source code in odak/learn/wave/loss.py
set_targets()
¶
Internal function for slicing the depth into planes without considering defocus. Users can query the results with get_targets() within the same class.
Source code in odak/learn/wave/loss.py
phase_gradient
¶
Bases: Module
The class 'phase_gradient' provides a regularization function to measure the variation(Gradient or Laplace) of the phase of the complex amplitude.
This implements a convolution of the phase with a kernel.
The kernel is a simple 3 by 3 Laplacian kernel here, but you can also try other edge detection methods.
Source code in odak/learn/wave/loss.py
__init__(kernel=None, loss=nn.MSELoss(), device=torch.device('cpu'))
¶
Parameters:
-
kernel
–Convolution filter kernel, 3 by 3 Laplacian kernel by default.
-
loss
–loss function, L2 Loss by default.
Source code in odak/learn/wave/loss.py
forward(phase)
¶
Calculates the phase gradient Loss.
Parameters:
-
phase
–Phase of the complex amplitude.
Returns:
-
loss_value
(tensor
) –The computed loss.
Source code in odak/learn/wave/loss.py
functional_conv2d(phase)
¶
Calculates the gradient of the phase.
Parameters:
-
phase
–Phase of the complex amplitude.
Returns:
-
edge_detect
(tensor
) –The computed phase gradient.
Source code in odak/learn/wave/loss.py
speckle_contrast
¶
Bases: Module
The class 'speckle_contrast' provides a regularization function to measure the speckle contrast of the intensity of the complex amplitude using C=sigma/mean. Where C is the speckle contrast, mean and sigma are mean and standard deviation of the intensity.
We refer to the following paper:
Kim et al.(2020). Light source optimization for partially coherent holographic displays with consideration of speckle contrast, resolution, and depth of field. Scientific Reports. 10. 18832. 10.1038/s41598-020-75947-0.
Source code in odak/learn/wave/loss.py
__init__(kernel_size=11, step_size=(1, 1), loss=nn.MSELoss(), device=torch.device('cpu'))
¶
Parameters:
-
kernel_size
–Convolution filter kernel size, 11 by 11 average kernel by default.
-
step_size
–Convolution stride in height and width direction.
-
loss
–loss function, L2 Loss by default.
Source code in odak/learn/wave/loss.py
forward(intensity)
¶
Calculates the speckle contrast Loss.
Parameters:
-
intensity
–intensity of the complex amplitude.
Returns:
-
loss_value
(tensor
) –The computed loss.
Source code in odak/learn/wave/loss.py
functional_conv2d(intensity)
¶
Calculates the speckle contrast of the intensity.
Parameters:
-
intensity
–Intensity of the complex field.
Returns:
-
Speckle_C
(tensor
) –The computed speckle contrast.
Source code in odak/learn/wave/loss.py
mixed_color_hologram_optimizer
¶
A class for optimizing holograms.
Source code in odak/learn/wave/optimizers.py
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 |
|
direct_phase_constrain(phase, phase_offset)
¶
Internal function to constrain a given phase.
Parameters:
-
phase
–Input phase values to be constrained.
-
phase_offset
–Input phase offset value.
Returns:
-
phase_only
(tensor
) –Constrained output phase.
Source code in odak/learn/wave/optimizers.py
double_phase_constrain(phase, phase_offset)
¶
Internal function to constrain a given phase similarly to double phase encoding.
Parameters:
-
phase
–Input phase values to be constrained.
-
phase_offset
–Input phase offset value.
Returns:
-
phase_only
(tensor
) –Constrained output phase.
Source code in odak/learn/wave/optimizers.py
evaluate(input_image, target_image, plane_id=0)
¶
Internal function to evaluate the loss.
Source code in odak/learn/wave/optimizers.py
gradient_descent(number_of_iterations=100, weights=[1.0, 1.0, 0.0, 0.0])
¶
Function to optimize multiplane phase-only holograms using stochastic gradient descent.
Parameters:
-
number_of_iterations
–Number of iterations.
-
weights
–Weights used in the loss function.
Returns:
-
hologram
(tensor
) –Optimised hologram.
Source code in odak/learn/wave/optimizers.py
537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 |
|
init_amplitude()
¶
Internal function to set the amplitude of the illumination source.
init_channel_power()
¶
Internal function to set the starting phase of the phase-only hologram.
Source code in odak/learn/wave/optimizers.py
init_loss_function(loss_function, reduction='sum')
¶
Internal function to set the loss function.
Source code in odak/learn/wave/optimizers.py
init_optimizer()
¶
Internal function to set the optimizer.
Source code in odak/learn/wave/optimizers.py
init_peak_amplitude_scale()
¶
Internal function to set the phase scale.
init_phase()
¶
Internal function to set the starting phase of the phase-only hologram.
Source code in odak/learn/wave/optimizers.py
init_phase_scale()
¶
Internal function to set the phase scale.
Source code in odak/learn/wave/optimizers.py
optimize(number_of_iterations=100, weights=[1.0, 1.0, 1.0])
¶
Function to optimize multiplane phase-only holograms.
Parameters:
-
number_of_iterations
–Number of iterations.
-
weights
–Loss weights.
Returns:
-
hologram_phases
(tensor
) –Phases of the optimized phase-only hologram.
-
reconstruction_intensities
(tensor
) –Intensities of the images reconstructed at each plane with the optimized phase-only hologram.
Source code in odak/learn/wave/optimizers.py
reconstruct(hologram_phases)
¶
Internal function to reconstruct a given hologram.
Parameters:
-
hologram_phase
–A monochrome hologram phase [mxn].
Returns:
-
reconstruction_intensities
(tensor
) –Reconstructed frames.
-
reconstruction_intensity
(tensor
) –Reconstructed image.
-
peak_intensity
(float
) –Peak intensity in the reconstructed image.
Source code in odak/learn/wave/optimizers.py
multiplane_hologram_optimizer
¶
A highly configurable class for optimizing multiplane holograms.
Source code in odak/learn/wave/optimizers.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 |
|