SMOOTHING (LOWPASS) SPATIAL FILTERS
Gonzalez R. C. and Woods R. E. Digital Image Processing (Forth Edition).
import cv2
import matplotlib.pyplot as plt
import numpy as np
FILTERS
filters实际上就是通过一些特殊的kernel \(w\) 对图片进行如下操作:
\]
其中\(w(s, t) \in \mathbb{R}^{m \times n}, m=2a+1, n = 2b+1\).
注: 注意到上面会出现\(f(-1, -1)\)之类的未定义情况, 常见的处理方式是在图片周围加padding(分别为pad a, b), 比如补0或者镜像补.
用卷积的目的是其特别的性质:
- \(f * g = g * f\);
- \(f * (g * h) = (f * g) * h\);
- \(f * (g + h) = (f * g) + (g * h)\).
注: \(f, g, h\)应当形状一致 (或者每次卷积完同样进行padding).
特别的, 如果
\]
则
\]
可以显著降低计算量.
Box Filter Kernels
即
\]
img = cv2.imread("./pics/alphabeta.png")
img.shape
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) # 由于是截图, 先转成灰度图
plt.imshow(img, cmap='gray')

# 或者等价地用 cv2.blur(img, (m, n))
kernels = [np.ones((i, i)) / (i * i) for i in [3, 11, 21]]
imgs_smoothed = [cv2.filter2D(img, -1, kernel) for kernel in kernels]
fig, axes = plt.subplots(2, 2)
axes[0, 0].imshow(img, cmap='gray')
axes[0, 0].set_title("raw")
axes[0, 1].imshow(imgs_smoothed[0], cmap="gray")
axes[0, 1].set_title("3x3")
axes[1, 0].imshow(imgs_smoothed[1], cmap="gray")
axes[1, 0].set_title("11x11")
axes[1, 1].imshow(imgs_smoothed[2], cmap="gray")
axes[1, 1].set_title("21x21")
plt.tight_layout()
plt.show()

Lowpass Gaussian Filter Kernels
即
\]
高斯分布的特点是绝大部分集中于\((-3\sigma, +3\sigma)\)之间, 故一般\(w\)的大小选择为\((-6\sigma, +6\sigma)\), 需要注意的是, \(\sigma\)的选择和图片的大小息息相关.
imgs_smoothed = [cv2.GaussianBlur(img, ksize=ksize, sigmaX=sigma) for (ksize, sigma) in [((5, 5), 1), ((21, 21), 3.5), ((43, 43), 7)]]
fig, axes = plt.subplots(1, 4)
axes[0].imshow(img, cmap='gray')
axes[0].set_title("raw")
axes[1].imshow(imgs_smoothed[0], cmap="gray")
axes[1].set_title("5x5, 1")
axes[2].imshow(imgs_smoothed[1], cmap="gray")
axes[2].set_title("21x21, 3.5")
axes[3].imshow(imgs_smoothed[2], cmap="gray")
axes[3].set_title("43x43, 7")
plt.tight_layout()
plt.show()

Order-Statistic (Nonlinear) Filters
即\(g(x, y)\)由\((x, y)\)周围的点的一个某个顺序的值代替, 比如median.
imgs_smoothed = [cv2.medianBlur(img, ksize=ksize) for ksize in [3, 7, 15]]
fig, axes = plt.subplots(1, 4)
axes[0].imshow(img, cmap='gray')
axes[0].set_title("raw")
axes[1].imshow(imgs_smoothed[0], cmap="gray")
axes[1].set_title("3x3")
axes[2].imshow(imgs_smoothed[1], cmap="gray")
axes[2].set_title("7x7")
axes[3].imshow(imgs_smoothed[2], cmap="gray")
axes[3].set_title("15x15")
plt.tight_layout()
plt.show()

