-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path12_smoothing_images.py
38 lines (26 loc) · 970 Bytes
/
12_smoothing_images.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
37
38
import numpy as np
import cv2 as cv
import matplotlib.pyplot as plt
############################ 2D convolution #########################
# img = cv.imread('OpenCV_Logo.png')
# kernel = np.ones((5,5),np.float32)/25
# dst = cv.filter2D(img, -1, kernel)
# plt.subplot(121),plt.imshow(img),plt.title('Original')
# plt.xticks([]), plt.yticks([])
# plt.subplot(122),plt.imshow(dst),plt.title('Averaging')
# plt.xticks([]), plt.yticks([])
# plt.show()
# cv.waitKey(0)
# cv.destroyAllWindows()
############################### Image Blurring ###############################
########### Averaging ###########
img = cv.imread('OpenCV_Logo.png')
# blur = cv.blur(img,(5,5))
# blur = cv.GaussianBlur(img, (5,5), 0)
# blur = cv.medianBlur(img, 5)
blur = cv.bilateralFilter(img, 9, 75, 75)
plt.subplot(121),plt.imshow(img),plt.title('Original')
plt.xticks([]), plt.yticks([])
plt.subplot(122),plt.imshow(blur),plt.title('Blurred')
plt.xticks([]), plt.yticks([])
plt.show()