Skip to main content

Python implementation of the Bayesian MEF method

Project description

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

To install the package and its dependencies,

pip install bayes_mef

Usage

A minimal example demonstrating the usage of BayesianMEF by simulating some data.

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/ 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.

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.

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

bayes_mef-0.1.2.tar.gz (10.7 kB view hashes)

Uploaded Source

Built Distribution

bayes_mef-0.1.2-py3-none-any.whl (11.2 kB view hashes)

Uploaded Python 3

Supported by

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