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

  1. # coding:utf8
  2.  
  3. import cv2
  4. import numpy as np
  5. from scipy import ndimage
  6.  
  7. # 3*3 的高通卷积核
  8. kernel_3x3 = np.array([
  9. [-1, -1, -1],
  10. [-1, 8, -1],
  11. [-1, -1, -1]
  12. ])
  13. # 5*5 高通卷积核
  14. kernel_5x5 = np.array([
  15. [-1, -1, -1, -1, -1],
  16. [-1, 1, 2, 1, -1],
  17. [-1, 3, 4, 2, -1],
  18. [-1, 1, 2, 1, -1],
  19. [-1, -1, -1, -1, -1]
  20. ])
  21.  
  22. # 按灰度值读入图像
  23. img = cv2.imread("../data/mm1.jpg", 0)
  24.  
  25. # 进行卷积运算
  26. k3 = ndimage.convolve(img, kernel_3x3)
  27. k5 = ndimage.convolve(img, kernel_5x5)
  28. """
  29. 高通滤波器: 根据像素与临近像素的亮度差值来提升像素的亮度
  30. """
  31.  
  32. # 原图像运用高斯低通滤波器
  33. blurred = cv2.GaussianBlur(img, (11, 11), 0)
  34. """
  35. 低通滤波器: 像素周围亮度小于一个特定值时候,平滑该像素的亮度,主要用于去噪和模糊化
  36. 高斯滤波器是最常用的模糊滤波器之一,他是一个削弱强度的低通滤波器
  37. """
  38. # 原图像减去低通
  39. g_hpf = img - blurred
  40.  
  41. cv2.imshow("3x3", k3)
  42. cv2.imshow("5x5", k5)
  43. cv2.imshow("g_hpf", g_hpf)
  44. cv2.imshow("origin", img)
  45. cv2.waitKey()
  46. 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. 【文件上传】文件上传的form表单提交方式和ajax异步上传方式对比

    一.html 表单代码 …… <input type="file" class="file_one" name="offenderExcelFi ...

  2. php中各种hash算法的执行速度比较

    更多内容推荐微信公众号,欢迎关注: PHP中的Hash函数很多,像MD4.MD5.SHA-1.SHA-256.SHA-384.SHA-512等我们比较常见,那么各个哈希的执行速度呢? $algos = ...

  3. C# XML序列化和反序列化

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.I ...

  4. yii验证系统学习记录,基于yiicms(一)写的太长了,再写一篇(二)

    项目地址:https://gitee.com/templi/yiicms 感谢七觞酒大神的付出,和免费分享.当然也感谢yii2的开发团队们. 项目已经安全完毕,不知道后台密码,这种背景下,后台无法进去 ...

  5. gitHub 迁移到gitlab上

    GitHub 迁移到 GitLab 上 第一步在github上生成 token 地址 https://blog.csdn.net/u014175572/article/details/55510825 ...

  6. Autofac Named命名和Key Service服务

    参考:http://www.cnblogs.com/wolegequ/archive/2012/06/03/2532605.html

  7. PHP SPL使用方法 自动加载和迭代器

    SPL,PHP 标准库(Standard PHP Library) ,此从 PHP 5.0 起内置的组件和接口,并且从 PHP5.3 已逐渐的成熟.SPL 其实在所有的 PHP5 开发环境中被内置,同 ...

  8. 洛谷P2261余数求和

    传送门啦 再一次见证了分块的神奇用法,在数论里用分块思想. 我们要求 $ ans = \sum\limits ^{n} _{i=1} (k % i) $ ,如果我没看错,这个题的暴力有 $ 60 $ ...

  9. 机器学习 Python实践-K近邻算法

    机器学习K近邻算法的实现主要是参考<机器学习实战>这本书. 一.K近邻(KNN)算法 K最近邻(k-Nearest Neighbour,KNN)分类算法,理解的思路是:如果一个样本在特征空 ...

  10. putIfAbsent

    public static HashSet<Long> getOrInitHashMapCacheValue(Long mId){ // HashSet<Long> set = ...