Giter Site home page Giter Site logo

mamdasn / imhblpce Goto Github PK

View Code? Open in Web Editor NEW
5.0 1.0 0.0 7.47 MB

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

Home Page: https://pypi.org/project/imhblpce/

License: GNU General Public License v3.0

Python 100.00%
histogram histogram-equalization contrast-enhancement hblpce imhblpce histogram-locality-preserving

imhblpce's Introduction

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

imhblpce's People

Contributors

mamdasn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.