Skip to main content

Python implementation of computational optical propagation and digital holography.

Project description

In-line Holographic Reconstruction

Python implementation of angular spectrum and multi-height phase recovery algorithms to reconstruct digital in-line holograms.

What's inside?

This package includes solvers for the holographic reconstruction problem. Computations can be performed on both cpu and gpu. The gpu-accelerated version is programmed on tensorflow and is auto-gradient friendly, thus can be easily employed on machine learning models.

Installation

To install the package, run:

pythom -m pip install fringe

The example files are not included in the package. To import them, clone the repository. In the git bash, run:

$ git clone https://github.com/farhadnkm/Fringe.Py

How to use

  1. Import images

Images must be ndarrays or tensors. A simple i/o functionality for this purpose is integrated inside the package:

from fringe.utils.io import import_image, import_image_seq, export_image
from fringe.utils.modifiers import ImageToArray, PreprocessHologram, ConvertToTensor

Modifiers are preprocessing classes. These classes have a process method which is called by the import functions on any image import and returns the processed image.

image_path = 'IMAGE_PATH.tif'
background_path = 'BACKGROUND_PATH.tif'

p1 = ImageToArray(bit_depth=16, channel='gray', crop_window=None, dtype='float32')
bg = import_image(background_path, preprocessor=p1)
p2 = PreprocessHologram(background=bg)

hologram = import_image(background_path, preprocessor=[p1, p2])
  1. Reconstruct holograms

Solvers are reconstruction algorithms having a solve function. solve functions give hologram(s) and axial distance(s) as input parameters and return a complex-valued reconstructed image.

solver = AsSolver(shape=h.shape, dx=1.12, dy=1.12, wavelength=532e-3)
z = -300

amp = np.abs(solver.solve(hologram, z))
phase = unwrap_phase(np.angle(solver.solve(hologram, z)))
  1. Export outputs
export_image(amp, os.path.join('PATH', 'amplitude.png'), dtype='uint8')
export_image(phase, os.path.join('PATH', 'phase.png'), dtype='uint8')

Examples and further details for multi-height phase recovery and gpu processing are included in the example notebooks.

Outcomes

A Hologram:

Reconstructed Amplitude and phase images obtained by back propagation:

Reconstructed Amplitude and phase images obtained by MHPR method using 8 axially displaced holograms:

======= History

0.0.1 (2021-02-19)

  • First release on PyPI.

0.0.2 (2021-02-25)

  • Some bugs and errors fixed

0.0.3 (2021-02-25)

  • Minor bugs fixed

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fringe-1.0.1.tar.gz (18.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fringe-1.0.1-py2.py3-none-any.whl (16.8 kB view details)

Uploaded Python 2Python 3

File details

Details for the file fringe-1.0.1.tar.gz.

File metadata

  • Download URL: fringe-1.0.1.tar.gz
  • Upload date:
  • Size: 18.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.10

File hashes

Hashes for fringe-1.0.1.tar.gz
Algorithm Hash digest
SHA256 aa19614dea50992be37a116aac0723230223536a925d4985338940258c9299c7
MD5 1cbfb3d48949f40d70181c067b1cb242
BLAKE2b-256 fae40606ed48cba4ce08c0c2ca8edf49137277637786d037add6c58074dd21c0

See more details on using hashes here.

File details

Details for the file fringe-1.0.1-py2.py3-none-any.whl.

File metadata

  • Download URL: fringe-1.0.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 16.8 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.10

File hashes

Hashes for fringe-1.0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 4c002a1db04dc76bf7ddcb69ed99a343e5e27542dda1ad8911bf838f27c744fb
MD5 cb5f90cf2a3f8113491f2ea0c5773f07
BLAKE2b-256 9235ff86cbdc27f21e510156e0cbde690f3ecc362fb47c44ace80d97c3c71bd3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page