OpenCV的图像处理————模糊锐化处理

 1 #!/bin/python3
 2   2 
 3   3 import cv2 as cv
 4   4 import numpy as np
 5   5 
 6   6 
 7   7 #均值模糊
 8   8 def blur_demo(image):
 9   9     dst = cv.blur(image,(5,3))
10  10     cv.imshow("blur_demo",dst)
11  11 
12  12 
13  13 #中值模糊
14  14 
15  15 def median_blur_demo(image):
16  16     dst = cv.medianBlur(image,(5,3))
17  17     cv.imshow("median_blur_demo",dst)
18  18 
19  19 
20  20 #哈希模糊 >>>>自定义>>>>>锐化
21  21 def custon_blur_demo(image):
22  22     #kernel = np.ones([5,5],np.float32)/25
23  23 
24  24     kernel = np.array([[0,-1,0],[-1,6,-1],[0,-1,0]],np.float32)
25  25     dst = cv.filter2D(image,-1,kernel=kernel)
26  26     cv.imshow("custom_blur_demo",dst)
27  27 
28  28 
29  29 ("----------Hello Python-----------------")
30  30 src = cv.imread("/home/laohe/downloads/image.jpeg")
31  31 cv.namedWindow("input image",cv.WINDOW_AUTOSIZE)
32  32 cv.imshow("input image",src)
33  33 
34  34 blur_demo(src)
35  35 custon_blur_demo(src)
36  36 cv.waitKey(0)
37  37 cv.destroyAllWindows()
38 
39 -- 插入 --                        

 

posted @ 2020-12-20 20:47  挑水工  阅读(546)  评论(0编辑  收藏  举报