数学之路-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)-机器视觉-滤波去噪(双边滤波与高斯滤波 )
高斯滤波就是对整幅图像进行加权平均的过程.每个像素点的值,都由其本身和邻域内的其它像素值经过加权平均后得到.高斯滤波的详细操作是:用一个模板(或称卷积.掩模)扫描图像中的每个像素.用模板确定的邻域内像 ...
随机推荐
- boost::thread类
前言 标准C++线程即将到来.预言它将衍生自Boost线程库,现在让我们探索一下Boost线程库. 几年前,用多线程执行程序还是一件非比寻常的事.然而今天互联网应用服务程序普遍使用多线程来提高与多客户 ...
- Qt中用正則表達式来推断Text的语种,主要通过推断unicode的编码范围
QString MainWindow::ParseLanguage(QString Text) { if(Text.length()<=0) { return & ...
- 【免费讲座IX算法第一阶段】转专业找CS工作“打狗棒法”
个人经验CS不相干,如何收拾简历?如何获取知识,在最短的时间内找到一份工作需要?如何避免盲目刷称号,迅速制定学习计划?如何准备面试? 星期五.九算法黄蓉老师受邀嘉宾 [在线共享] 她成功转专业的六个月 ...
- android用canvas绘制两种波纹效果
波形效果有几种不同的呈现形式,比如从中间向四周散开的波形,也就是熟知的水涟漪:还有上下波动的曲线,像五线谱等.英文中可以称作Wave或者Ripple,所以暂且叫它们WaveView.WaveLayo ...
- c#1所搭建的核心基础之值类型和引用类型
这个主题很重要,在.NET中做的一切其实都是在和一个值类型或者引用类型打交道. 现实世界中的值和引用 假定你在读一份非常棒的东西,希望一个朋友也去读他.于是你到复印室里复印了一份.这个时候他获得了属于 ...
- TCP/IP笔记 二.网络层(2)——ICMP,RIP,OSPF,BGP
1. ICMP ICMP (Internet Control Message Protocol) 作用:提高 IP 数据报交付成功的机会. 1.1 特点 ICMP 允许主机或路由器报告差错情况和提供有 ...
- Ubuntu 安装和配置minicom
Ubuntu 安装和配置minicom 1 . 安装 Minicom 用新立得软件管理器下载minicom 2.配置Minicom shell下输入 minicom -s 打开配置界面 进入Seria ...
- Android菜鸟的成长笔记(2)——第一个Android应用
原文:Android菜鸟的成长笔记(2)--第一个Android应用 上一篇:Android菜鸟的成长笔记(1)--Anddroid环境搭建从入门到精通 在上一篇Android菜鸟的成长笔记(1)中我 ...
- 与众不同 windows phone (16) - Media(媒体)之编辑图片, 保存图片到相册, 与图片的上下文菜单“应用程序...”和“共享...”关联, 与 Windows Phone 的图片中心集成
原文:与众不同 windows phone (16) - Media(媒体)之编辑图片, 保存图片到相册, 与图片的上下文菜单"应用程序..."和"共享..." ...
- tsunami:一种基于UDP协议的高速传输
一. 需求 近期在做数据库迁移.常常须要打包实例传输.传统scp感觉非常慢. 二. 软件信息 1. 软件主页:http://tsunami-udp.sf.net/ 2. 软件安装:直接源代码make ...