-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathutility.py
36 lines (26 loc) · 803 Bytes
/
utility.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import numpy as np
import cv2
def crop (h, w, scale) :
h = h - np.mod(h, scale)
w = w - np.mod(w, scale)
return h, w
def getSize(image) :
if len(image.shape) == 3 :
h, w, _ = image.shape
else:
h, w = image.shape
return h, w
def getImage (h, w, image) :
if len(image.shape) == 3 :
image = image[0:h, 0:w, :]
else:
image = image[0:h, 0:w]
return image
def modcrop (image, scale) :
h, w = getSize(image)
h, w = crop(h, w, scale)
return getImage(h, w, image)
def bicubicInterpolation(image, scale, dim ) :
downScale = cv2.resize(image,dsize=(0,0), fx=scale,fy=scale, interpolation = cv2.INTER_CUBIC)
upScale = cv2.resize(downScale, dsize = (dim[1], dim[0]), interpolation = cv2.INTER_CUBIC)
return upScale