fringe


Namefringe JSON
Version 1.0.6 PyPI version JSON
download
home_pagehttps://github.com/farhadnkm/fringe
SummaryPython implementation of computational optical propagation and digital holography.
upload_time2023-03-16 13:20:32
maintainer
docs_urlNone
authorFarhad Niknam
requires_python>=3.6, <4
licenseMIT license
keywords diffraction angular spectrum holography holograms phase recovery
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            

# Fringe.Py

[![GitHub version](https://badge.fury.io/gh/farhadnkm%2FFringe.Py.svg)](https://badge.fury.io/gh/farhadnkm%2FFringe.Py)
[![PyPI version](https://badge.fury.io/py/fringe.svg)](https://badge.fury.io/py/fringe)
[![DOI](https://zenodo.org/badge/327240077.svg)](https://zenodo.org/badge/latestdoi/327240077)
[![MIT License](https://img.shields.io/apm/l/atomic-design-ui.svg?)](https://github.com/farhadnkm/Fringe.Py/blob/master/LICENSE)

A coherent propagation and diffraction simulation tool, all written in Python. 

In this package, a set of utilities are provided to simulate coherent signal propagation. It is particularly made for free-space optical propagation, diffraction, and holography. However, the tools are compatible with 1D and 2D data structures and can be potentially used for any sort of spatially-coherent signals.

-----

<p align="center">
    <img src="examples/images/exports/propagation_anim.gif" width="500">
<p>

    
## What's inside?

A set of modules are provided to solve the scalar diffraction problem. The codes are GPU-friendly, compatible with well-known computation libraries (Numpy, TensorFlow) and they support batch processing. Using the TensorFlow backend, computations become autograd-compatible and could be mounted on machine learning models. Angular spectrum algorithm is the primary work horse for field propagation though other custom solvers could be used. Aside the built-in Numpy and TensorFlow backends, any computational means could be employed to process tensor operations.

It also includes:
- a simple yet useful data pipeline to load and standardize data. For now, it only supports images.
- Gerchberg-Saxton multi-distance phase recovery algorithm. It can be easily tweaked to support other variations of signal e.g. by wavelength.

## Installation
To install the package, run:

```
python -m pip install fringe
```

Fringe requires ```numpy```, ```tensorflow 2.x```, and ```scikit_image```.
The example files are not included in the package and should be downloaded separately. Also they require ```matplotlib``` to show plots.

## How to Use
1. Import or create data

For images:

```python
import numpy as np
from fringe.utils.io import import_image
from fringe.utils.modifiers import ImageToArray, Normalize, MakeComplex
```

Images need to be standardized, normalized, and casted to complex data type. *Modifiers* are tools made for this purpose which apply these operations on import.

```python
p1 = ImageToArray(bit_depth=16, channel='gray', crop_window=None, dtype='float32')
p2 = Normalize(background=np.ones((512, 512)))
p3 = MakeComplex(set_as='amplitude', phase=0)

obj = import_image("images/squares.png", preprocessor=[p1, p2, p3])
```

2. Propagate

*Solvers* contain propagation algorithms and can be called by *solver.solve*. In particular, angular Spectrum algorithm convolves the input field with a free-space propagtor function which depends on *wavelength λ* (or *wavenumber k=2π/λ*) and distance *z*.

```python
from numpy import pi, abs, angle
from fringe.solvers.AngularSpectrum import AngularSpectrumSolver as AsSolver

solver = AsSolver(shape=obj.shape, dr=1, is_batched=False, padding="same", pad_fill_value=0, backend="Numpy")
rec = solver.solve(hologram, k=2*pi/500e-3, z=-1000)
amp, phase = abs(rec), angle(rec)

ax = pyplot.sublots(2, 1, 1)
ax[0].imshow(abs(obj))
ax[1].imshow(amp)
pyplot.show()
```

<p align="center">
    <img src="examples/images/exports/squares_1.png" width="300"> <img src="examples/images/exports/squares_2.png" width="300">
<p>

Example notebooks provide further details with 1D and 2D diffraction, GPU acceleration, batch processing, and phase recovery.

## License

Fringe is released under the MIT license. See LICENSE for details.


=======
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

0.0.5 (2023-03-15)
------------------
* AngularSpectrum.py
    Propagator issue for small pixels is resolved
    Near field propagation is now supported
* io.py
    skimage warnings io is fixed.

0.0.6 (2023-03-16)
------------------
* AngularSpectrum.py
    Bug fixed

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/farhadnkm/fringe",
    "name": "fringe",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6, <4",
    "maintainer_email": "",
    "keywords": "diffraction,angular spectrum,holography,holograms,phase recovery,",
    "author": "Farhad Niknam",
    "author_email": "farhad.niknam.em@gmail.com",
    "download_url": "",
    "platform": null,
    "description": "\n\n# Fringe.Py\n\n[![GitHub version](https://badge.fury.io/gh/farhadnkm%2FFringe.Py.svg)](https://badge.fury.io/gh/farhadnkm%2FFringe.Py)\n[![PyPI version](https://badge.fury.io/py/fringe.svg)](https://badge.fury.io/py/fringe)\n[![DOI](https://zenodo.org/badge/327240077.svg)](https://zenodo.org/badge/latestdoi/327240077)\n[![MIT License](https://img.shields.io/apm/l/atomic-design-ui.svg?)](https://github.com/farhadnkm/Fringe.Py/blob/master/LICENSE)\n\nA coherent propagation and diffraction simulation tool, all written in Python. \n\nIn this package, a set of utilities are provided to simulate coherent signal propagation. It is particularly made for free-space optical propagation, diffraction, and holography. However, the tools are compatible with 1D and 2D data structures and can be potentially used for any sort of spatially-coherent signals.\n\n-----\n\n<p align=\"center\">\n    <img src=\"examples/images/exports/propagation_anim.gif\" width=\"500\">\n<p>\n\n    \n## What's inside?\n\nA set of modules are provided to solve the scalar diffraction problem. The codes are GPU-friendly, compatible with well-known computation libraries (Numpy, TensorFlow) and they support batch processing. Using the TensorFlow backend, computations become autograd-compatible and could be mounted on machine learning models. Angular spectrum algorithm is the primary work horse for field propagation though other custom solvers could be used. Aside the built-in Numpy and TensorFlow backends, any computational means could be employed to process tensor operations.\n\nIt also includes:\n- a simple yet useful data pipeline to load and standardize data. For now, it only supports images.\n- Gerchberg-Saxton multi-distance phase recovery algorithm. It can be easily tweaked to support other variations of signal e.g. by wavelength.\n\n## Installation\nTo install the package, run:\n\n```\npython -m pip install fringe\n```\n\nFringe requires ```numpy```, ```tensorflow 2.x```, and ```scikit_image```.\nThe example files are not included in the package and should be downloaded separately. Also they require ```matplotlib``` to show plots.\n\n## How to Use\n1. Import or create data\n\nFor images:\n\n```python\nimport numpy as np\nfrom fringe.utils.io import import_image\nfrom fringe.utils.modifiers import ImageToArray, Normalize, MakeComplex\n```\n\nImages need to be standardized, normalized, and casted to complex data type. *Modifiers* are tools made for this purpose which apply these operations on import.\n\n```python\np1 = ImageToArray(bit_depth=16, channel='gray', crop_window=None, dtype='float32')\np2 = Normalize(background=np.ones((512, 512)))\np3 = MakeComplex(set_as='amplitude', phase=0)\n\nobj = import_image(\"images/squares.png\", preprocessor=[p1, p2, p3])\n```\n\n2. Propagate\n\n*Solvers* contain propagation algorithms and can be called by *solver.solve*. In particular, angular Spectrum algorithm convolves the input field with a free-space propagtor function which depends on *wavelength \u00ce\u00bb* (or *wavenumber k=2\u00cf\u20ac/\u00ce\u00bb*) and distance *z*.\n\n```python\nfrom numpy import pi, abs, angle\nfrom fringe.solvers.AngularSpectrum import AngularSpectrumSolver as AsSolver\n\nsolver = AsSolver(shape=obj.shape, dr=1, is_batched=False, padding=\"same\", pad_fill_value=0, backend=\"Numpy\")\nrec = solver.solve(hologram, k=2*pi/500e-3, z=-1000)\namp, phase = abs(rec), angle(rec)\n\nax = pyplot.sublots(2, 1, 1)\nax[0].imshow(abs(obj))\nax[1].imshow(amp)\npyplot.show()\n```\n\n<p align=\"center\">\n    <img src=\"examples/images/exports/squares_1.png\" width=\"300\"> <img src=\"examples/images/exports/squares_2.png\" width=\"300\">\n<p>\n\nExample notebooks provide further details with 1D and 2D diffraction, GPU acceleration, batch processing, and phase recovery.\n\n## License\n\nFringe is released under the MIT license. See LICENSE for details.\n\n\n=======\nHistory\n=======\n\n0.0.1 (2021-02-19)\n------------------\n* First release on PyPI.\n\n0.0.2 (2021-02-25)\n------------------\n* Some bugs and errors fixed\n\n0.0.3 (2021-02-25)\n------------------\n* Minor bugs fixed\n\n0.0.5 (2023-03-15)\n------------------\n* AngularSpectrum.py\n    Propagator issue for small pixels is resolved\n    Near field propagation is now supported\n* io.py\n    skimage warnings io is fixed.\n\n0.0.6 (2023-03-16)\n------------------\n* AngularSpectrum.py\n    Bug fixed\n",
    "bugtrack_url": null,
    "license": "MIT license",
    "summary": "Python implementation of computational optical propagation and digital holography.",
    "version": "1.0.6",
    "split_keywords": [
        "diffraction",
        "angular spectrum",
        "holography",
        "holograms",
        "phase recovery",
        ""
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d22125c4d2d12f3c43ce19e3cdf7f5e99f61521673862217b7d74a7652323d15",
                "md5": "c1c2c4c6f8afd3b4b66f8255c8812d0c",
                "sha256": "ee9d90d83261716dfce4ecff66b07c4873c0c5c67728d2e943dc22c85e0558da"
            },
            "downloads": -1,
            "filename": "fringe-1.0.6-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c1c2c4c6f8afd3b4b66f8255c8812d0c",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.6, <4",
            "size": 18145,
            "upload_time": "2023-03-16T13:20:32",
            "upload_time_iso_8601": "2023-03-16T13:20:32.673394Z",
            "url": "https://files.pythonhosted.org/packages/d2/21/25c4d2d12f3c43ce19e3cdf7f5e99f61521673862217b7d74a7652323d15/fringe-1.0.6-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-03-16 13:20:32",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "farhadnkm",
    "github_project": "fringe",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "tox": true,
    "lcname": "fringe"
}
        
Elapsed time: 0.04520s