SHARPENING (HIGHPASS) SPATIAL FILTERS
上一部分介绍的blur能够将图片模糊化, 这部分介绍的是突出图片的边缘的细节.
什么是边缘呢? 往往是像素点跳跃特别大的点, 这部分和梯度的概念是类似的, 可以如下定义图片的一阶导数而二阶导数:
\frac{\partial^2 f}{\partial x^2} = f(x+1) + f(x-1) - 2f(x).
\]
注: 或许用差分来表述更为贴切.
如上图实例所示, 描述了密度值沿着\(x\)的变化, 一阶导数似乎能划分区域, 而二阶导数能够更好的“识别"边缘.
Laplacian
著名的laplacian算子:
\]
在digital image这里:
\]
这个算子用kernel表示是下面的(a), 但是在实际中也有(b, c, d)的用法, (b, d)额外用到了对角的信息, 注意到这些kernels都满足
\]
最后
\]
\(c=-1\), 如果a, b, \(c=1\)如果c, d.
kernel = -np.ones((3, 3))
kernel[1, 1] = 8
laps = cv2.filter2D(img, -1, kernel)
laps = (laps - laps.min()) / (laps.max() - laps.min()) * 255
img_pos = img + laps
img_neg = img - laps
fig, axes = plt.subplots(1, 4)
axes[0].imshow(img, cmap='gray')
axes[1].imshow(laps, cmap='gray')
axes[2].imshow(img_pos, cmap='gray')
axes[3].imshow(img_neg, cmap='gray')
plt.tight_layout()
plt.show()
kernel = np.ones((3, 3))
kernel[0, 0] = 0
kernel[0, 2] = 0
kernel[1, 1] = -4
kernel[2, 0] = 0
kernel[2, 2] = 0
laps = cv2.filter2D(img, -1, kernel)
laps = (laps - laps.min()) / (laps.max() - laps.min()) * 255
img_pos = img + laps
img_neg = img - laps
fig, axes = plt.subplots(1, 4)
axes[0].imshow(img, cmap='gray')
axes[1].imshow(laps, cmap='gray')
axes[2].imshow(img_pos, cmap='gray')
axes[3].imshow(img_neg, cmap='gray')
plt.tight_layout()
plt.show()
有点奇怪... 注意到我上面对laps进行标准化处理了, 如果没这个处理其实感觉是差不多的\(c=1,-1\).
UNSHARP MASKING AND HIGHBOOST FILTERING
注意到, 之前的box kernel,
\]
考虑\(3 \times 3\)的kernel size下:
\]
这里
\]
故假设
\]
其中\(\bar{f}\)是通过box filter 模糊的图像, 则
\]
故\(g_{mask}\)也反应了细节边缘信息.
进一步定义
\]
kernel = np.ones((3, 3)) / 9
img_mask = (img - cv2.filter2D(img, -1, kernel)) * 9
img_mask = (img_mask - img_mask.mean()) / (img_mask.max() - img_mask.min())
fig, ax = plt.subplots(1, 1)
ax.imshow(img_mask, cmap='gray')
plt.show()
First-Order Derivatives
最后再说说如何用一阶导数提取细节.
定义
\]
注: 也常常用\(M(x, y) = |\frac{\partial f}{\partial x}| + |\frac{\partial f}{\partial y}|\)代替.
Roberts cross-gradient
把目标区域按照图(a)区分, Roberts cross-gradient采用如下方式定义:
\]
即右下角的对角之差. 所以相应的kernel变如图(b, c)所示(其余部分为0, \(3 \times 3\)).
注: 计算\(M\)需要两个kernel做两次卷积.
Sobel operators
Sobel operators 则是
\frac{\partial f}{\partial y} = (z_3 + 2z_6 + z_9) - (z_1 + 2z_4 + z_7),
\]
即如图(d, e)所示.
kernel = np.zeros((3, 3))
kernel[1, 1] = -1
kernel[2, 2] = 1
part1 = cv2.filter2D(img, -1, kernel)
kernel = np.zeros((3, 3))
kernel[1, 2] = -1
kernel[2, 1] = 1
part2 = cv2.filter2D(img, -1, kernel)
img_roberts = np.sqrt(part1 ** 2 + part2 ** 2)
part1 = cv2.Sobel(img, -1, dx=1, dy=0, ksize=3)
part2 = cv2.Sobel(img, -1, dx=0, dy=1, ksize=3)
img_sobel = np.sqrt(part1 ** 2 + part2 ** 2)
fig, axes = plt.subplots(1, 2)
axes[0].imshow(img_roberts, cmap='gray')
axes[1].imshow(img_sobel, cmap='gray')
SHARPENING (HIGHPASS) SPATIAL FILTERS的更多相关文章
- SMOOTHING (LOWPASS) SPATIAL FILTERS
目录 FILTERS Box Filter Kernels Lowpass Gaussian Filter Kernels Order-Statistic (Nonlinear) Filters Go ...
- 【Duke-Image】Week_3 Spatial processing
Chapter_3 Intensity Transsformations and Spatial Filtering 灰度变换与空间滤波 Intensity transformation functi ...
- Image Processing and Analysis_8_Edge Detection:The Design and Use of Steerable Filters——1991
此主要讨论图像处理与分析.虽然计算机视觉部分的有些内容比如特 征提取等也可以归结到图像分析中来,但鉴于它们与计算机视觉的紧密联系,以 及它们的出处,没有把它们纳入到图像处理与分析中来.同样,这里面也有 ...
- A simple test
博士生课程报告 视觉信息检索技术 博 士 生:施 智 平 指导老师:史忠植 研究员 中国科学院计算技术研究所 2005年1月 目 ...
- 转载:EQ--biquad filter
http://www.musicdsp.org/files/Audio-EQ-Cookbook.txt https://arachnoid.com/BiQuadDesigner/index.html ...
- KCF:High-Speed Tracking with Kernelized Correlation Filters 的翻译与分析(一)。分享与转发请注明出处-作者:行于此路
High-Speed Tracking with Kernelized Correlation Filters 的翻译与分析 基于核相关滤波器的高速目标跟踪方法,简称KCF 写在前面,之所以对这篇文章 ...
- ADC and DAC Analog Filters for Data Conversion
Figure 3-7 shows a block diagram of a DSP system, as the sampling theorem dictates it should be. Bef ...
- 论文笔记之:Optical Flow Estimation using a Spatial Pyramid Network
Optical Flow Estimation using a Spatial Pyramid Network spynet 本文将经典的 spatial-pyramid formulation ...
- Spatial convolution
小结: 1.卷积广泛存在与物理设备.计算机程序的smoothing平滑.sharpening锐化过程: 空间卷积可应用在图像处理中:函数f(原图像)经过滤器函数g形成新函数f-g(平滑化或锐利化的新图 ...
随机推荐
- A Child's History of England.48
A few could not resolve to do this, but the greater part complied. They made a blazing heap of all t ...
- 用python写的推箱子搜索程序
1 # -*- coding: gbk -*- 2 from functools import reduce 3 from copy import deepcopy 4 import re 5 def ...
- postgresql安装部署
一.下载安装: 1.下载: 官网下载地址:https://www.postgresql.org/download/linux/redhat/ 也可以用这个:https://www.enterprise ...
- 【排序算法】——冒泡排序、选择排序、插入排序、Shell排序等排序原理及Java实现
排序 1.定义: 所谓排序,即是整理文件中的内容,使其按照关键字递增或递减的顺序进行排列. 输入:n个记录,n1,n2--,其对应1的关键字为k1,k2-- 输出:n(i1),n(i2)--,使得k( ...
- JPA和事务管理
JPA和事务管理 很重要的一点是JPA本身并不提供任何类型的声明式事务管理.如果在依赖注入容器之外使用JPA,事务处理必须由开发人员编程实现. 123456789101112UserTransacti ...
- Spring Boot,Spring Cloud,Spring Cloud Alibaba 版本选择说明以及整理归纳
前言 本文的核心目的: 1.方便自己以后的查找,预览,参考 2.帮助那些不知道如何选择版本的朋友进行指引,而不是一味的跟风网上的版本,照抄. Spring Boot 版本 版本查询: https:// ...
- Apache Log4j 2 报高危漏洞,CODING 联手腾讯安全护卫软件安全
导语 12 月 9 日晚间,Apache Log4j 2 发现了远程代码执行漏洞,恶意使用者可以通过该漏洞在目标服务器上执行任意代码,危害极大. 腾讯安全第一时间将该漏洞收录至腾讯安全漏洞特征库中,C ...
- Mysql配置文件 binlog和慢日志
目录 binlog binlog_format log_slave_updates log-bin|log-bin-index expire_logs_days relay-log|relay-log ...
- mysql的MVCC多版本并发控制机制
MVCC多版本并发控制机制 全英文名:Multi-Version Concurrency Control MVCC不会通过加锁互斥来保证隔离性,避免频繁的加锁互斥. 而在串行化隔离级别为了保证较高的隔 ...
- [ZJCTF 2019]Login
学了一段时间的堆溢出现在继续做题, 例行检查一下 64位的程序放入ida中 shift+f12查看程序函数 可以看到非常明显的后门程序 查看主函数 发现了程序给的账号和密码,但是没有看到明显的栈溢出漏 ...