标签:ide sim name osi put ash ges operation optional
高通滤波与低通滤波
images can be filtered with various low-pass filters (LPF), high-pass filters (HPF), etc. A LPF helps in removing noise, or blurring the image. A HPF filters helps in finding edges in an image.
cv2.filter2D()
OpenCV provides a function cv2.filter2D() to convolve卷积 a kernel(核) with an image. 例如:
定义一个5x5 averaging filter kernel
直接上代码:
import cv2 import numpy as np from matplotlib import pyplot as plt #读图像 img = cv2.imread(‘text.jpg‘) #核的定义 kernel = np.ones((5,5),np.float32)/25 dst = cv2.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()
结果展示:
注释:
Python:
cv.
Filter2D
(src, dst, kernel, anchor=(-1, -1))
src
.split()
and process them individually.dst
.borderInterpolate()
for details).
OpenCV&&python_图像平滑(Smoothing Images)
标签:ide sim name osi put ash ges operation optional
原文地址:http://www.cnblogs.com/lwbjyp/p/6916680.html