Introduction to Signal Processing
Signal processing is a fundamental discipline in electrical engineering and computer science that deals with the analysis, manipulation, and transformation of signals. This field plays a crucial role in various applications across industries, including audio processing, image enhancement, telecommunications, and medical imaging.
What is a Signal?
A signal is a function that conveys information about physical parameters such as temperature, pressure, voltage, current, flow rate, etc. It can be continuous (analog) or discrete (digital). In signal processing, we often represent signals mathematically using functions like:
- Continuous-time signals: f(t)
- Discrete-time signals: x[n]
Key Concepts in Signal Processing
Time Domain vs Frequency Domain
Signals can be analyzed in both time domain and frequency domain:
- Time domain: Represents how a signal changes over time
- Frequency domain: Represents the distribution of energy across different frequencies
Understanding both domains is essential for effective signal processing.
Linearity
Linearity is a fundamental property in signal processing. A system is linear if:
- It preserves scaling: y(ax) = ay(x)
- It preserves homogeneity: x(t) + y(t) → z(t) + w(t)
Understanding linearity helps in simplifying complex signal processing problems.
Stability
A system is stable if all its poles lie inside the unit circle in the s-plane. Stability ensures that the system output remains bounded for any finite input.
Causality
A causal system responds only to past and present inputs. This property is important in real-world applications where future inputs are unknown.
Signal Processing Techniques
Filtering
Filtering is one of the most common operations in signal processing. Filters remove unwanted frequencies or noise from signals.
Types of filters:
- Low-pass filter: Allows low frequencies, rejects high frequencies
- High-pass filter: Rejects low frequencies, allows high frequencies
- Band-pass filter: Allows a range of frequencies, rejects others
- Band-stop filter: Rejects a range of frequencies, allows others
Example: Implementing a Simple Low-Pass Filter Using Python
Here’s a basic example of how to implement a low-pass filter using Python with the scipy
library:
import numpy as np
import matplotlib.pyplot as plt
from scipy.signal import butter, filtfilt
# Function to create a low-pass filter
def low_pass_filter(data, cutoff_freq, sample_rate, order=5):
nyquist = 0.5 * sample_rate
normal_cutoff = cutoff_freq / nyquist
b, a = butter(order, normal_cutoff, btype='low', analog=False)
y = filtfilt(b, a, data)
return y
# Generate a sample signal
sample_rate = 1000 # Sampling rate in Hz
t = np.linspace(0, 1.0, sample_rate)
# Create a signal with high-frequency noise
signal = np.sin(2 * np.pi * 50 * t) + np.random.normal(0, 0.5, t.shape)
# Apply low-pass filter
cutoff_freq = 60 # Cut-off frequency in Hz
filtered_signal = low_pass_filter(signal, cutoff_freq, sample_rate)
# Plotting the original and filtered signals
plt.figure(figsize=(10, 6))
plt.subplot(2, 1, 1)
plt.plot(t, signal, label='Original Signal')
plt.title('Original Signal with Noise')
plt.xlabel('Time [s]')
plt.ylabel('Amplitude')
plt.grid()
plt.legend()
plt.subplot(2, 1, 2)
plt.plot(t, filtered_signal, label='Filtered Signal', color='orange')
plt.title('Low-Pass Filtered Signal')
plt.xlabel('Time [s]')
plt.ylabel('Amplitude')
plt.grid()
plt.legend()
plt.tight_layout()
plt.show()
In this example:
- A sample signal is generated, which combines a sine wave with some added noise.
- A low-pass filter is applied to the noisy signal, allowing lower frequencies to pass while attenuating the high-frequency noise.
- The original and filtered signals are plotted for comparison.
This example demonstrates how filtering can effectively clean up a signal, a common task in signal processing applications.