MBG0903 commited on
Commit
2c1eec0
·
verified ·
1 Parent(s): accd6a0

Create sharpen.py

Browse files
Files changed (1) hide show
  1. utils/sharpen.py +33 -0
utils/sharpen.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import cv2
2
+ import numpy as np
3
+
4
+
5
+ def sharpen_image(img):
6
+
7
+ kernel = np.array(
8
+ [
9
+ [0, -1, 0],
10
+ [-1, 5, -1],
11
+ [0, -1, 0]
12
+ ]
13
+ )
14
+
15
+ return cv2.filter2D(
16
+ img,
17
+ -1,
18
+ kernel
19
+ )
20
+
21
+
22
+ def upscale_image(img, scale=2):
23
+
24
+ height = int(img.shape[0] * scale)
25
+ width = int(img.shape[1] * scale)
26
+
27
+ upscaled = cv2.resize(
28
+ img,
29
+ (width, height),
30
+ interpolation=cv2.INTER_NEAREST
31
+ )
32
+
33
+ return upscaled