0
0
RosConceptBeginner · 3 min read

Anti Aliasing Filter: Definition, How It Works, and Examples

An anti aliasing filter is a filter used before sampling a signal to remove high-frequency components that can cause distortion called aliasing. It ensures the sampled signal accurately represents the original by limiting frequencies above half the sampling rate.
⚙️

How It Works

Imagine you want to take a photo of a spinning wheel. If the wheel spins too fast, the photo might show strange patterns or the wheel appearing to spin backward. This happens because the camera's shutter speed can't capture the fast motion correctly. Similarly, when converting a continuous signal into digital form by sampling, high-frequency parts can create confusing patterns called aliasing.

An anti aliasing filter acts like a slow shutter speed for signals. It smooths out or removes the fast changes (high frequencies) before sampling. This way, the digital version keeps the true shape of the original signal without weird distortions.

💻

Example

This example shows how to apply a simple low-pass filter as an anti aliasing filter before sampling a signal with high-frequency noise.
python
import numpy as np
import matplotlib.pyplot as plt
from scipy.signal import butter, filtfilt

# Create a signal with two frequencies: 5 Hz and 50 Hz
fs = 200  # Sampling frequency in Hz
T = 1.0   # Duration in seconds
t = np.linspace(0, T, int(fs*T), endpoint=False)
signal = np.sin(2*np.pi*5*t) + 0.5*np.sin(2*np.pi*50*t)

# Design a low-pass Butterworth filter to remove frequencies above 10 Hz
cutoff = 10  # Cutoff frequency in Hz
b, a = butter(4, cutoff / (0.5 * fs), btype='low')
filtered_signal = filtfilt(b, a, signal)

# Plot original and filtered signals
plt.figure(figsize=(10, 4))
plt.plot(t, signal, label='Original Signal')
plt.plot(t, filtered_signal, label='Filtered Signal (Anti Aliasing)')
plt.xlabel('Time [seconds]')
plt.ylabel('Amplitude')
plt.legend()
plt.title('Anti Aliasing Filter Example')
plt.grid(True)
plt.show()
Output
A plot showing two lines: the original signal with fast oscillations and the filtered signal with smooth, slower oscillations.
🎯

When to Use

Use an anti aliasing filter whenever you convert a continuous signal to digital by sampling. This is common in audio recording, image processing, and sensor data collection. Without it, high-frequency noise or details can create false patterns that confuse analysis or playback.

For example, in audio, it prevents high-pitched sounds from turning into strange low-pitched noises after recording. In images, it avoids jagged edges or moiré patterns when scanning or resizing.

Key Points

  • An anti aliasing filter removes frequencies above half the sampling rate (Nyquist frequency).
  • It prevents aliasing, which causes distortion in digital signals.
  • Usually implemented as a low-pass filter before sampling.
  • Essential in audio, video, and sensor data digitization.

Key Takeaways

An anti aliasing filter removes high frequencies to prevent distortion during sampling.
It works by smoothing the signal before converting it to digital form.
Use it in any system that samples continuous signals to keep data accurate.
Typically implemented as a low-pass filter cutting off frequencies above half the sampling rate.