ZEISS Microscopy Knowledge Base
Help
ZEISS Microscopy Knowledge Base

Performing contrast limited adaptive histogram equalization (CLAHE)»

This guide explains how to apply the contrast limited adaptive histogram equalization (CLAHE) algorithm. The CLAHE algorithm partitions the images into contextual regions and applies the histogram equalization to each one. This evens out the distribution of used grey values and thus makes hidden features of the image more visible. The full grey spectrum is used to express the image. CLAHE is an improved version of AHE, or Adaptive Histogram Equalization. Both overcome the limitations of standard histogram equalization.

Opening the working dataset

  1. Select Open... from the file menu.
    File menu showing Open... option highlighted with shortcut CTRL+O
  2. Select the dataset from the file browser.
    The dataset is a multi dimensional, discrete, representation of your real sample volume. It can be structured as a Z series of planes (Optical sectioning) of multiple channels (dyes) in a temporal sequence of time points (located in several spatial positions).​
    Usually, the dataset shows a single experimental situation (a complete experiment can be composed by several datasets). The datasets are available as graphic files saved in plenty of file formats (standard formats as well as proprietary formats)​.
    Note: The dataset is visualized according to the current rendering setting parameters. Refer to the arivis Vision4D Help for more details.
    Black background with scattered bright red dots and irregular elongated red clusters forming a curved band

Loading the Python script

  1. Open Python Script Editor. From the Extra menu, select Script Editor.
    Menu bar 'Extras' dropdown listing Preferences..., Plug-in Manager, Task Monitor, Run Script..., Script Editor
  2. Load the Clahe_Rev5 (3_4).py Python Script.
    Window title 'Script Editor - Script1' with menu items File Edit View Script
  3. Browse the folder on which the file has been saved.
    File menu with 'Open... Ctrl+O' highlighted and items New Ctrl+N, Open Sample, Close Ctrl+F4

Python script code usage rights:The user has the permission to use, modify and distribute this code, as long as this copyright notice remains part of the code itself: Copyright(c) 2021 arivis AG, Germany. All Rights Reserved.

Python script header showing NAME: Clahe; FILE: Clahe_Rev5 (3_4).py; AUTHOR: Maurizio Abbate; Copyright 2021 arivis AG

Setting the script features

Some Clahe algorithm options can be set to optimize the results:

Code screenshot of CLAHE options: INPUT_CHANNEL=0, CLAHE_CV2=True, BLOCK_NUMBER_X=16, CLIP_LIMIT_CV2=30

  • INPUT_CHANNEL : Set the source channel to be equalized. NOTE: Only one channel can be processed.
  • OUTPUT_CH_CHANNEL : Set the output channel name.

The size used to compute the Clahe can be freely set.

  • CLAHE_CV2 = True : Set the OpenCV2 algorithm – False the Skimage one.
  • HISTO_STRETCH : With the CLAHE_CV2 = False sets the result stretching.
  • BLOCK_NUMBER_X : Sets the number of horizontal patches (tiles) used to compute the local equlization.
  • BLOCK_NUMBER_Y : Sets the number of vertical patches (tiles) used to compute the local equalization.
  • CLIP_LIMIT_CV2 : Sets the clipping limit, normalized between 0 and 100 (higher values give more contrast). It is applied to the OpenCv2 algorithm.
  • CLIP_LIMIT_SKIMAGE : Sets the clipping limit, normalized between 0 and 1 (higher values give more contrast). It is applied to the Skimage algorithm.
  • ACTIVE_FRAME : If True, the Clahe is applied only to the active time point.
  • ACTIVE_PLANE : If True, the Clahe is applied only to the active Z plane.

ACTIVE_PLANE = False  # True == active plane; ACTIVE_FRAME = True  # True == active time point

Installing the Anaconda3 package and the OpenCV module

The Anaconda3 Package and the OpenCV module are required to run the script. Please refer to the Application Note #20 for more details.

  1. Once the Anaconda3 package has been correctly installed, the OpenCV module can be installed too.
  1. From the Window menu, select the Anaconda Prompt.
    Windows Start button icon on dark background
    Start menu showing Anaconda3 (64-bit) folder and Anaconda Prompt (anaconda3) highlighted
  2. Type pip install opencv-python and press return.
    Terminal showing (base) C:\Users\utente>pip install opencv-python
  3. A message confirms the correct OpenCv installation.
    Anaconda PowerShell showing conda env list and pip install opencv-python with 'Successfully installed opencv-python-4.5.2.52'
Impressum
Carl-Zeiss-Strasse 22
73447 Oberkochen
Germany
Legal