Guide package:
import numpy as np import cv2 import matplotlib.pyplot as plt def show(image): plt.imshow(image) plt.axis('off') plt.show() def imread(image): image=cv2.imread(image) image=cv2.cvtColor(image,cv2.COLOR_BGR2RGB) return image
The image smoothing process:
= kernelsizes [(3,3), (9, 9), (15, 15 )] plt.figure (figsize = (15, 15 )) for I, Kenel in the enumerate (kernelsizes): plt.subplot ( l, 3 , I +. 1 ) # average smooth manner Blur = cv2.blur (Image, Kenel) plt.axis ( ' OFF ' ) # not display coordinate plt.title ( ' Great title ' + STR (Kenel)) plt.imshow ( Blur) plt.show ()
Gaussian blur:
= kernelsizes [(3,3), (9, 9), (15, 15)] # only for this picture, the mean and Gaussian blur blur is no difference. plt.figure (figsize = (15, 15 )) for I, Kenel in the enumerate (kernelsizes): plt.subplot ( l, 3, I +. 1 ) # Average smooth manner Blur = cv2.GaussianBlur (Image, Kenel, 0 ) plt.axis ( ' OFF ' ) # not display coordinate plt.title ( ' Great title ' + STR (Kenel)) plt.imshow (Blur) plt.show ()
Median Blur:
plt.figure (figsize = (15, 15 )) for I, Kenel in the enumerate ((3,9,15)): # means is representative of a convolution kernel 3 * 3,9 * 9,15 * 15 plt.subplot (l, 3, I +. 1 ) # average smooth manner Blur = cv2.medianBlur (Image, Kenel, 0) plt.axis ( ' OFF ' ) # not display coordinate plt.title ( ' Great title ' + STR (Kenel )) plt.imshow (Blur) plt.show ()