SMOOTHING (LOWPASS) SPATIAL FILTERS的更多相关文章
- SHARPENING (HIGHPASS) SPATIAL FILTERS
目录 Laplacian UNSHARP MASKING AND HIGHBOOST FILTERING First-Order Derivatives Roberts cross-gradient ...
- 【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
此主要讨论图像处理与分析.虽然计算机视觉部分的有些内容比如特 征提取等也可以归结到图像分析中来,但鉴于它们与计算机视觉的紧密联系,以 及它们的出处,没有把它们纳入到图像处理与分析中来.同样,这里面也有 ...
- EAC3 enhanced channel coupling
Enhanced channel coupling是一种spatial coding 技术,在传统的channel coupling的基础上添加了phase compensation, de-corr ...
- A simple test
博士生课程报告 视觉信息检索技术 博 士 生:施 智 平 指导老师:史忠植 研究员 中国科学院计算技术研究所 2005年1月 目 ...
- IIR filter design from analog filter
Analog filter和digital filter的联系: z变换与Laplace从数学上的关系为: 但这种关系在实际应用上不好实现,因此通常使用biliner transform(https: ...
- fMRI: spatial smoothing
Source: Brain voyager support Theoretical Background Spatial smoothing means that data points are av ...
- 【DIP, OpenCV】Some Kinds Of Image Smoothing Methodologies
In digital image processing(DIP), many methods are used in smoothing images in order to suppress noi ...
- Smoothing in fMRI analysis (FAQ)
Source: http://mindhive.mit.edu/node/112 1. What is smoothing? "Smoothing" is generally us ...
随机推荐
- JAVA中的六种日期类型使用
基本的6种日期类 /** * 六种时间类型的类 * 数据库格式的时间三种格式 */ java.util.Date date = new java.util.Date();//年与日时分秒 //数据库的 ...
- Linux基础命令---mailq显示邮件队列
mailq mailq指令可以显示出待发送的邮件队列. 此命令的适用范围:RedHat.RHEL.Ubuntu.CentOS.Fedora. 1.语法 mailq 2.选项参数列表 ...
- 在隐藏导航栏的控制器中,调用UIIMagePickerController,出现导航栏变透明的问题
在隐藏导航栏的控制器中,调用UIIMagePickerController,出现导航栏变透明的问题 解决办法 #pragma mark - UIImagePickerController Delega ...
- transient关键字和volatile关键字
看到HashSet的源代码的时候,有一个关键字不太认识它..transient,百度整理之: Java的Serialization提供了一种持久化对象实例的机制,当持久化对象时,可能有一些特殊的对象数 ...
- 【编程思想】【设计模式】【行为模式Behavioral】状态模式State
Python版 https://github.com/faif/python-patterns/blob/master/behavioral/state.py #!/usr/bin/env pytho ...
- feignclient发送get请求,传递参数为对象
feignclient发送get请求,传递参数为对象.此时不能使用在地址栏传递参数的方式,需要将参数放到请求体中. 第一步: 修改application.yml中配置feign发送请求使用apache ...
- Vector Bin Packing 华为讲座笔记
Vector bin packing:first fit / best fit / grasp 成本:性价比 (先验) 设计评价函数: evaluation function:cosine simil ...
- java 多线程的状态迁移 常用线程方法分析
一.线程的各个状态 图中的线程状态(Thread.Stat 中定义的Enum 名)NEW.RUNNABLE .TERMINATED.WAITING.TIMED_WAITING 和BLOCKED 都能够 ...
- java多线程并发编程中的锁
synchronized: https://www.cnblogs.com/dolphin0520/p/3923737.html Lock:https://www.cnblogs.com/dolphi ...
- 使用frp进行内网穿透,实现ssh远程访问Linux服务器
搭建一个完整的frp服务链需要: VPS一台(也可以是具有公网IP的实体机) 访问目标设备(就是你最终要访问的设备) 简单的Linux基础(如果基于Linux配置的话) 我这里使用了腾讯云服务器作为服 ...