imhblpce


Nameimhblpce JSON
Version 0.0.5 PyPI version JSON
download
home_pagehttps://github.com/Mamdasn/imhblpce
SummaryThis module attempts to enhance contrast of a given image by employing a method called HBLPCE.
upload_time2021-05-01 22:48:39
maintainer
docs_urlNone
authormamdasn s
requires_python
license
keywords python histogram imhblpce hblpce histogram equalization histogram based equalization histogram locality preserving contrast enhancement
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# 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](https://www.researchgate.net/publication/272424815_Histogram-Based_Locality-Preserving_Contrast_Enhancement).  

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

## Installation

Run the following to install:

```python
pip install imhblpce
```

## Usage

```python
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](https://raw.githubusercontent.com/Mamdasn/imhblpce/main/assets/Countryside.jpg "Countryside.jpg Image")
The sample image enhanced by HBLPCE method
![Countryside-imhblpce.jpg Image](https://raw.githubusercontent.com/Mamdasn/imhblpce/main/assets/Countryside-imhblpce.jpg "Countryside-imhblpce.jpg")



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Mamdasn/imhblpce",
    "name": "imhblpce",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "python,histogram,imhblpce,hblpce,histogram equalization,histogram based equalization,histogram locality preserving,contrast enhancement",
    "author": "mamdasn s",
    "author_email": "<mamdassn@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/ae/a7/559c1d867d392af6ad81aa93068e4613d9ddbc25d75c365b0232d06b69ea/imhblpce-0.0.5.tar.gz",
    "platform": "",
    "description": "\n# imhblpce\nThis 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.  \n\nYou can access the article that came up with this method [here](https://www.researchgate.net/publication/272424815_Histogram-Based_Locality-Preserving_Contrast_Enhancement).  \n\nThrough formulating their approach, a minimization problem is introduced and solved using cvxpy library in python.\n\n## Installation\n\nRun the following to install:\n\n```python\npip install imhblpce\n```\n\n## Usage\n\n```python\nimport numpy as np\nimport cv2\nfrom imhblpce import imhblpce\n\ndef imresize(img, wr=500, hr=None): # This is just for imshow-ing images with titles\n    [ h, w, d] = img.shape\n    hr = (h*wr)//w if not hr else hr\n    img_resized = cv2.resize(img, dsize=(wr, hr))\n    return img_resized\n\ndef main():\n    image_name = 'assets/Countryside.jpg'\n    image = cv2.imread(image_name)\n\n    # converts rgb image to hsv\n    hsv_image = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)\n    v_image = hsv_image[:, :, 2]\n    v_image_hblpce = imhblpce(v_image)\n\n    hsv_image_hblpce = hsv_image.copy()\n    hsv_image_hblpce[:, :, 2] = v_image_hblpce\n    image_hblpce = cv2.cvtColor(hsv_image_hblpce, cv2.COLOR_HSV2BGR)\n\n    # This is just for imshow-ing images with titles\n\n    cv2.imshow('Original Image', imresize(image))\n    cv2.imshow('HBLPCE-d Image', imresize(image_hblpce))\n    cv2.waitKey(0)\n\nif __name__ == '__main__': main()\n```\n\n## Showcase\nThis is a sample image\n![Countryside.jpg Image](https://raw.githubusercontent.com/Mamdasn/imhblpce/main/assets/Countryside.jpg \"Countryside.jpg Image\")\nThe sample image enhanced by HBLPCE method\n![Countryside-imhblpce.jpg Image](https://raw.githubusercontent.com/Mamdasn/imhblpce/main/assets/Countryside-imhblpce.jpg \"Countryside-imhblpce.jpg\")\n\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "This module attempts to enhance contrast of a given image by employing a method called HBLPCE.",
    "version": "0.0.5",
    "split_keywords": [
        "python",
        "histogram",
        "imhblpce",
        "hblpce",
        "histogram equalization",
        "histogram based equalization",
        "histogram locality preserving",
        "contrast enhancement"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "090c31dbf42f1c9d1fdb13ecfba7edee",
                "sha256": "e83296141c5f0de29f34436c04f2925bad9007b1d7e4e174eb9845013aa44ea5"
            },
            "downloads": -1,
            "filename": "imhblpce-0.0.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "090c31dbf42f1c9d1fdb13ecfba7edee",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 4389,
            "upload_time": "2021-05-01T22:47:39",
            "upload_time_iso_8601": "2021-05-01T22:47:39.634224Z",
            "url": "https://files.pythonhosted.org/packages/4e/12/265b80d9372e06b99d0a06aad25ddac357864602cab2d5f0f1d5001ae62e/imhblpce-0.0.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "9def97b82770573c873fd1ac077142aa",
                "sha256": "a9a1542ff382b2a7a00301c017d2891f28038d98be509747b98c6b5d02ffcb91"
            },
            "downloads": -1,
            "filename": "imhblpce-0.0.5.tar.gz",
            "has_sig": false,
            "md5_digest": "9def97b82770573c873fd1ac077142aa",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 3678470,
            "upload_time": "2021-05-01T22:48:39",
            "upload_time_iso_8601": "2021-05-01T22:48:39.476142Z",
            "url": "https://files.pythonhosted.org/packages/ae/a7/559c1d867d392af6ad81aa93068e4613d9ddbc25d75c365b0232d06b69ea/imhblpce-0.0.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2021-05-01 22:48:39",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": null,
    "github_project": "Mamdasn",
    "error": "Could not fetch GitHub repository",
    "lcname": "imhblpce"
}
        
Elapsed time: 0.22919s