Skip to main content

Tensorflow implementation of the Multidimensional Contrast Limited Adaptive Histogram Equalization (MCLAHE) procedure

Project description

Multidimensional Contrast Limited Adaptive Histogram Equalization

Note: for the latest version of the software please visit VincentStimper/mclahe.

Introduction

Multidimensional Contrast Limited Adaptive Histogram Equalization (MCLAHE) is a multidimensional extension of the contrast enhancement procedure CLAHE for images. It can be applied to datasets with an arbitrary number of dimensions. This repository comprises an implementation in Tensorflow and one in NumPy only. Both can be run on multiple CPUs, and the Tensorflow implementation works with other hardware accelerators such as GPUs as well.

Installation

The Tensorflow implementation of the package can be installed via pip

pip install --upgrade https://github.com/mpes-kit/mclahe/archive/master.zip

To install the NumPy version, run

pip install --upgrade https://github.com/VincentStimper/mclahe/archive/numpy.zip

Requirements

The main package requires numpy and tensorflow. tensorflow needs to be installed manually depending on the hardware in use. The package supports tensorflow 2.0 and later versions. A comprehensive installation guide is given at the Tensorflow webpage. For the NumPy version, only numpy needs to be installed. The example notebook requires matplotlib in addition.

Sample datasets

Fluorescence microscopy

Fluorescence microscopy can be used to capture time resolved volumetric images of a developing embryo. To illustrate the effectiveness of MCLAHE we applied it to a dataset of an organism of species phallusia mammillata (available here). To reduce the noise in the data, we preprocessed it by a median filter with kernel size (2, 2, 2, 1) in the (x, y, z, t) space

            MCLAHE applied to fluorescence microscopy data

The above image show a slice along the z-axis through the data. The unit hpf means hours post fertilization. Our hyperparameters of choice were the kernel size (20, 20, 10, 25), 256 bins in the histogram, and a clipping limit of 0.25. We used a global histogram range

Multidimensional photoemission spectroscopy

Multidimensional photoemission spectroscopy is a technique to map the electronic band structure in a 4D space consisting of two momentum (kx, ky), an energy (E), and a pump-probe time delay (tpp) coordinate. In the raw data, the excited state (E > 0) is not visible. 4D CLAHE makes is visible while enhancing local features in the other states but preserving the temporal intensity changes.

MCLAHE applied to MPES data

Here, we used a kernel size of (30, 30, 15, 20) in (kx, ky, E, tpp) space, 256 histogram bins, and a clipping limit of 0.02. We made use of the adaptive histogram range for processing this dataset.

Documentation

def mclahe(x, kernel_size=None, n_bins=128, clip_limit=0.01, adaptive_hist_range=False, use_gpu=True):
    ...

Parameters

  • x: Input data as a numpy array with a arbitrary number of dimensions
  • kernel_size: Tuple, list, or numpy array specifying the kernel size along the data dimensions. If kernel_size=None, the kernel size is set to 1/8 of the data size along each dimension. This is a typical choice for photographs. For more complex dataset, the kernel size should be roughly of the size of the features which shall be enhanced by MCLAHE.
  • n_bins: Integer specifying the number of histogram bins used within each kernel. Typically, it is set to a power of two like 128 or 256 but any number could be chosen.
  • clip_limit: Float being the share of voxels within a kernel at which the histogram shall be clipped. A clipping limit of 1 corresponds to standard histogram equalization and if it is smaller than 1 the contrast enhancement is limited. Since a relative histogram height of 1/n_bins corresponds to a uniform distribution the clipping limit should be higher than that.
  • adaptive_hist_range: flag saying whether an adaptive histogram range (AHR) shall be used or not. With AHR, each histogram uses its own range determined by the minimum and maximum intensity in the kernel. Otherwise, the range is set by the global minimum and maximum within the data.
  • use_gpu: flag specifying whether a GPU shall be used for computations if available. If there is no GPU available, this flag has no influence. If the dataset is very large it might be necessary to use CPUs only to not run out of memory on the GPU.

Citation

If you are using this package within your own projects, please cite it as

V. Stimper, S. Bauer, R. Ernstorfer, B. Schölkopf and R. P. Xian, "Multidimensional Contrast Limited Adaptive Histogram Equalization," in IEEE Access, vol. 7, pp. 165437-165447, 2019.

Bibtex code

@article{Stimper2019,
    author={V. {Stimper} and S. {Bauer} and R. {Ernstorfer} and B. {Schölkopf} and R. P. {Xian}},
    journal={IEEE Access},
    title={Multidimensional Contrast Limited Adaptive Histogram Equalization},
    year={2019},
    volume={7}, 
    pages={165437-165447},
    doi={10.1109/ACCESS.2019.2952899},
}

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

mclahe-1.1.0.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

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

mclahe-1.1.0-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file mclahe-1.1.0.tar.gz.

File metadata

  • Download URL: mclahe-1.1.0.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for mclahe-1.1.0.tar.gz
Algorithm Hash digest
SHA256 7d8d702e213a2dab5823d503e7aebe35c9cfd60b2e0c5bcb2dbd021b6bb5b76b
MD5 c636442ceb71c1f966c9d7a8b1803299
BLAKE2b-256 90f0c075fdcb4247d775629ce30ceb5af428d92ef63f6a53bc99a12f9ee51c49

See more details on using hashes here.

Provenance

The following attestation bundles were made for mclahe-1.1.0.tar.gz:

Publisher: release.yml on mpes-kit/mclahe

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mclahe-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: mclahe-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for mclahe-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9a79641cc6f39ce0d003bf3b0d36bb99f2811e0be75a262942d4e6add4aad68d
MD5 1472e1ac99b27b6d0f0f2780b679f3aa
BLAKE2b-256 8ab8bbec91fa4079bb7dd56663d6fb88b4ca97e47a7fe4a2c0368d33c1e18048

See more details on using hashes here.

Provenance

The following attestation bundles were made for mclahe-1.1.0-py3-none-any.whl:

Publisher: release.yml on mpes-kit/mclahe

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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