数学之路-python计算实战(19)-机器视觉-卷积滤波
filter2D
Convolves an image with the kernel.
- C++: void filter2D(InputArray src, OutputArray dst, int ddepth, InputArraykernel, Point anchor=Point(-1,-1), double delta=0, int borderType=BORDER_DEFAULT )
- Python: cv2.filter2D(src, ddepth, kernel[, dst[, anchor[, delta[, borderType]]]]) → dst
- C: void cvFilter2D(const CvArr* src, CvArr* dst, const CvMat* kernel, CvPointanchor=cvPoint(-1,-1) )
- Python: cv.Filter2D(src, dst, kernel, anchor=(-1, -1)) → None
-
Parameters: - src – input image.
- dst – output image of the same size and the same number of channels as src.
- ddepth –
- desired depth of the destination image; if it is negative, it will be the same as src.depth(); the following combinations ofsrc.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.
- kernel – convolution kernel (or rather a correlation kernel), a single-channel floating point matrix; if you want to apply different kernels to different channels, split the image into separate color planes using split() and process them individually.
- anchor – anchor of the kernel that indicates the relative position of a filtered point within the kernel; the anchor should lie within the kernel; default value (-1,-1) means that the anchor is at the kernel center.
- delta – optional value added to the filtered pixels before storing them in dst.
- borderType – pixel extrapolation method (seeborderInterpolate() for details).
The function applies an arbitrary linear filter to an image. In-place operation is supported. When the aperture is partially outside the image, the function interpolates outlier pixel values according to the specified border mode.
# -*- coding: utf-8 -*-
#卷积滤波
#code:myhaspl@myhaspl.com
import cv2
import numpy as np
fn="test2.jpg"
myimg=cv2.imread(fn)
img=cv2.cvtColor(myimg,cv2.COLOR_BGR2GRAY)
myh=np.array([[0,1,0],[1,-4,1],[0,1,0]])
jgimg=cv2.filter2D(img,-1,myh)
cv2.imshow('src',img)
cv2.imshow('dst',jgimg)
cv2.waitKey()
cv2.destroyAllWindows()
本博客全部内容是原创,假设转载请注明来源
http://blog.csdn.net/myhaspl/
数学之路-python计算实战(19)-机器视觉-卷积滤波的更多相关文章
- 数学之路-python计算实战(21)-机器视觉-拉普拉斯线性滤波
拉普拉斯线性滤波,.边缘检測 . When ksize == 1 , the Laplacian is computed by filtering the image with the follow ...
- 数学之路-python计算实战(17)-机器视觉-滤波去噪(中值滤波)
Blurs an image using the median filter. C++: void medianBlur(InputArray src, OutputArray dst, int ks ...
- 数学之路-python计算实战(20)-机器视觉-拉普拉斯算子卷积滤波
拉普拉斯算子进行二维卷积计算,线性锐化滤波 # -*- coding: utf-8 -*- #线性锐化滤波-拉普拉斯算子进行二维卷积计算 #code:myhaspl@myhaspl.com impor ...
- 数学之路-python计算实战(15)-机器视觉-滤波去噪(归一化块滤波)
# -*- coding: utf-8 -*- #code:myhaspl@myhaspl.com #归一化块滤波 import cv2 import numpy as np fn="tes ...
- 数学之路-python计算实战(14)-机器视觉-图像增强(直方图均衡化)
我们来看一个灰度图像,让表示灰度出现的次数,这样图像中灰度为 的像素的出现概率是 是图像中全部的灰度数, 是图像中全部的像素数, 实际上是图像的直方图,归一化到 . 把 作为相应于 的累计概率 ...
- 数学之路-python计算实战(9)-机器视觉-图像插值仿射
插值 Python: cv2.resize(src, dsize[, dst[, fx[, fy[, interpolation]]]]) → dst interpolation – interpol ...
- 数学之路-python计算实战(13)-机器视觉-图像增强
指数变换的基本表达式为:y=bc(x-a)-1 当中參数b.c控制曲线的变换形状,參数a控制曲线的位置. 指数变换的作用是扩展图像的高灰度级.压缩低灰度级.能够用于亮度过高的图像 本博客全部内容是原创 ...
- 数学之路-python计算实战(16)-机器视觉-滤波去噪(邻域平均法滤波)
# -*- coding: utf-8 -*- #code:myhaspl@myhaspl.com #邻域平均法滤波,半径为2 import cv2 import numpy as np fn=&qu ...
- 数学之路-python计算实战(18)-机器视觉-滤波去噪(双边滤波与高斯滤波 )
高斯滤波就是对整幅图像进行加权平均的过程.每个像素点的值,都由其本身和邻域内的其它像素值经过加权平均后得到.高斯滤波的详细操作是:用一个模板(或称卷积.掩模)扫描图像中的每个像素.用模板确定的邻域内像 ...
随机推荐
- Android程序检测网络是否可用
在做Android应用程序中,连接网络的时候,常常要用到检测网络状态是否可用,在这里分享一个比较好用的方法. 本人参考:http://blog.csdn.net/sunboy_2050/article ...
- uva 11400 Problem F Lighting System Design
紫皮书题: 题意:让你设计照明系统,给你n种灯泡,每种灯泡有所需电压,电源,每个灯泡的费用,以及每个灯泡所需的数量.每种灯泡所需的电源都是不同的,其中电压大的灯泡可以替换电压小的灯泡,要求求出最小费用 ...
- linux配置本地tomcat应用80端口转发
场景: 本地部署tomcat到8080端口,并期望本地访问80端口来访问本地tomcat. 结论: 使用linux下的iptables工具实现端口转发功能. 具体为 现取得root权限 执行iptab ...
- mysql基础: mysql列类型--字符串
mysql列类型:整型 http://blog.csdn.net/jk110333/article/details/9342283 mysql列类型--时间和日期 http://blog.csd ...
- 【Demo 0001】Java基础-数据类型
本章学习要点: 1. 了解Java 语言 2. 了解Java程序结构; 3. 了解Java中基本数据类型; 4. 掌握基本数据类型之间的运算 ...
- [读书笔记]设计原本[The Design of Design]
第1章 设计之命题 1.设计首先诞生于脑海里,再慢慢逐步成形(实现) 2.好的设计具有概念完整性:统一.经济.清晰.优雅.利落.漂亮... 第2章 工程师怎样进行设计思维——理性模型 1.有序模型的有 ...
- maven的命令使用笔记
(1)创建web项目mvn archetype:create -DgroupId=com.mycompany.webapp -DartifactId=myweb -DarchetypeArtif ...
- TP-LINK无线路由器WR340G+ 54M支持WDS - 东莞市泰讯电子科技有限公司
TP-LINK无线路由器WR340G+ 54M支持WDS - 东莞市泰讯电子科技有限公司 TP-LINK无线路由器WR340G+ 54M支持WDS 品牌 TP-LINK无线路由器 型号 WR340 ...
- ISO/OSI网络体系结构和TCP/IP协议模型
1. ISO/OSI的参考模型共有7层,由低层至高层分别为:物理层.数据链路层.网络层.传输层.会话层.表示层. 应用层.各层功能分别为: (1)物理层 提供建立.维护和拆除 ...
- 七内部排序算法汇总(插入排序、Shell排序、冒泡排序、请选择类别、、高速分拣合并排序、堆排序)
写在前面: 排序是计算机程序设计中的一种重要操作,它的功能是将一个数据元素的随意序列,又一次排列成一个按keyword有序的序列.因此排序掌握各种排序算法很重要. 对以下介绍的各个排序,我们假定全部排 ...