当前位置:网站首页>OpenCV笔记(二十):滤波函数——filter2D
OpenCV笔记(二十):滤波函数——filter2D
2022-07-30 21:44:00 【生活需要深度】
ilter2D用于将自定义的滤波器应用于图像,需要为这个函数提供的一个重要参数就是核矩阵。
该函数非常强大,可以生成很多种不同的结果,包括与之前的模糊函数相同的结果,不同的核还可以形成很多不同的滤波器。
不同核的示例
OpenCV API:
cv2.filter2D(src, ddepth, kernel)
参数:
src:输入的图像
ddepth:图像的深度
kernel:卷积核的大小
代码示例:
import cv2 as cv
import numpy as np
src = cv.imread("E:\\qi.png")
img = src.copy()
kernel = np.array([[0, 1.5, 0],
[1.5, -6, 1.5],
[0, 1.5, 0]])
dst = cv.filter2D(img, -1, kernel)
# 显示图像
fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(10, 8), dpi=100)
axes[0].imshow(img[:, :, ::-1])
axes[0].set_title("原图")
axes[1].imshow(dst[:, :, ::-1])
axes[1].set_title("结果")
plt.show()
代码示例中的卷积核为
可用于检测图像的边缘
2. 卷积核
可用于锐化图像
3. 卷积核
可生成浮雕化的图像
分身(即和本身一模一样)
4. 卷积核
之前见过的Sobel算子
卷积核为
Laplacian算子
卷积核为等。
边栏推荐
猜你喜欢
Advanced c language: pointers (5)
MySQL 8.0.29 decompressed version installation tutorial (valid for personal testing)
MySQL user authorization
mysql 时间字段默认设置为当前时间
cnpm installation steps
[Deep Learning] Target Detection | SSD Principle and Implementation
【信息安全技术】RSA算法的研究及不同优化策略的比较
手动从0搭建ABP框架-ABP官方完整解决方案和手动搭建简化解决方案实践
Uni-app 小程序 App 的广告变现之路:激励视频广告
cookie和session区别
随机推荐
ClickHouse 创建数据库建表视图字典 SQL
关于MySQL主从复制的数据同步延迟问题
ELF: Loading process
基于ABP实现DDD--领域逻辑和应用逻辑
Collapse legacy apps
小心你的字典和样板代码
触摸屏状态机
折叠旧版应用程序
Typescript 严格模式有多严格?
How do I refresh the company's background management system (Part 1) - performance optimization
The structure of knowledge in the corners of the C language
About the data synchronization delay of MySQL master-slave replication
ClickHouse删除数据之delete问题详解
系统结构考点之多级混洗交换网络
cmd (command line) to operate or connect to the mysql database, and to create databases and tables
Solve the problem of centos8 MySQL password ERROR 1820 (HY000) You must reset your password using the ALTER USER
Advanced c language: pointers (5)
JUC原子类详解
MySQL 5.7详细下载安装配置教程
Apache DolphinScheduler新一代分布式工作流任务调度平台实战-