High-pass filtering and low-pass filtering from rational to perceptual analysis

High-pass filtering and low-pass filtering from rational to perceptual analysis

Analysis of high-pass and low-pass filtering

  • Physical meaning:
    • From the perspective of frequency, high-pass filters out low-frequency information, and low-pass filters out high-frequency information
    • From the sampling point, the low-pass makes the change of the sampling point more gentle, that is, increasing the low frequency and reducing the high frequency
  • in summary
    • The essence is to smooth the sample point value of the current dimension and remove the relevant high and low frequency information
    • The smoother the time domain, the more low-frequency information it corresponds to; the more varied the time domain, the more high-frequency information it corresponds to
  • Low pass (1st order)
    • alpha parameter, changing from 0-1, 0 means no filter effect, all are the initial value x[0], 1 means all x[i] input
    • 0.1 low pass is the most ruthless, 0.8 low pass is slightly lighter
    • In general, the change between before and after the sample point is reduced, and the smooth curve reduces the change, making it more like a straight line
  • Qualcomm (Level 1)
    • Generally, it is in the range of lowering the amplitude, and the envelope changes little before and after.
    • 0.1 Qualcomm is the most ruthless, 0.8 Qualcomm is slightly lighter
    • The small density of sample points changes to achieve high-pass, and the gentle changes are weakened to prevent low-pass

The formula is as follows:
insert image description here

Comparison of low-pass filter parameters:
insert image description here
insert image description here

insert image description here

Comparison of high-pass filter parameters:

insert image description here
insert image description here
insert image description here

Python simulation code

Code for comparative analysis:

# -*- coding: utf-8 -*-
"""
Created on Thu Jul  7 14:09:06 2022

@author: laizhixiao
"""

import matplotlib.pyplot as plt      # 绘图用
import numpy as np                   # 数据处理用
import math as mt                    # 数学运算


def plot_advance(x, y0, y1, xx):
    fig2 = plt.figure()
#    l1 = plt.plot(x, y0, color='r',marker='o', linestyle='dashed', label='yl')   # 返回结果为对线操作的句柄
    l2 = plt.plot(x, y1, color='k',marker='.', linestyle='--', label='yh')        # 黑色,linestye: -, --实线
    l2 = plt.plot(x, xx, color='b',marker='.', linestyle='--', label='xx')        # 黑色,linestye: -, --实线
    
    plt.xlabel('x')
    plt.ylabel('y')
    plt.title('test')
    plt.legend()                             # 显示图例,即每条线对应 label 中的内容
#     plt.axis([-1, 33, -1, 480])            # [xmin, xmax, ymin, ymax]
    plt.xlim(-1, 33)                         # 或单独设置
    plt.ylim(-3, 3)
#     plt.grid()
    plt.grid(linestyle='--')               # 组合有: -.   -- 
    plt.show()
#    plt.savefig('./salary.jpg')
    fig2.savefig('./pic.jpg')
    # plt.close(fig2)


if __name__ == "__main__":
    x0 = list(range(30))
    x  = np.random.randn(30)

    #lowpass
    yl = list(range(30))
    yl[0] = x[0]
    alpha = 0.8
    for i in range(29):
        i = i + 1
        yl[i] = alpha * x[i] + (1 - alpha) * (yl[i - 1])

    #highpass
    yh = list(range(30))
    yh[0] = x[0]
    for i in range(29):
        i = i + 1
        yh[i] = alpha * yh[i - 1] + alpha * (x[i] - x[i - 1])

    print('start processing...')
    plot_advance(x0, yl, yh, x)
    print('done!')

References


  1. A simple understanding of high-pass filtering and low-pass filtering, link1
  2. Derivation of the principle of program realization of low-pass filter and high-pass filter, link2

Guess you like

Origin blog.csdn.net/qq_17256689/article/details/130875002
Recommended