OpenCV&&python_图像平滑(Smoothing Images)
Goals
- 学习用不同低通滤波方法模糊图像(Blur imagess with various low pass filter)
- 用用定制的滤波器处理图像(Apply custom-made filters to images (2D convolution))
高通滤波与低通滤波
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 – input image.
- dst – output image of the same size and the same number of channels as
src.
- 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 (see
borderInterpolate()for details).
OpenCV&&python_图像平滑(Smoothing Images)的更多相关文章
- OpenCV 之 图像平滑
1 图像平滑 图像平滑,可用来对图像进行去噪 (noise reduction) 或 模糊化处理 (blurring),实际上图像平滑仍然属于图像空间滤波的一种 (低通滤波) 既然是滤波,则图像中任 ...
- OpenCV:图像平滑和图像模糊处理
导包: import numpy as np import cv2 import matplotlib.pyplot as plt def show(image): plt.imshow(image) ...
- opencv图像处理之常见滤波器
图像平滑 Smoothing, also called blurring, is a simple and frequently used image processing operation. 平滑 ...
- OpenCV 之 边缘检测
上一篇 <OpenCV 之 图像平滑> 中,提到的图像平滑,从信号处理的角度来看,实际上是一种“低通滤波器”. 本篇中,数字图像的边缘,因为通常都是像素值变化剧烈的区域 (“高频”),故可 ...
- opencv-10-图像滤波-噪声添加与均值滤波-含opencv C++ 代码实现
开始之前 再说上一篇文章中, 我们想按照噪声产生, 然后将降噪的, 但是限于篇幅, 我就放在这一篇里面了, 说起图像的噪声问题就又回到了我们上一章的内容, 把噪声当作信号处理, 实际上数字图像处理实际 ...
- OpenCV图像平滑处理
图像平滑处理 目标 本教程教您怎样使用各种线性滤波器对图像进行平滑处理,相关OpenCV函数如下: blur GaussianBlur medianBlur bilateralFilter 原理 No ...
- 图像滤波与OpenCV中的图像平滑处理
.About图像滤波 频率:可以这样理解图像频率,图像中灰度的分布构成一幅图像的纹理.图像的不同本质上是灰度分布规律的不同.但是诸如"蓝色天空"样的图像有着大面积近似的灰度强度,而 ...
- OpenCV图像处理篇之图像平滑
图像平滑算法 图像平滑与图像模糊是同一概念,主要用于图像的去噪.平滑要使用滤波器.为不改变图像的相位信息,一般使用线性滤波器,其统一形式例如以下: %20\Large%20g(i,j)=\sum_{k ...
- OpenCV计算机视觉学习(4)——图像平滑处理(均值滤波,高斯滤波,中值滤波,双边滤波)
如果需要处理的原图及代码,请移步小编的GitHub地址 传送门:请点击我 如果点击有误:https://github.com/LeBron-Jian/ComputerVisionPractice &q ...
随机推荐
- jQuery插件开发之windowScroll
回首望,曾经洋洋得意的代码现在不忍直视.曾经看起来碉堡的效果现在也能稍微弄点出来.社会在往前发展,人也得向前迈进. 参考于搜狗浏览器4.2版本首页的上下滚动效果.主要实现整个窗口的上下和左右滚动逻辑, ...
- NSSM - the Non-Sucking Service Manager
nssm is a service helper which doesn't suck. srvany and other service helper programs suck because t ...
- Android6.0内核移植(1):分析编译日志
在下面命令之后产生的编译日志进行分析 source build/envsetup.sh lunch sabresd_6dq-user make -j20 ======================= ...
- Nginx 基于客户端 IP 来开启/关闭认证
前些日子帮助公司在搭建了一个内部资源的导航页面,方便公司员工访问各种常用的系统.因为这个页面包含一些敏感信息,我们希望对其做认证,但仅当从外网访问的时候才开启,当从公司内网访问的时候,则无需输入账号密 ...
- 激活 IntelliJ IDEA
1.点击下面的链接下载 JetbrainsIdesCrack-4.2-release.jar 链接:https://pan.baidu.com/s/1eNY_bwxF7Efl4QG0yh6l1A 提 ...
- C#生成Excel
需要引用MyXls.SL2.dll的类库: 下载地址:http://sourceforge.net/projects/myxls/ 命名空间using org.in2bits.MyXls: //创建表 ...
- Druid SqlParser理解及使用入门
以前的项目中很少去思考SQL解析这个事情,即使在saas系统或者分库分表的时候有涉及到也会有专门的处理方案,这些方案也对使用者隐藏了实现细节. 而最近的这个数据项目里面却频繁涉及到了对SQL的处理,原 ...
- nginx 安装配置和常用命令
基本环境:CentOS 1. 下载 nginx [root@localhost ~]# cd Downloads/ [root@localhost Downloads]# wget http://ng ...
- 基于.Net下整合RestSharp,实现REST服务客户端
一. 准备工作 1. 点击此访问 RestSharp 官网,可作参考 2. VS2012 中安装支持.Net4.0的最新版 RestSharp 插件 工具---NuGet程序包管理器---程序包管理器 ...
- 使用命令行编译打包运行自己的MapReduce程序 Hadoop2.6.0
使用命令行编译打包运行自己的MapReduce程序 Hadoop2.6.0 网上的 MapReduce WordCount 教程对于如何编译 WordCount.java 几乎是一笔带过… 而有写到的 ...