신호 처리(Signal Processing)는 아날로그 또는 디지털 신호를 분석, 변환, 합성하는 이론과 기술이다. 통신, 음향, 의료 영상, 레이더, 센서 데이터 처리의 핵심 기반이다.
신호의 분류
시간 영역:
연속 신호: x(t) - 아날로그 신호
이산 신호: x[n] - 디지털 샘플
주파수 영역:
주기 신호: 푸리에 급수로 분해
비주기 신호: 푸리에 변환으로 분석
결정론적 vs 확률적:
결정론: 완전히 예측 가능 (수학적 신호)
확률적: 노이즈 포함 실제 신호
푸리에 변환
python
import numpy as np
import matplotlib.pyplot as plt
# 복합 신호 생성 (440Hz + 880Hz + 노이즈)
sample_rate = 44100
t = np.linspace(0, 1, sample_rate)
signal = (
np.sin(2 * np.pi * 440 * t) + # A4 음
0.5 * np.sin(2 * np.pi * 880 * t) + # A5 음 (2배음)
0.1 * np.random.randn(len(t)) # 노이즈
)
# FFT
fft_result = np.fft.rfft(signal)
frequencies = np.fft.rfftfreq(len(signal), d=1/sample_rate)
magnitude = np.abs(fft_result)
# 피크 주파수 찾기
peak_indices = np.argsort(magnitude)[-5:][::-1]
for idx in peak_indices:
print(f"주파수: {frequencies[idx]:.1f} Hz, 크기: {magnitude[idx]:.1f}")
필터 설계
python
from scipy import signal as sp_signal
# 대역통과 필터 (300Hz ~ 3400Hz, 전화 음질)
low_cutoff = 300
high_cutoff = 3400
nyquist = sample_rate / 2
b, a = sp_signal.butter(
N=4,
Wn=[low_cutoff/nyquist, high_cutoff/nyquist],
btype='bandpass'
)
# 주파수 응답
freqs, response = sp_signal.freqz(b, a, fs=sample_rate)
# 필터 적용
filtered = sp_signal.filtfilt(b, a, signal)
관련 문서