HIGH PASS FILTER USING HAMMING WINDOW FUNCTION

HIGH PASS FILTER USING HAMMING WINDOW FUNCTION

Summary:
A high-pass filter (HPF) allows signals with frequencies higher than a certain cutoff frequency to pass through while attenuating lower frequencies. In digital signal processing, such a filter can be designed using the window method, where an ideal filter’s impulse response is truncated and shaped by a window function. The Hamming window is commonly used for this purpose due to its good frequency response—offering a balance between main-lobe width and side-lobe attenuation. This process involves designing an ideal HPF in the time domain, multiplying it by the Hamming window to control leakage, and then implementing it digitally. A step-by-step design example is provided at the end.


What Is a High-Pass Filter?

A high-pass filter passes high-frequency components of a signal and suppresses frequencies lower than a specified cutoff fcf_c. It is used in applications like noise removal, speech processing, and edge detection in images.


Ideal vs. Real Filters

  • Ideal HPF has a sharp transition and infinite impulse response—non-causal and impractical.

  • Practical HPF has a finite impulse response (FIR), achieved by truncating the ideal response and applying a window function like Hamming.


Why Use the Hamming Window?

Truncating an ideal filter leads to Gibbs phenomenon—ripples in the frequency response. A Hamming window smooths the edges of the truncated filter to reduce these ripples.

The Hamming window is defined as:

w[n]=0.540.46cos(2πnN1),0nN1w[n] = 0.54 - 0.46\cos\left(\frac{2\pi n}{N-1}\right), \quad 0 \leq n \leq N-1

Here, NN is the length of the filter.


The Filtering Process

  1. Design ideal HPF in time-domain:

    hd[n]=δ[n]sin(2πfc(nN2))π(nN2)h_d[n] = \delta[n] - \frac{\sin(2\pi f_c (n - \frac{N}{2}))}{\pi(n - \frac{N}{2})}

    where fcf_c is the normalized cutoff frequency (0 < fcf_c < 0.5).

  2. Apply Hamming window:

    h[n]=hd[n]w[n]h[n] = h_d[n] \cdot w[n]
  3. Result: FIR high-pass filter with controlled sidelobes and smoother frequency transition.


Key Parameters

  • Cutoff Frequency fcf_c: Normalized to sampling rate (e.g., 0.3 means 0.3 * fs / 2).

  • Filter Length NN: Determines sharpness of the cutoff and computational cost.

  • Window Type: Hamming is used for its smooth spectral behavior.

Comparison of Windowed and Ideal Filters

Feature Ideal HPF  Hamming-Windowed HPF
Impulse Response       Infinite  Finite
Frequency Transition   Sharp (ideal)  Smooth (realistic)
Sidelobes   High (ripples)   Lowered (less leakage)

Illustrative Example: Design a High-Pass FIR Filter

Design goal: Block frequencies below 500 Hz and allow above.

Given:

  • Sampling rate fs=2000f_s = 2000 Hz

  • Cutoff fc=500f_c = 500 Hz → normalized fc=500/2000=0.25f_c = 500 / 2000 = 0.25

  • Filter length N=21N = 21

Steps:

  1. Compute the ideal high-pass filter hd[n]h_d[n] centered around n=10n = 10 (since N is odd).

  2. Generate the Hamming window w[n]w[n] of length 21.

  3. Multiply hd[n]w[n]h_d[n] \cdot w[n] element-wise to get the final FIR coefficients.

First few coefficients:

h[0] ≈ -0.013, h[1] ≈ -0.017, h[2] ≈ -0.022, ... h[10]0.894 (center), h[11] ≈ -0.022, ...

This filter now attenuates signals below 500 Hz and passes those above, with minimal distortion due to the Hamming window.


Here's the frequency response of the high-pass FIR filter using a Hamming window. You can clearly see that frequencies below 500 Hz are attenuated, while higher frequencies pass through, with a smooth transition around the cutoff due to the windowing effect. 

Comments

  1. Higher cutoff frequencies generally result in shorter impulse responses ?

    ReplyDelete
  2. The Hamming window provides around 53 dB side lobe attenuation.

    ReplyDelete


  3. The design is limited in achieving very sharp cutoffs without increasing the filter length.

    ReplyDelete
  4. FIR filters designed this way are inherently stable and easier to implement.

    ReplyDelete

Post a Comment