美文网首页
[OpenCV官方教程中文版-段力辉译]-图像平滑-2D卷积

[OpenCV官方教程中文版-段力辉译]-图像平滑-2D卷积

作者: 六千宛 | 来源:发表于2021-06-26 21:29 被阅读0次

1.1-2D 卷积

image.png
import cv2
import matplotlib.pyplot as plt
img1 = cv2.imread('D:/PYCHARM_WORK/cv/cv_detection/project/guandao_angle_detection/sample1.jpg')

import cv2
import numpy as np
from matplotlib import pyplot as plt

kernel = np.ones((5,5),np.float32)/25
#cv.Filter2D(src, dst, kernel, anchor=(-1, -1))
#ddepth –desired depth of the destination image;
#if it is negative, it will be the same as src.depth();
#the following combinations of src.depth() and ddepth are supported:
#src.depth() = CV_8U, ddepth = -1/CV_16S/CV_32F/CV_64F
#src.depth() = CV_16U/CV_16S, ddepth = -1/CV_32F/CV_64F
#src.depth() = CV_32F, ddepth = -1/CV_32F/CV_64F
#src.depth() = CV_64F, ddepth = -1/CV_64F
#when ddepth=-1, the output image will have the same depth as the source.
dst = cv2.filter2D(img1,-1,kernel)
plt.subplot(121),plt.imshow(img1),plt.title('Original')
plt.xticks([]), plt.yticks([])
plt.subplot(122),plt.imshow(dst),plt.title('Averaging')
plt.xticks([]), plt.yticks([])
plt.show()
image.png

相关文章

网友评论

      本文标题:[OpenCV官方教程中文版-段力辉译]-图像平滑-2D卷积

      本文链接:https://www.haomeiwen.com/subject/kaekyltx.html