Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FFT Applications: Noise Removal, Note Detection & Image Filtering

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).

What It Does

  1. 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.
  2. 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.
  3. 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.

Files

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

How It Works

Noise Removal — Spectral Subtraction

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

Pitch Detection — Harmonic Product Spectrum

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₀.

Image Filtering — 2D FFT Low-Pass & High-Pass

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.

Usage

Live recording (requires microphone)

>> liverecord

Follow the prompts: first record ambient/fan noise, then record the signal (guitar note, voice, etc.).

Offline simulation

>> preload

Generates a random guitar note + synthetic fan noise, runs the full pipeline, and prints detection error against the known ground truth.

Image blur/sharpen

>> blur

A file picker opens — select any .jpg, .png, or .bmp image. The script displays the original, blurred, and sharpened versions side by side.

Example Output

Spectral Comparison HPS Detection Liverecord Detection Image Filtering

Requirements

  • MATLAB (tested on R2023a+)
  • Signal Processing Toolbox (for designfilt in liverecord.m / preload.m)
  • Image Processing Toolbox (for rgb2gray in blur.m)

License

MIT

About

MATLAB FFT applications: spectral-subtraction noise removal, harmonic product spectrum pitch detection, and frequency-domain image filtering

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages