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.
Installation
Run the following to install:
pip install imWeightedThresholdedheq
Usage
For images
imWeightedThresholdedheq --input 'Plane.jpg' --output 'Plane-imWeightedThresholdedheq.jpg'
For videos
vid2dhisteq --input 'assets/Arctic-Convoy-With-Giant-Mack-Trucks.mp4' --output 'assets/Arctic-Convoy-With-Giant-Mack-Trucks-imWeightedThresholdedheq.mp4'
Or
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
Metadata
Release files for imWeightedThresholdedheq 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| imWeightedThresholdedheq-1.0.2.tar.gz | 223.8 kB | Without provenance | Details for imWeightedThresholdedheq-1.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| imWeightedThresholdedheq-1.0.2-py3-none-any.whl | Python 3 | none | any | Details for imWeightedThresholdedheq-1.0.2-py3-none-any.whl |
Total release size: 241.7 kB
Release files / imWeightedThresholdedheq-1.0.2.tar.gz
| Download URL | imWeightedThresholdedheq-1.0.2.tar.gz |
|---|---|
| Size | 223.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d80e2f599660609177cabde779ce4ab3ad0f25c8e17fe3ffcf8af11a9c1c25e5
|
|
BLAKE2b-256 checksum How to use checksums |
1f39d7437021eafab3353e682cc26332c1c1090002876fc0d0b263f7fcf416b1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.7
|
Release files / imWeightedThresholdedheq-1.0.2-py3-none-any.whl
| Download URL | imWeightedThresholdedheq-1.0.2-py3-none-any.whl |
|---|---|
| Size | 17.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
46382bd51bb2afd5a17f07deaa9265110137dc92b7052d56a681325422d65345
|
|
BLAKE2b-256 checksum How to use checksums |
23dd3c21ecaaccd7d9651c063c80c832423a045cb22b83f56ac1ab1a817606b3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.7
|
Security for imWeightedThresholdedheq 1.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.