Skip to main content

This module attempts to enhance contrast of a given image by employing a method called HBLPCE.

Project description

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()

Showcase

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

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

imhblpce-0.0.5.tar.gz (3.7 MB view details)

Uploaded Source

Built Distribution

imhblpce-0.0.5-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file imhblpce-0.0.5.tar.gz.

File metadata

  • Download URL: imhblpce-0.0.5.tar.gz
  • Upload date:
  • Size: 3.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.2

File hashes

Hashes for imhblpce-0.0.5.tar.gz
Algorithm Hash digest
SHA256 a9a1542ff382b2a7a00301c017d2891f28038d98be509747b98c6b5d02ffcb91
MD5 9def97b82770573c873fd1ac077142aa
BLAKE2b-256 aea7559c1d867d392af6ad81aa93068e4613d9ddbc25d75c365b0232d06b69ea

See more details on using hashes here.

File details

Details for the file imhblpce-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: imhblpce-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.2

File hashes

Hashes for imhblpce-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 e83296141c5f0de29f34436c04f2925bad9007b1d7e4e174eb9845013aa44ea5
MD5 090c31dbf42f1c9d1fdb13ecfba7edee
BLAKE2b-256 4e12265b80d9372e06b99d0a06aad25ddac357864602cab2d5f0f1d5001ae62e

See more details on using hashes here.

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