A MATLAB project demonstrating the Fast Fourier Transform across three domains: audio noise removal via spectral subtraction, musical pitch detection using the Harmonic Product Spectrum, and frequency-domain image sharpening/blurring.
Built as part of the Digital Signal Processing module at Vietnamese–German University (VGU).
- Noise removal — Removes fan/ambient noise from a guitar or voice recording using spectral subtraction with oversubtraction and a spectral floor to prevent musical noise artifacts.
- Pitch detection — Identifies the musical note being played/sung using the Harmonic Product Spectrum, which correctly finds the fundamental frequency even when upper harmonics are louder.
- Image filtering — Applies frequency-domain low-pass (blur) and high-pass (sharpen) filters to images using the 2D FFT, demonstrating how spatial frequencies map to visual detail.
| File | Description |
|---|---|
liverecord.m |
Records live audio via microphone (fan sample + signal), denoises, and detects the note |
preload.m |
Generates synthetic guitar + fan noise signals for offline testing and validation |
blur.m |
Loads an image, applies FFT-based low-pass blurring and high-pass sharpening |
Standard spectral subtraction (|Y| = max(|X| - |N|, 0)) clamps frequency bins to zero, creating spectral holes that produce ringing artifacts ("musical noise") after the inverse FFT.
This project uses an improved formulation:
|Y| = max(|X| - α|N|, β|X|)
- α = 2.0 (oversubtraction factor) — subtracts 2× the noise estimate for more aggressive removal
- β = 0.02 (spectral floor) — keeps every bin at ≥2% of its original magnitude, filling spectral holes with an inaudible residual so the phase reconstruction stays smooth
Simple max-peak detection fails when harmonics exceed the fundamental in magnitude (common with voice and real instruments at higher pitches).
HPS downsamples the magnitude spectrum by integer factors 2, 3, …, H and multiplies all versions together. The fundamental is the only frequency where harmonics at 2f, 3f, … all align after downsampling, so the product reliably peaks at f₀.
An image's 2D FFT maps spatial detail to frequency: low frequencies encode smooth gradients and large shapes, high frequencies encode edges and fine texture.
- Low-pass (blur): A circular mask of radius r zeroes out everything outside r in the frequency domain, removing fine detail. Smaller radius = stronger blur.
- High-pass (sharpen): The inverse mask keeps only high-frequency content (edges). Adding this back to the original emphasises detail.
>> liverecordFollow the prompts: first record ambient/fan noise, then record the signal (guitar note, voice, etc.).
>> preloadGenerates a random guitar note + synthetic fan noise, runs the full pipeline, and prints detection error against the known ground truth.
>> blurA file picker opens — select any .jpg, .png, or .bmp image. The script displays the original, blurred, and sharpened versions side by side.
- MATLAB (tested on R2023a+)
- Signal Processing Toolbox (for
designfiltinliverecord.m/preload.m) - Image Processing Toolbox (for
rgb2grayinblur.m)
MIT



