• Goals

  1. 学习用不同低通滤波方法模糊图像(Blur imagess with various low pass filter)
  2. 用用定制的滤波器处理图像(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)的更多相关文章

  1. OpenCV 之 图像平滑

    1  图像平滑 图像平滑,可用来对图像进行去噪 (noise reduction) 或 模糊化处理 (blurring),实际上图像平滑仍然属于图像空间滤波的一种 (低通滤波) 既然是滤波,则图像中任 ...

  2. OpenCV:图像平滑和图像模糊处理

    导包: import numpy as np import cv2 import matplotlib.pyplot as plt def show(image): plt.imshow(image) ...

  3. opencv图像处理之常见滤波器

    图像平滑 Smoothing, also called blurring, is a simple and frequently used image processing operation. 平滑 ...

  4. OpenCV 之 边缘检测

    上一篇 <OpenCV 之 图像平滑> 中,提到的图像平滑,从信号处理的角度来看,实际上是一种“低通滤波器”. 本篇中,数字图像的边缘,因为通常都是像素值变化剧烈的区域 (“高频”),故可 ...

  5. opencv-10-图像滤波-噪声添加与均值滤波-含opencv C++ 代码实现

    开始之前 再说上一篇文章中, 我们想按照噪声产生, 然后将降噪的, 但是限于篇幅, 我就放在这一篇里面了, 说起图像的噪声问题就又回到了我们上一章的内容, 把噪声当作信号处理, 实际上数字图像处理实际 ...

  6. OpenCV图像平滑处理

    图像平滑处理 目标 本教程教您怎样使用各种线性滤波器对图像进行平滑处理,相关OpenCV函数如下: blur GaussianBlur medianBlur bilateralFilter 原理 No ...

  7. 图像滤波与OpenCV中的图像平滑处理

    .About图像滤波 频率:可以这样理解图像频率,图像中灰度的分布构成一幅图像的纹理.图像的不同本质上是灰度分布规律的不同.但是诸如"蓝色天空"样的图像有着大面积近似的灰度强度,而 ...

  8. OpenCV图像处理篇之图像平滑

    图像平滑算法 图像平滑与图像模糊是同一概念,主要用于图像的去噪.平滑要使用滤波器.为不改变图像的相位信息,一般使用线性滤波器,其统一形式例如以下: %20\Large%20g(i,j)=\sum_{k ...

  9. OpenCV计算机视觉学习(4)——图像平滑处理(均值滤波,高斯滤波,中值滤波,双边滤波)

    如果需要处理的原图及代码,请移步小编的GitHub地址 传送门:请点击我 如果点击有误:https://github.com/LeBron-Jian/ComputerVisionPractice &q ...

随机推荐

  1. Spring中线程池的应用

    多线程并发处理起来通常比较麻烦,如果你使用spring容器来管理业务bean,事情就好办了多了.spring封装了Java的多线程的实现,你只需要关注于并发事物的流程以及一些并发负载量等特性,具体来说 ...

  2. Field [_id] is a metadata field and cannot be added inside a document. Use the index API request parameters--转

    https://github.com/elasticquent/Elasticquent/issues/53 the data is coming from a Mongo DB instance. ...

  3. 浅谈javascript函数,变量声明及作用域

    javascript函数跟变量的声明.作用域这些概念网上都已经讲烂了. 这里写个博客,也相当于做个笔记. 变量声明 首先看个例子: var globalVar = "gv"; fu ...

  4. oracle 树状结构递归 PL/SQL输出控制 包括空格输出控制

    树状结构 存储过程中通过递归构建,类似BBS回帖显示,代码共三段: 建表,插入数据,创建存储过程显示: 1.create table article(id number primary key,con ...

  5. C#泛型设计的一个小陷阱.

    距离上次发表博客已经有几年了. 对于没能坚持更新博客,实在是感觉到甚是惭愧. 闲言少叙, 直接切入主题. 背景 最近一直在对于公司一个网络通信服务程序使用.net core 进行重构.重构的目的有两个 ...

  6. 使用StackPanel进行简单地布局

    尽管StackPanel非常简单,但是其实用性也非常强 ,Stackpanel将子元素以堆叠的形式 排列在一行或一列.通常建议使用该控件对于一些小范围内的控件进行布局. 如果要架设用户控件的框架结构, ...

  7. NET Core 应用程序 IIS 运行报错 502.3-Gateway

    转自:http://www.zmland.com/forum.php?mod=viewthread&tid=941 将 NET Core 应用程序部署在 IIS 环境,默认配置下,如果任务执行 ...

  8. 撩课-Java每天5道面试题第8天

    撩课Java+系统架构 视频 点击开始学习 71.jsp有哪些内置对象?作用分别是什么? Page, pageContext, request, response, session, applicat ...

  9. hdu 3474 Necklace 单调队列

    Necklace Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Su ...

  10. 原生Ajax(XMLHttpRequest)

    一.什么是Ajax: 全称Asynchronous JavaScript and XML: 异步的 JavaScript 和 XML: 可以在不重新加载整个页面的情况下(偷偷发数据),与服务器交换数据 ...