# Revisit of JPEG decompression with artifact suppression by total variation and its variants


This code implements the JPEG decompression with three variants of regularization, namely classical total variation, adapted TV, and Dirichlet integral, for artifact suppression.

## Installation

Create python 3.10 environment and install dependencies:

```bash
conda create -n jpeg_tv python=3.10
conda activate jpeg_tv
pip install -r requirements.txt
```

## Usage

Run the main script with your JPEG image:

```bash
python main.py --input asset/traffic.jpg --method tv
```

Available methods are: `tv`, `atv`, `dirichlet`

Or run the main script with an uncompressed image and your custom JPEG compression:

```bash
python main.py --input asset/traffic.png --method tv  --add_compression true --Q 80
```

## Parameters

- `--input`: Input image file. Can be JPEG (.jpg, .jpeg) or PNG format. 

- `--output`: Decompressed output image file (default: `decompressed.png`).

- `--method`: Regularization method for total variation minimization. Choose from:
  - `tv`: Classical total variation regularization
  - `atv`: Adapted total variation regularization  
  - `dirichlet`: Dirichlet integral regularization

- `--K`: Number of iterations for the TV minimization algorithm (default: `5`). 

- `--beta`: Step size parameter for the gradient descent (default: `-1`). 

- `--add_compression`: Whether to apply JPEG compression to the input image before decompression, in `true` or `false` (default: `false`). 

- `--Q`: JPEG compression quality factor (range: 1-100, required when `--add_compression` is `true`).