https://github.com/mamdasn/im2dhisteq
This module attempts to enhance contrast of a given image by equalizing its two dimensional histogram.
https://github.com/mamdasn/im2dhisteq
2dhist contrast-enhancement hist2d histogram histogram-equalization im2dhisteq image-contrast-enhancement image-processing imhist python two-dimensional-histogram
Last synced: 4 months ago
JSON representation
This module attempts to enhance contrast of a given image by equalizing its two dimensional histogram.
- Host: GitHub
- URL: https://github.com/mamdasn/im2dhisteq
- Owner: Mamdasn
- License: gpl-3.0
- Created: 2021-04-05T07:44:48.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2024-03-11T15:27:51.000Z (about 2 years ago)
- Last Synced: 2025-09-19T16:48:26.946Z (7 months ago)
- Topics: 2dhist, contrast-enhancement, hist2d, histogram, histogram-equalization, im2dhisteq, image-contrast-enhancement, image-processing, imhist, python, two-dimensional-histogram
- Language: Python
- Homepage: https://pypi.org/project/im2dhisteq/
- Size: 33.2 MB
- Stars: 27
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://pypi.org/project/im2dhisteq/) [](https://pypi.org/project/im2dhisteq/) [](https://pepy.tech/project/im2dhisteq) [](https://github.com/Mamdasn/im2dhisteq/blob/main/LICENSE) 
# 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
For images
```Bash
im2dhisteq --input 'cloudy-day.jpg' --output 'assets/cloudy-day-2dhisteq.jpg' --w 6
```
For videos
```Bash
vid2dhisteq --input 'video-input.mp4' --output 'video-output-enhanced.mp4' --w 6
```
### Speed up
The speed of the program can be significantly increased if the go library `lib-im2dhist.go` in src/go_libs in the package is compiled and moved to a dir in the system path.
To compile, first make sure `go` is installed on your system. Then run
```Bash
go mod init lib-im2dhist.go
go mod tidy
```
followed by running the script `make-library`.
#### Download binary
Instead of compiling the go library `lib-im2dhist.go`, you can download the library based on your system configuration:
* [lib-im2dhist-linux-amd64.so](https://github.com/Mamdasn/im2dhisteq/releases/download/v1.1.0/lib-im2dhist-linux-amd64.so)
* [lib-im2dhist-linux-386.so](https://github.com/Mamdasn/im2dhisteq/releases/download/v1.1.0/lib-im2dhist-linux-386.so)
* [lib-im2dhist-darwin-amd64.dylib](https://github.com/Mamdasn/im2dhisteq/releases/download/v1.1.0/lib-im2dhist-darwin-amd64.dylib)
* [lib-im2dhist-darwin-arm64.dylib](https://github.com/Mamdasn/im2dhisteq/releases/download/v1.1.0/lib-im2dhist-darwin-arm64.dylib)
## Showcase
* A one minute comparative video: https://youtu.be/7LrzX2ZpLAQ
* This is a sample image and its corresponding 2d-histogram equalized image.
