im2dhisteq


Nameim2dhisteq JSON
Version 0.0.10 PyPI version JSON
download
home_pagehttps://github.com/Mamdasn/im2dhisteq
SummaryThis module attempts to enhance contrast of a given image by equalizing its two dimensional histogram.
upload_time2021-05-03 23:06:42
maintainer
docs_urlNone
authormamdasn s
requires_python
license
keywords python histogram imhist 2dhist hist2d im2dhisteq histogram equalization two dimensional histogram
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# im2dhisteq
This module attempts to enhance contrast of a given image by equalizing its two dimensional histogram. An easy way to enhance quality of a given image is to just equalize its histogram, but despite using minimum resources and a very short process time, there are a lot of drawbacks to it.
One of the ways to tackle drawbacks of `histogram equalization method` is to instead equalize the image's `two dimensional histogram`, as one dimensional histogram of a given image does not contain the image's contextual information. Tests on a multitude of images has shown, by taking contextual information of an image in addition to the image's histogram into account when attempting to enhance contrast, output images are significantly better in quality in compare to histogram equalizaion and a handful of other known methods.  

You can access the article that came up with this method [here](https://www.researchgate.net/publication/256822485_Two-dimensional_histogram_equalization_and_contrast_enhancement).

## Two Dimensional Histogram 
[Here](https://github.com/Mamdasn/im2dhist) is the source code for the im2dhist python library with a short description on how it's done. 

## Installation

Run the following to install:

```python
pip install im2dhisteq
```

## Usage

```python
import numpy as np
import cv2
from im2dhisteq import im2dhisteq

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

def main():
    fullname = 'cloudy-day.jpg'
    image = cv2.imread(fullname)
    gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)

    # w_neighboring=6 is generally an adequate value, drived by a lot of experimenting.
    # w_neighboring=6 corresponds to a 13*13 square
    gray_image_2DHisteq = im2dhisteq(gray_image, w_neighboring=6)

    # This is just for imshow-ing images with titles
    gray_Image_resized = imresize(gray_image)
    gray_Image_2DHisteq_resized = imresize(gray_image_2DHisteq)

    cv2.imshow('Original Image', gray_Image_resized)
    cv2.imshow('2DHeq Image', gray_Image_2DHisteq_resized)
    cv2.waitKey(0)

if __name__ == '__main__': main()
```

## Showcase
* A one minute comparative video: https://youtu.be/tX1KbJ2ugdE
* This is a sample image and its corresponding 2d-histogram equalized image.  
![cloudy-day-original-im2dhisteq.jpg Image](https://raw.githubusercontent.com/Mamdasn/im2dhisteq/main/assets/cloudy-day-original-im2dhisteq.jpg "cloudy-day-original-im2dhisteq.jpg Image")




            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Mamdasn/im2dhisteq",
    "name": "im2dhisteq",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "python,histogram,imhist,2dhist,hist2d,im2dhisteq,histogram equalization,two dimensional histogram",
    "author": "mamdasn s",
    "author_email": "<mamdassn@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/e8/15/02eaed46bb7c628267801c4f791fc463e645fb267e4bc7e3e164af1ef230/im2dhisteq-0.0.10.tar.gz",
    "platform": "",
    "description": "\n# im2dhisteq\nThis module attempts to enhance contrast of a given image by equalizing its two dimensional histogram. An easy way to enhance quality of a given image is to just equalize its histogram, but despite using minimum resources and a very short process time, there are a lot of drawbacks to it.\nOne of the ways to tackle drawbacks of `histogram equalization method` is to instead equalize the image's `two dimensional histogram`, as one dimensional histogram of a given image does not contain the image's contextual information. Tests on a multitude of images has shown, by taking contextual information of an image in addition to the image's histogram into account when attempting to enhance contrast, output images are significantly better in quality in compare to histogram equalizaion and a handful of other known methods.  \n\nYou can access the article that came up with this method [here](https://www.researchgate.net/publication/256822485_Two-dimensional_histogram_equalization_and_contrast_enhancement).\n\n## Two Dimensional Histogram \n[Here](https://github.com/Mamdasn/im2dhist) is the source code for the im2dhist python library with a short description on how it's done. \n\n## Installation\n\nRun the following to install:\n\n```python\npip install im2dhisteq\n```\n\n## Usage\n\n```python\nimport numpy as np\nimport cv2\nfrom im2dhisteq import im2dhisteq\n\ndef imresize(img, wr=500, hr=None): # This is just for imshow-ing images with titles\n    [ h, w] = 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    fullname = 'cloudy-day.jpg'\n    image = cv2.imread(fullname)\n    gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)\n\n    # w_neighboring=6 is generally an adequate value, drived by a lot of experimenting.\n    # w_neighboring=6 corresponds to a 13*13 square\n    gray_image_2DHisteq = im2dhisteq(gray_image, w_neighboring=6)\n\n    # This is just for imshow-ing images with titles\n    gray_Image_resized = imresize(gray_image)\n    gray_Image_2DHisteq_resized = imresize(gray_image_2DHisteq)\n\n    cv2.imshow('Original Image', gray_Image_resized)\n    cv2.imshow('2DHeq Image', gray_Image_2DHisteq_resized)\n    cv2.waitKey(0)\n\nif __name__ == '__main__': main()\n```\n\n## Showcase\n* A one minute comparative video: https://youtu.be/tX1KbJ2ugdE\n* This is a sample image and its corresponding 2d-histogram equalized image.  \n![cloudy-day-original-im2dhisteq.jpg Image](https://raw.githubusercontent.com/Mamdasn/im2dhisteq/main/assets/cloudy-day-original-im2dhisteq.jpg \"cloudy-day-original-im2dhisteq.jpg Image\")\n\n\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "This module attempts to enhance contrast of a given image by equalizing its two dimensional histogram.",
    "version": "0.0.10",
    "split_keywords": [
        "python",
        "histogram",
        "imhist",
        "2dhist",
        "hist2d",
        "im2dhisteq",
        "histogram equalization",
        "two dimensional histogram"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "752cf007ffbe994a475539eb4ddb4bf0",
                "sha256": "2e2ee0a4abeaecd3999a962a982b94f4f6cb37505b660f0ed7ee0965eaf7ddb6"
            },
            "downloads": -1,
            "filename": "im2dhisteq-0.0.10-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "752cf007ffbe994a475539eb4ddb4bf0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 4059,
            "upload_time": "2021-05-03T23:06:28",
            "upload_time_iso_8601": "2021-05-03T23:06:28.054825Z",
            "url": "https://files.pythonhosted.org/packages/1b/82/f2560a81dd55b89b8a9e917cd00679d1a1b19e3b7db6c4c466b5b331f75e/im2dhisteq-0.0.10-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "d2377187c68cd2047175c5058a9c0949",
                "sha256": "ad47281a087aec9627723aa916a8f5f1641bf5883a175aeca64ae3df05cfa0c4"
            },
            "downloads": -1,
            "filename": "im2dhisteq-0.0.10.tar.gz",
            "has_sig": false,
            "md5_digest": "d2377187c68cd2047175c5058a9c0949",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 946169,
            "upload_time": "2021-05-03T23:06:42",
            "upload_time_iso_8601": "2021-05-03T23:06:42.470025Z",
            "url": "https://files.pythonhosted.org/packages/e8/15/02eaed46bb7c628267801c4f791fc463e645fb267e4bc7e3e164af1ef230/im2dhisteq-0.0.10.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2021-05-03 23:06:42",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": null,
    "github_project": "Mamdasn",
    "error": "Could not fetch GitHub repository",
    "lcname": "im2dhisteq"
}
        
Elapsed time: 0.29274s