-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
29 lines (25 loc) · 775 Bytes
/
utils.py
File metadata and controls
29 lines (25 loc) · 775 Bytes
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
import cv2
import numpy as np
def downImage(img_file, n):
img = cv2.imread(img_file)
res = img
for i in range(n,0,-1):
res = cv2.pyrDown(res)
#imwrite always write integer value[0,255]
result_path = "down%d.jpg"%i
cv2.imshow(result_path, res)
cv2.waitKey(0)
result_path = "%s-down-%d.jpg"%(img_file,n)
cv2.imwrite(result_path, res)
def genPencilTexture(img_file):
img = cv2.imread(img_file, cv2.IMREAD_GRAYSCALE)
img = np.float32(img)/255.0
cv2.imshow('original', img)
cv2.waitKey(1)
img = np.power(img,1.618)
cv2.imshow('generated pencil texture', img)
cv2.waitKey(0)
if __name__ == '__main__':
downImage('mei5.jpg',2)
img_path = 'pencil3.jpg'
genPencilTexture(img_path)