提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档
文章目录
前言
上一章我们讲到频率低通滤波,简而言之就是让图像的低频信号通过,过滤或者衰减高频信号。频率高通滤波刚好相反,让图像的高频信号通过,过滤或者衰减低频信号。
1. 理论基础
由于频率域低通滤波域高通滤波的原理一样,知识滤波器不同,因此原理部分此处不做讲解,各位可以查看上一章的内容

从上图可以看出频率域高通滤波器的传递函数都是基于对应的低通滤波器传递函数推导出来的。各位可以对下面的两幅图片进行对比分析:


2. 示例分析
2.1 示例代码
import cv2 as cv
import numpy as np
import matplotlib.pyplot as plt
def genIdealHighpassFilters(D0, shape):
"""
Generate an ideal high pass filter
Those inside the circle are marked 1 and those outside are marker 0.
:param D0: The radius of the circle.
:param shape: The shape of the mask (the mask is also an image)
:return:
"""
mask = np.ones(shape, np.uint8)
center = np.array([shape[0] // 2, shape[1] // 2])
for i in range(shape[0]):
for j in range(shape[1]):
point = np.array([i, j])
distance = np.linalg.norm(point - center)
if distance <= D0:
# print(distance, radius)
mask[i][j] = 0
return mask
def genGaussianHighpassFilters(sigma, shape):
"""
Generate a gaussian high pass filter
:param sigma: The standard deviation of the gaussian filter.
:param shape: The shape of the mask (the mask is also an image)
:return: Returns a gaussian high pass filter.
"""
mask = np.ones(shape, np.float32)
rows, cols = shape[0], shape[1]
center_x, center_y = rows // 2, cols /

最低0.47元/天 解锁文章
4344

被折叠的 条评论
为什么被折叠?



