6.2 频率域滤波之高通滤波

提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档


前言

上一章我们讲到频率低通滤波,简而言之就是让图像的低频信号通过,过滤或者衰减高频信号。频率高通滤波刚好相反,让图像的高频信号通过,过滤或者衰减低频信号。


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 /
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值