Metadata-Version: 2.1
Name: bayes_mef
Version: 0.1.2
Summary: Python implementation of the Bayesian MEF method
Home-page: https://github.com/microscopic-image-analysis/bayes-mef
License: BSD-3-Clause
Author: Shantanu Kodgirwar
Author-email: shantanu.kodgirwar@uni-jena.de
Requires-Python: >=3.9,<3.12
Classifier: License :: OSI Approved :: BSD License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Requires-Dist: black (>=23.7.0,<24.0.0)
Requires-Dist: h5py (>=3.9.0,<4.0.0)
Requires-Dist: ipykernel (>=6.25.0,<7.0.0)
Requires-Dist: matplotlib (>=3.7.2,<4.0.0)
Requires-Dist: numpy (>=1.22,<=1.24.3)
Requires-Dist: scikit-image (>=0.21.0,<0.22.0)
Requires-Dist: scipy (>=1.11.1,<2.0.0)
Requires-Dist: tqdm (>=4.65.0,<5.0.0)
Project-URL: Repository, https://github.com/microscopic-image-analysis/bayes-mef
Description-Content-Type: text/markdown

# Bayesian MEF

Bayesian multi-exposure image fusion (MEF) is a general purpose MEF algorithm suitable for any imaging scheme requiring high dynamic range (HDR) treatment. Implementation of the algorithm in the context of ptychography has been published as "Bayesian multi-exposure image fusion for robust high dynamic range preprocessing in ptychography".

![demo_mef](https://github.com/microscopic-image-analysis/bayes-mef/assets/64919085/44f06535-7eac-47a0-b6db-62ef40456993)


To install the package and its dependencies, 
```bash
pip install bayes_mef
```

## Usage

A minimal example demonstrating the usage of `BayesianMEF` by simulating some data.
```python
from bayes_mef import BayesianMEF
from skimage.data import camera
import numpy as np

# simulation params
truth = camera()
background = 60  # some background
times = np.array([0.1, 1, 10])  # exposure times or equivalently flux factors
threshold = 1500 # detector limit

# poisson data based on image formation model that is overexposed
data = [np.random.poisson(time * truth + background) for time in times]
data_saturated = np.clip(data, None, threshold, dtype="float")

# Bayesian MEF with optional field `update_fluxes`. Set it to `True` when
# flux factors (exposure times) are not accurately known.
mef_em = BayesianMEF(data_saturated, threshold, times, background, update_fluxes=False)
mef_em.run(n_iter=100)
fused_im = mef_em.fused_image.copy()
```

Under [scripts/](scripts) directory, MEF with ptychographic data and subsequent reconstructions used in the publication can be tested. These are based on the package `ptylab` that can be installed additionally.

```bash
pip install git+https://github.com/PtyLab/PtyLab.py.git@main
```

For faster reconstructions using GPU, please install `cupy` as given under its [installation guide](https://docs.cupy.dev/en/stable/install.html).



