git:https://github.com/linyi0604/Computer-Vision

 # coding:utf8

 import cv2
import numpy as np
from scipy import ndimage # 3*3 的高通卷积核
kernel_3x3 = np.array([
[-1, -1, -1],
[-1, 8, -1],
[-1, -1, -1]
])
# 5*5 高通卷积核
kernel_5x5 = np.array([
[-1, -1, -1, -1, -1],
[-1, 1, 2, 1, -1],
[-1, 3, 4, 2, -1],
[-1, 1, 2, 1, -1],
[-1, -1, -1, -1, -1]
]) # 按灰度值读入图像
img = cv2.imread("../data/mm1.jpg", 0) # 进行卷积运算
k3 = ndimage.convolve(img, kernel_3x3)
k5 = ndimage.convolve(img, kernel_5x5)
"""
高通滤波器: 根据像素与临近像素的亮度差值来提升像素的亮度
""" # 原图像运用高斯低通滤波器
blurred = cv2.GaussianBlur(img, (11, 11), 0)
"""
低通滤波器: 像素周围亮度小于一个特定值时候,平滑该像素的亮度,主要用于去噪和模糊化
高斯滤波器是最常用的模糊滤波器之一,他是一个削弱强度的低通滤波器
"""
# 原图像减去低通
g_hpf = img - blurred cv2.imshow("3x3", k3)
cv2.imshow("5x5", k5)
cv2.imshow("g_hpf", g_hpf)
cv2.imshow("origin", img)
cv2.waitKey()
cv2.destroyAllWindows()

python opencv3 滤波器 卷积核的更多相关文章

  1. python opencv3添加opencv-contrib

    不需要编译或其他操作,只需一句话安装第三方库利用sift等特征提取算法: sudo pip3 install opencv-contrib-python 附网站:https://pypi.python ...

  2. python opencv3 给图片加中文

    转自:https://www.cnblogs.com/arkenstone/p/6961453.html opencv3.2将中文输出到图片上 opencv自带的putText函数无法输出utf8类型 ...

  3. python opencv3 直线检测

    git:https://github.com/linyi0604/Computer-Vision # coding:utf8 import cv2 import numpy as np # 读入图像 ...

  4. python opencv3 写字画圈画矩形

    python opencv练习 自定义一张[512, 512, 3]的图像 在上面写写字,画画圈和矩形 显示 代码为: import cv2 import numpy as np img = np.z ...

  5. python opencv3 背景分割 mog2 knn

    git:https://github.com/linyi0604/Computer-Vision 使用mog2算法进行背景分割 # coding:utf-8 import cv2 # 获取摄像头对象 ...

  6. python opencv3 运动检测

    git:https://github.com/linyi0604/Computer-Vision 思路:  开启摄像头后 设置一个当前帧为背景, 在之后检测到的帧都与背景对比不同,对不同的地方进行检测 ...

  7. python opencv3 检测人

    git:https://github.com/linyi0604/Computer-Vision # coding:utf-8 import cv2 # 检测i方框 包含o方框 def is_insi ...

  8. python opencv3 FLANN单应性匹配

    git:https://github.com/linyi0604/Computer-Vision 匹配准确率非常高. 单应性指的是图像在投影发生了 畸变后仍然能够有较高的检测和匹配准确率 # codi ...

  9. python opencv3 基于ORB的特征检测和 BF暴力匹配 knn匹配 flann匹配

    git:https://github.com/linyi0604/Computer-Vision bf暴力匹配: # coding:utf-8 import cv2 """ ...

随机推荐

  1. id=%d是什么意思呢?

    $branch=M('Branchs')->where("id=%d",session('branchid'))->find(); %d代表,逗号后面那个user[]的 ...

  2. mac nginx 安装及PHP配置

    安装nginx 1.安装brew命令 ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/mas ...

  3. Css之备忘录~

    1.background-size:contain/cover 两者的作用都是一样,一般用于设置小图标作为背景图,两者的区别是: Contain:不会失真     cover:会失真 2.a标签里面如 ...

  4. python面向对象——类

    from:http://www.runoob.com/python3/python3-class.html Python3 面向对象 Python从设计之初就已经是一门面向对象的语言,正因为如此,在P ...

  5. python函数,模块及eclipse配置python开发环境

    一.eclipse的使用 1.作用 (1)最好用的IDE (2)可调式debug (3)查看可执行过程 (4)可查看源代码 2.安装eclipse及配置 目录安装Pythonpython for ec ...

  6. 【转】Spring MVC 标签总结

    1.@Controller 在SpringMVC 中,控制器Controller 负责处理由DispatcherServlet 分发的请求,它把用户请求的数据经过业务处理层处理之后封装成一个Model ...

  7. textarea保留换行和空格

    <style> pre {white-space: pre-wrap;} </style> //替换textare <pre class="feedback_q ...

  8. Python爬取微信好友

    前言 今天看到一篇好玩的文章,可以实现微信的内容爬取和聊天机器人的制作,所以尝试着实现一遍,本文记录了实现过程和一些探索的内容 来源: 痴海 链接: https://mp.weixin.qq.com/ ...

  9. os.path.isdir(path)异常

    Window 10家庭中文版,Python 3.6.4, 当一个路径以多个斜杠(/)或反斜杠字符(\\)结尾时,os.path.isdir(path)函数仍然将它们判断为目录: >>> ...

  10. SQLite数据库初步

    Windows 10家庭中文版 想使用Python操作SQLite数据库,可是,不知道怎么建立数据库文件. 在SQLite官网溜达了一圈,总算使用上面的工具安装了建立了我需要的数据库文件. 1.进入官 ...