imWeightedThresholdedheq


NameimWeightedThresholdedheq JSON
Version 1.0.2 PyPI version JSON
download
home_pagehttps://github.com/Mamdasn/imWeightedThresholdedheq
SummaryThis module attempts to enhance contrast of a given image by employing a method called weighted thresholded histogram equalization (WTHE).
upload_time2023-12-26 16:28:30
maintainer
docs_urlNone
authormamdasn s
requires_python
license
keywords python histogram he hist equalization histogram based equalization weighted thresholded histogram equalization contrast enhancement
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
[![PyPI Latest Release](https://img.shields.io/pypi/v/imWeightedThresholdedheq.svg)](https://pypi.org/project/imWeightedThresholdedheq/)
[![Package Status](https://img.shields.io/pypi/status/imWeightedThresholdedheq.svg)](https://pypi.org/project/imWeightedThresholdedheq/)
[![Downloads](https://pepy.tech/badge/imWeightedThresholdedheq)](https://pepy.tech/project/imWeightedThresholdedheq)
[![License](https://img.shields.io/pypi/l/imWeightedThresholdedheq.svg)](https://github.com/Mamdasn/imWeightedThresholdedheq/blob/main/LICENSE)
![Repository Size](https://img.shields.io/github/languages/code-size/mamdasn/imWeightedThresholdedheq)


# imWeightedThresholdedheq
This module attempts to enhance contrast of a given image or video by employing a method called weighted thresholded histogram equalization (WTHE). This method seeks to improve on preformance of the conventional histogram equalization method by adding controllable parameters to it. By weighting and thresholding the PMF of the image before performing histogram equalization, two parameters are introduced that can be changed manually, but by experimenting on a variety of images, optimal values for both parameters are calculated (r = 0.5, v = 0.5).

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


## Installation

Run the following to install:

```python
pip install imWeightedThresholdedheq
```

## Usage

For images
```Bash
imWeightedThresholdedheq --input 'Plane.jpg' --output 'Plane-imWeightedThresholdedheq.jpg'
```
For videos
```Bash
vid2dhisteq --input 'assets/Arctic-Convoy-With-Giant-Mack-Trucks.mp4' --output 'assets/Arctic-Convoy-With-Giant-Mack-Trucks-imWeightedThresholdedheq.mp4'
```
Or
```Python
import numpy as np
import cv2
from imWeightedThresholdedheq import imWTHeq

cap = cv2.VideoCapture('assets/Arctic-Convoy-With-Giant-Mack-Trucks.mp4')

# output video without sound
video_out_name = 'assets/Arctic-Convoy-With-Giant-Mack-Trucks-imWeightedThresholdedheq.mp4'
i = 0
j = 0
Wout_list = np.zeros((10))
while(cap.isOpened()):
    ret, frame = cap.read()
    if ret == False:
        break
    frame_hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
    frame_v   = frame_hsv[:, :, 2].copy()
    image_heq, Wout = imWTHeq(frame_v, Wout_list, r=0.5, v=0.5)
    Wout_list[j] = Wout
    j += 1
    if j == 10:
        j = 0
    frame_hsv[:, :, 2] = image_heq
    frame_eq = cv2.cvtColor(frame_hsv, cv2.COLOR_HSV2BGR)

    fps = cap.get(cv2.CAP_PROP_FPS)
    if i==0:
        h, w, d = frame_eq.shape
        fourcc = cv2.VideoWriter_fourcc(*'mp4v')
        video_out = cv2.VideoWriter(video_out_name, fourcc, fps, (w, h))
    video_out.write(frame_eq)

    i+=1
cv2.destroyAllWindows()
video_out.release()
```


## Showcase
* A 5 minutes comparative video: https://youtu.be/5H_EY_ugmzg
* A sample video and its enhanced version by WTHE method
[![Arctic-Convoy-With-Giant-Mack-Trucks-Orig-Heq.gif GIF](https://raw.githubusercontent.com/Mamdasn/imWeightedThresholdedheq/main/assets/Arctic-Convoy-With-Giant-Mack-Trucks-Orig-Heq.gif "Arctic-Convoy-With-Giant-Mack-Trucks-Orig-Heq.gif GIF")](https://youtu.be/5H_EY_ugmzg)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Mamdasn/imWeightedThresholdedheq",
    "name": "imWeightedThresholdedheq",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "python,histogram,HE,hist equalization,histogram based equalization,weighted thresholded histogram equalization,contrast enhancement",
    "author": "mamdasn s",
    "author_email": "<mamdassn@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/1f/39/d7437021eafab3353e682cc26332c1c1090002876fc0d0b263f7fcf416b1/imWeightedThresholdedheq-1.0.2.tar.gz",
    "platform": null,
    "description": "\n[![PyPI Latest Release](https://img.shields.io/pypi/v/imWeightedThresholdedheq.svg)](https://pypi.org/project/imWeightedThresholdedheq/)\n[![Package Status](https://img.shields.io/pypi/status/imWeightedThresholdedheq.svg)](https://pypi.org/project/imWeightedThresholdedheq/)\n[![Downloads](https://pepy.tech/badge/imWeightedThresholdedheq)](https://pepy.tech/project/imWeightedThresholdedheq)\n[![License](https://img.shields.io/pypi/l/imWeightedThresholdedheq.svg)](https://github.com/Mamdasn/imWeightedThresholdedheq/blob/main/LICENSE)\n![Repository Size](https://img.shields.io/github/languages/code-size/mamdasn/imWeightedThresholdedheq)\n\n\n# imWeightedThresholdedheq\nThis module attempts to enhance contrast of a given image or video by employing a method called weighted thresholded histogram equalization (WTHE). This method seeks to improve on preformance of the conventional histogram equalization method by adding controllable parameters to it. By weighting and thresholding the PMF of the image before performing histogram equalization, two parameters are introduced that can be changed manually, but by experimenting on a variety of images, optimal values for both parameters are calculated (r = 0.5, v = 0.5).\n\nYou can access the article that came up with this method [here](https://www.researchgate.net/publication/3183125_Ward_RK_Fast_ImageVideo_Contrast_Enhancement_Based_on_Weighted_Thresholded_Histogram_Equalization_IEEE_Trans_Consumer_Electronics_532_757-764).\n\n\n## Installation\n\nRun the following to install:\n\n```python\npip install imWeightedThresholdedheq\n```\n\n## Usage\n\nFor images\n```Bash\nimWeightedThresholdedheq --input 'Plane.jpg' --output 'Plane-imWeightedThresholdedheq.jpg'\n```\nFor videos\n```Bash\nvid2dhisteq --input 'assets/Arctic-Convoy-With-Giant-Mack-Trucks.mp4' --output 'assets/Arctic-Convoy-With-Giant-Mack-Trucks-imWeightedThresholdedheq.mp4'\n```\nOr\n```Python\nimport numpy as np\nimport cv2\nfrom imWeightedThresholdedheq import imWTHeq\n\ncap = cv2.VideoCapture('assets/Arctic-Convoy-With-Giant-Mack-Trucks.mp4')\n\n# output video without sound\nvideo_out_name = 'assets/Arctic-Convoy-With-Giant-Mack-Trucks-imWeightedThresholdedheq.mp4'\ni = 0\nj = 0\nWout_list = np.zeros((10))\nwhile(cap.isOpened()):\n    ret, frame = cap.read()\n    if ret == False:\n        break\n    frame_hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)\n    frame_v   = frame_hsv[:, :, 2].copy()\n    image_heq, Wout = imWTHeq(frame_v, Wout_list, r=0.5, v=0.5)\n    Wout_list[j] = Wout\n    j += 1\n    if j == 10:\n        j = 0\n    frame_hsv[:, :, 2] = image_heq\n    frame_eq = cv2.cvtColor(frame_hsv, cv2.COLOR_HSV2BGR)\n\n    fps = cap.get(cv2.CAP_PROP_FPS)\n    if i==0:\n        h, w, d = frame_eq.shape\n        fourcc = cv2.VideoWriter_fourcc(*'mp4v')\n        video_out = cv2.VideoWriter(video_out_name, fourcc, fps, (w, h))\n    video_out.write(frame_eq)\n\n    i+=1\ncv2.destroyAllWindows()\nvideo_out.release()\n```\n\n\n## Showcase\n* A 5 minutes comparative video: https://youtu.be/5H_EY_ugmzg\n* A sample video and its enhanced version by WTHE method\n[![Arctic-Convoy-With-Giant-Mack-Trucks-Orig-Heq.gif GIF](https://raw.githubusercontent.com/Mamdasn/imWeightedThresholdedheq/main/assets/Arctic-Convoy-With-Giant-Mack-Trucks-Orig-Heq.gif \"Arctic-Convoy-With-Giant-Mack-Trucks-Orig-Heq.gif GIF\")](https://youtu.be/5H_EY_ugmzg)\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "This module attempts to enhance contrast of a given image by employing a method called weighted thresholded histogram equalization (WTHE).",
    "version": "1.0.2",
    "project_urls": {
        "Homepage": "https://github.com/Mamdasn/imWeightedThresholdedheq"
    },
    "split_keywords": [
        "python",
        "histogram",
        "he",
        "hist equalization",
        "histogram based equalization",
        "weighted thresholded histogram equalization",
        "contrast enhancement"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "23dd3c21ecaaccd7d9651c063c80c832423a045cb22b83f56ac1ab1a817606b3",
                "md5": "39da86be9642b47f4c9cbafa7f6c662e",
                "sha256": "46382bd51bb2afd5a17f07deaa9265110137dc92b7052d56a681325422d65345"
            },
            "downloads": -1,
            "filename": "imWeightedThresholdedheq-1.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "39da86be9642b47f4c9cbafa7f6c662e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 17877,
            "upload_time": "2023-12-26T16:28:28",
            "upload_time_iso_8601": "2023-12-26T16:28:28.812052Z",
            "url": "https://files.pythonhosted.org/packages/23/dd/3c21ecaaccd7d9651c063c80c832423a045cb22b83f56ac1ab1a817606b3/imWeightedThresholdedheq-1.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1f39d7437021eafab3353e682cc26332c1c1090002876fc0d0b263f7fcf416b1",
                "md5": "1e396496e9c7b42145ae08d0b046af4c",
                "sha256": "d80e2f599660609177cabde779ce4ab3ad0f25c8e17fe3ffcf8af11a9c1c25e5"
            },
            "downloads": -1,
            "filename": "imWeightedThresholdedheq-1.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "1e396496e9c7b42145ae08d0b046af4c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 223811,
            "upload_time": "2023-12-26T16:28:30",
            "upload_time_iso_8601": "2023-12-26T16:28:30.563831Z",
            "url": "https://files.pythonhosted.org/packages/1f/39/d7437021eafab3353e682cc26332c1c1090002876fc0d0b263f7fcf416b1/imWeightedThresholdedheq-1.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-26 16:28:30",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Mamdasn",
    "github_project": "imWeightedThresholdedheq",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "imweightedthresholdedheq"
}
        
Elapsed time: 0.22631s