Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ruhyadi/image-enchancement
Image Enchancement with OpenCV and GAN
https://github.com/ruhyadi/image-enchancement
gan image-enhancement opencv
Last synced: about 10 hours ago
JSON representation
Image Enchancement with OpenCV and GAN
- Host: GitHub
- URL: https://github.com/ruhyadi/image-enchancement
- Owner: ruhyadi
- License: apache-2.0
- Created: 2022-07-02T11:26:46.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-07-06T12:33:19.000Z (over 2 years ago)
- Last Synced: 2024-11-08T20:51:06.148Z (about 2 months ago)
- Topics: gan, image-enhancement, opencv
- Language: Python
- Homepage:
- Size: 4.81 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## ⚠️ Cautions
> This repository currently under development## 📼 Demo
![demo](assets/demo.gif)
## 📌 Introduction
This repository is used for assessment purposes in the image enhancement task. There are two types of enhancements used:
- Enhancement using OpenCV Python
- Enhancement using GAN (Generative Adversarial Network) and OpenCV Python## 🚀 Quickstart
> In using this repository, it is recommended to use a virtual environment (**Anaconda**).### 💎 Installation
> The steps will install the required dependencies1. Clone repository
```bash
git clone https://github.com/ruhyadi/assessment-image-enchancment
```
2. Install requirements inside Virtual Env (details in [miniconda](https://docs.conda.io/en/latest/miniconda.html))
```bash
cd assessment-image-enchancment
pip install -r requirements.txt
```
3. Install **BasicSR**
```bash
cd BasicSR
python setup.py develop
```
4. Download ESRGAN Pretrained Model
```bash
python scripts/download_pretrained_models.py ESRGAN
```### 🍿 Inference
#### 🥊 Enchancement with OpenCV
I have provided a GUI application that can be used for this purpose. The application can be accessed by:
```bash
streamlit run app.py
```
In the application you can input **the input image** and **the ground-truth image**. The application will process the image into an intermediate image and an output image. Inside the application there are sliders and buttons that can be combined to produce the best enhancement results.
For details see the demo section.The enhancement function can also be accessed via `enhancement.py`scripts:
```bash
python enhancement.py \
--img_path /assets/input.png \
--inter_path /assets/intermediate.png \
--output_path /assets/results.png \
--alpha 1.5 \
--beta -0.5 \
--ksize 11 \
--threshold 170 \
--clahe \
--clahe_cliplimit 2.0 \
--equalizer
```
with the help:
```bash
usage: enhancement.py [-h] [--img_path IMG_PATH] [--inter_path INTER_PATH] [--output_path OUTPUT_PATH] [--equalizer] [--clahe]
[--clahe_cliplimit CLAHE_CLIPLIMIT] [--alpha ALPHA] [--beta BETA] [--ksize KSIZE] [--threshold THRESHOLD]Image enhancement
optional arguments:
-h, --help show this help message and exit
--img_path IMG_PATH Path to image
--inter_path INTER_PATH
Path to intermediate image
--output_path OUTPUT_PATH
Path to output image
--equalizer Equalize histogram
--clahe CLAHE
--clahe_cliplimit CLAHE_CLIPLIMIT
CLAHE clip limit
--alpha ALPHA Alpha
--beta BETA Beta
--ksize KSIZE Ksize
--threshold THRESHOLD
Threshold
```#### 🎯 Generative Adversarial Network (GAN)
Enhancement can also use GAN. The GAN function here **does not directly** get the thresholding of the image, but as an intermediate for upscaling the image first. The GAN command can be executed with:```bash
python BasicSR/inference/inference_esrgan.py \
--model_path BasicSR/experiments/pretrained_models/ESRGAN/ESRGAN_SRx4_DF2KOST_official-ff704c30.pth \
--input assets
```The results of upscaling the image using GAN can be seen in the table below:
|Input Image|GAN Results|
|:--:|:--:|
|![head](assets/head.png)|![head-gan](assets/head_ESRGAN.png)|
|![before](assets/input.png)|![output](assets/001_ESRGAN.png)|The results of the GAN look not very effective for the image in the second row, this is because the GAN is very dependent on the image data being trained, maybe the training data itself does not have the same image as the second row.
## ❤️ Acknowledgement
- [OpenCV](https://github.com/opencv/opencv)
- [BasicSR](https://github.com/XPixelGroup/BasicSR)
```
@misc{wang2020basicsr,
author = {Xintao Wang and Ke Yu and Kelvin C.K. Chan and
Chao Dong and Chen Change Loy},
title = {{BasicSR}: Open Source Image and Video Restoration Toolbox},
howpublished = {\url{https://github.com/xinntao/BasicSR}},
year = {2018}
}
```