Skip to main content

This module attempts to enhance contrast of a given image by employing a method called weighted thresholded histogram equalization (WTHE).

Project description

PyPI Latest Release Package Status Downloads License Repository Size

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

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()

Or

imWeightedThresholdedheq --input 'Plane.jpg' --output 'Plane-imWeightedThresholdedheq.jpg'

Showcase

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

imWeightedThresholdedheq-1.0.0.tar.gz (222.9 kB view details)

Uploaded Source

Built Distribution

imWeightedThresholdedheq-1.0.0-py3-none-any.whl (16.5 kB view details)

Uploaded Python 3

File details

Details for the file imWeightedThresholdedheq-1.0.0.tar.gz.

File metadata

File hashes

Hashes for imWeightedThresholdedheq-1.0.0.tar.gz
Algorithm Hash digest
SHA256 dc651b89c0e2335a17d051e8bb778b8cf7f0cd0c6b684b6d1d36d1d5c6f45f9d
MD5 b20134df60005061f81fdb00867b4e5e
BLAKE2b-256 195de11ecf8884f8893c727551cacba615f0b44e24090bf41e79406a34c176c7

See more details on using hashes here.

File details

Details for the file imWeightedThresholdedheq-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for imWeightedThresholdedheq-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fa9295c869c2eb3dd276bdd6d42eaebf5c84fd258a8c671feec872cbb7f7ad67
MD5 8a28eca4dd9d2f4df30410e0264942a9
BLAKE2b-256 2231533b75d96d1806920c6888a9b932d5737744ea6fdc67ffe6876781251882

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page