Skip to content

A Python library for Low-Light Image Enhancement

License

Notifications You must be signed in to change notification settings

glory-wan/LLIE-Lib

Repository files navigation

LLIELib: Low-Light Image Enhancement Library

LibLLIE is an open-source library for Low-Light Image Enhancement built on PyTorch.

This Python library provides a collection of traditional machine learning algorithms for low-light image enhancement. The library supports multiple color spaces and offers various methods for image enhancement. It is designed to be modular and easy to integrate into your existing projects.

The integration code for deep learning models is currently being developed and will be released soon !

Feel free to use this library in your research!

⭐ Star us on GitHub — your support means a lot!

Table of Contents

Supported Algorithms for now :

HE Series: HE、CLAHE、RCLAHE

Math series: gamma correction、log transformation

Dark Channel Prior(DCP): implementation of paper : Single image haze removal using dark channel prior

Color Spaces: RGB、HLS、HSV、LAB、YUV...

More algorithms will be released soon !

Installation

There are two ways to install LibLLIE.

conda create -n LlieLib python=3.8 -y
pip install -r requirements.txt

Method 1: Install from Source Code

git clone https://github.com/glory-wan/LLIE-Lib.git

pip install -e .  # Editable mode, suitable for those who wish to modify the source code.
pip install .     # Standard mode, suitable for installing the package without the need for further modification of the source code.

Method 2: Install Using a Compressed Package

With this method, you don't need to download the source code. Simply download a compressed package and execute the following command in your local Python environment.

The compressed package can be found at LLIE-Lib/dist, or you can download it from the Releases section.

pip install LibLlie-1.0.tar.gz

Quick Start

Command-Line Interface

To quickly start processing images using the command-line interface:

# traditional algorithm
python commandTA.py --img path/to/img --method he --cs hsv --name he_hsv --display True
# deep learning algorithm
python commandDL.py --model model --model_path weights.pth --input_dir path/to/img --output_dir path/to/output_img

Supported algorithms and color spaces can be found in the LibLlie/troditionAlgorithm/config.py (traditional algorithm) and LibLlie/deelLearning/config.py (deep learning algorithm) file.

Script Interface

To use the library in a Python script:

# traditional algorithm
from LibLlie.scriptTA import script_ta

img = script_ta(
    img_path='path/to/img.jpg',
    algorithm='he',
	
    # following parameters are alternative
    showimg=True,
    saveimg=False,
    # name='rgb_he',
    # width=800,
    # height=600,
    # format='jpg',
    # directory=results_path,
    # clipLimit=2.0,   # default = 2.0
    # gridSize=8,    # default = 8
    # iteration=2,    # default = 2
    # dcpSize=15,     # default = 15
)

Parameters (traditional algorithm)

The configuration parameters for the algorithms can be set via the command line or within a script:

  • --img: Path to the image file (URL or local path).
  • --method: Selected algorithm (e.g., he, clahe, rclahe).
  • --cs: Selected color space (e.g., rgb, hls, hsv, lab, yuv).

Optional parameters include clipLimit, gridSize, iteration, name, save, format, display, width, and height.

More details can be found in the LibLlie/troditionAlgorithm/config.py file.

# deep learning algorithm
from LibLlie.deelLearning.utils.utils import scriptDL

img = scriptDL(
    model='Zero-DCE',
    model_path=r'LibLlie/models/Zero-DCE/Zero-DCE.pth',
    input_dir=r'assets/DL_test/input',
    output_dir=r'assets/DL_test/output',

    # following parameters are alternative
    # save_format='jpg',
    # batch_size=1,
    # output_height=256,
)

Parameters (deep learning algorithm)

The configuration parameters for the algorithms can be set via the command line or within a script:

  • --model: the deep learning algorithm
  • --model_path: the weights which will be load, saved in LibLlie/models.

Other parameters are optional.

More details can be found in the LibLlie/deelLearning/config.py file.

Case Studies

Below are some examples demonstrating the enhancement effects achieved using LibLLIE on low-light images.

Original vs Enhanced Images using HE series

the inputinput

the results of HE series

image-20240817204710109

Original vs Enhanced Images using gamma correction

The input

gamma

The result with varying gamma values

for i in tqdm(np.arange(0.0, 30.0, 0.05)):  # Gamma values from 0.0 to 30.0 with a step size of 0.05
    gamma_img = gamma_correction(img, gamma=i)
gamma_correction.mp4

Original vs Enhanced Images using Dark Channel Prior

Dark Channel Prior

Original vs Enhanced Images using Single-Frame Multi-Enhancement Fusion

(This part of the code will be uploaded soon.)

Multi-Enhancement

Contributor

Some parts of LLIELib's code were completed with the assistance of Ln3214, BZ2116, zhlhlz, KyleTang-0711, Bainianzzz, purplers, Mystic2004, Humbleb11, 7dayu6 shazhou01.

We welcome contributions to improve this library. If you would like to contribute, please fork the repository, create a new branch, and submit a pull request.

Contact us

If you have any question or suggestion, please feel free to contact us by raising an issue or sending an email to glory947446@gmail.com.

License

LibLLIE is licensed under the MIT License. See the LICENSE file for more details.

About

A Python library for Low-Light Image Enhancement

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages