File tree 6 files changed +42
-11
lines changed
6 files changed +42
-11
lines changed Original file line number Diff line number Diff line change
1
+ name : Lint
2
+
3
+ on : [push, pull_request]
4
+
5
+ jobs :
6
+ lint :
7
+ runs-on : ubuntu-latest
8
+ steps :
9
+ - uses : actions/checkout@v2
10
+ - uses : actions/setup-python@v2
11
+ - uses : psf/black@stable
Original file line number Diff line number Diff line change @@ -163,3 +163,5 @@ img/output/
163
163
* .mtc1
164
164
* .out
165
165
* .synctex.gz
166
+
167
+ .vscode /
Original file line number Diff line number Diff line change
1
+ # See https://pre-commit.com for more information
2
+ # See https://pre-commit.com/hooks.html for more hooks
3
+ repos :
4
+ - repo : https://github.com/psf/black
5
+ rev : 19.10b0 # Replace by any tag/version: https://github.com/psf/black/tags
6
+ hooks :
7
+ - id : black
8
+ language_version : python
9
+ - repo : https://github.com/pre-commit/pre-commit-hooks
10
+ rev : v2.0.0
11
+ hooks :
12
+ - id : flake8
Original file line number Diff line number Diff line change 1
-
2
1
<h1 align =" center " >Quantization - team project</h1 >
3
2
3
+ [ ![ Code style: black] ( https://img.shields.io/badge/code%20style-black-000000.svg )] ( https://github.com/psf/black )
4
+
4
5
## Development
5
6
6
7
1 . Create virtual environment with ` virtualenv .venv ` .
Original file line number Diff line number Diff line change
1
+ [tool .black ]
2
+ line-length = 119
3
+ target-version = [' py37' ]
4
+ include = ' \.pyi?$'
Original file line number Diff line number Diff line change 2
2
import numpy as np
3
3
import math
4
4
5
- def PSNR (original , compressed ):
6
- mse = np .mean ((original - compressed ) ** 2 )
7
- if (mse == 0 ): # MSE is zero means no noise is present in the signal .
8
- # Therefore PSNR have no importance.
5
+
6
+ def PSNR (original , compressed ):
7
+ mse = np .mean ((original - compressed ) ** 2 )
8
+ if mse == 0 : # MSE is zero means no noise is present in the signal .
9
+ # Therefore PSNR have no importance.
9
10
return 100
10
11
max_pixel = 255.0
11
- psnr = 20 * math .log10 (max_pixel / math .sqrt (mse ))
12
- return psnr
12
+ psnr = 20 * math .log10 (max_pixel / math .sqrt (mse ))
13
+ return psnr
14
+
13
15
14
- img = Image .open ('.. /img/input/balloon.bmp' )
16
+ img = Image .open (". /img/input/balloon.bmp" )
15
17
16
18
img_arr = np .array (img )
17
- img_arr_noise = img_arr & 254
19
+ img_arr_noise = img_arr & 254
18
20
19
21
img_noise = Image .fromarray (img_arr_noise )
20
- img_noise .save (".. /img/input/balloon_noise.bmp" )
22
+ img_noise .save ("./img/input/balloon_noise.bmp" )
21
23
22
24
print (f"PSNR: { PSNR (img_arr , img_arr_noise )} " )
23
-
You can’t perform that action at this time.
0 commit comments