Skip to main content

PyPI Latest Release Package Status Downloads License Repository Size

imhblpce

This module attempts to enhance contrast of a given image by employing a method called HBLPCE [Histogram-Based Locality-Preserving Contrast Enhancement]. This method enhances contrast of an image through equalizing its histogram, while keeping an eye on histogram's general shape, to conserve overall brightness and prevent excessive enhancement of the image.

You can access the article that came up with this method here.

Through formulating their approach, a minimization problem is introduced and solved using cvxpy library in python.

Installation

Run the following to install:

pip install imhblpce

Usage

import numpy as np
import cv2
from imhblpce import imhblpce

def imresize(img, wr=500, hr=None): # This is just for imshow-ing images with titles
    [ h, w, d] = img.shape
    hr = (h*wr)//w if not hr else hr
    img_resized = cv2.resize(img, dsize=(wr, hr))
    return img_resized

def main():
    image_name = 'assets/Countryside.jpg'
    image = cv2.imread(image_name)

    # converts rgb image to hsv
    hsv_image = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)
    v_image = hsv_image[:, :, 2]
    v_image_hblpce = imhblpce(v_image)
    
    hsv_image_hblpce = hsv_image.copy()
    hsv_image_hblpce[:, :, 2] = v_image_hblpce
    image_hblpce = cv2.cvtColor(hsv_image_hblpce, cv2.COLOR_HSV2BGR)

    # This is just for imshow-ing images with titles

    cv2.imshow('Original Image', imresize(image))
    cv2.imshow('HBLPCE-d Image', imresize(image_hblpce))
    cv2.waitKey(0)
    
if __name__ == '__main__': main()

Or

imhblpce --input 'Countryside.jpg' --output 'Countryside-imhblpce.jpg'

Showcase

This is a sample image Countryside.jpg Image The sample image enhanced by HBLPCE method Countryside-imhblpce.jpg Image

Metadata

Release files for imhblpce 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for imhblpce 1.0.0
File Size Uploaded
imhblpce-1.0.0.tar.gz 3.7 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for imhblpce 1.0.0
File Interpreter ABI Platform
imhblpce-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 3.7 MB

Release files / imhblpce-1.0.0.tar.gz

Download URL imhblpce-1.0.0.tar.gz
Size 3.7 MB
Tags Source
SHA-256 checksum
How to use checksums
5c895750b11563635e1d67e4a0b320c079416168050296be8b77f04c6afe3db1
BLAKE2b-256 checksum
How to use checksums
159aa81700f4664004d8a8b75e76a85174aa706c31a35a734965ef1c3164b558
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release files / imhblpce-1.0.0-py3-none-any.whl

Download URL imhblpce-1.0.0-py3-none-any.whl
Size 16.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c4144520a9669199f65c68c530fd9c403220c44228dac3a2da4fc614d5451df4
BLAKE2b-256 checksum
How to use checksums
0f399d670945fcc4b9bb6f94b57bc73a2dfa00241cd2d4fa0224d6c838a7c3f1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page