Frequency analysis of images using the 2D Fourier Transform: decomposition, filtering, and reconstruction of an Earth image through sinusoidal components.
- Overview
- Mathematical Concepts
- Project Structure
- Notebook Content
- Results & Interpretations
- Real-World Applications
- Key Formulas
- How to Run
- Dependencies
This project explores the 2D Fourier Transform (FT2D) and its applications to digital image processing. Through two progressive exercises, we analyze the decomposition of images into frequency components (sinusoids) and their reconstruction via the Inverse Fourier Transform (IFT).
The reference image used throughout the project is a photograph of the Earth (Earth.png), converted to grayscale for analysis.
| Concept | Description |
|---|---|
| 2D Fourier Transform | Decomposes an image into spatial frequencies |
| Inverse Fourier Transform | Reconstructs the image from its frequency components |
| Sinusoidal grating | 2D pattern whose amplitude varies sinusoidally |
| Amplitude | Contrast between light and dark regions of the grating |
| Phase | Lateral shift of the sinusoidal signal |
| Spatial frequency | Number of cycles per unit distance in the image |
| Point pairs (FT2D) | Symmetric points in Fourier space representing a sinusoid |
| fftshift | Recenters the Fourier spectrum around low frequencies |
projet-OMI-transformee-fourier/
β
βββ notebooks/ # Jupyter / Colab notebooks
β βββ PROJET_OMI.ipynb # Main notebook (Google Colab)
β
βββ images/ # Reference images
β βββ Earth.png # Earth image used in the project
β
βββ docs/ # Additional documentation
β βββ rapport.md # Supplementary notes and explanations
β
βββ .gitignore # Files ignored by Git
βββ requirements.txt # Python dependencies
βββ README.md # Project documentation
Generates an interactive 2D sinusoidal grating with sliders to vary in real time:
- Amplitude (0.1 to 50) β controls image contrast
- Phase (-Ο to Ο) β controls lateral shift of the grating
Key observations:
| Parameter | Effect |
|---|---|
| High amplitude (e.g., 50) | Strong contrast, distinct black and white bands |
| Low amplitude (e.g., 0.1) | Nearly all-black image, total loss of contrast |
| Increasing phase | Grating shifts to the left |
| Decreasing phase | Grating shifts to the right |
This exercise proceeds through five progressive steps:
Earth.png (RGB)
β
βΌ
ββββββββββββββββββββββββ
β Step 1: Load & ββββ Convert to grayscale (np.mean on RGB)
β Convert Image β
ββββββββββββ¬ββββββββββββ
β
βΌ
ββββββββββββββββββββββββ
β Step 2: Compute ββββ np.fft.fft2 + fftshift
β 2D Fourier Transform β Log-scale spectrum display
ββββββββββββ¬ββββββββββββ
β
βΌ
ββββββββββββββββββββββββ
β Step 3: Identify ββββ Sort frequencies by amplitude
β Point Pairs β Identify dominant sinusoidal components
ββββββββββββ¬ββββββββββββ
β
βΌ
ββββββββββββββββββββββββ
β Step 4: Iterative ββββ IFT per pair, cumulative reconstruction
β IFT Reconstruction β Observe progressive image formation
ββββββββββββ¬ββββββββββββ
β
βΌ
ββββββββββββββββββββββββ
β Step 5: Frequency ββββ Reconstruct using % of frequencies
β Percentage Filtering β Compare low vs high frequency content
ββββββββββββββββββββββββ
Step 1 β Image Loading & Conversion:
Upload Earth.png into Google Colab, convert to grayscale using np.mean across RGB channels.
Step 2 β 2D Fourier Transform:
Compute FT2D with np.fft.fft2, apply np.fft.fftshift to recenter the spectrum, and display in logarithmic scale (np.log(abs(...))) to visualize frequencies.
Step 3 β Point Pair Identification: Point pairs in the Fourier spectrum represent sinusoidal waves in the image. Frequencies are sorted by decreasing amplitude to identify the most significant components.
Step 4 β Iterative IFT Reconstruction: For each frequency pair, apply the Inverse Fourier Transform and accumulate sinusoids one by one to progressively reconstruct the image.
Step 5 β Frequency Percentage Filtering: Reconstruct the image using only a percentage of available frequencies:
| Frequencies Used | Result |
|---|---|
| 100% | Identical to the original image |
| 10% lowest | Still recognizable (low freq = global contours) |
| 10% highest | Grayish image (high freq = fine details, little useful info) |
In the FT2D, each symmetric pair of points corresponds to a 2D sinusoidal wave in the image. By modulating the amplitude, phase, and frequency of these waves, then applying the IFT, we can:
- Reconstruct the original image
- Filter specific frequencies (compression, denoising)
- Analyze the frequency structure of the image
| Frequencies | Content | Effect on Image |
|---|---|---|
| Low frequencies | Global shapes, main contours | Image recognizable even with few |
| High frequencies | Fine details, textures, noise | Weak contribution but needed for sharpness |
The Fourier Transform is a fundamental mathematical tool used across many fields:
| Domain | Application |
|---|---|
| Signal Processing | Filtering, spectral analysis |
| Image Processing | JPEG compression, edge detection |
| Medicine | MRI (Magnetic Resonance Imaging), CT scanners |
| Telecommunications | Signal modulation, WiFi, 4G/5G |
| Astronomy | Light and radio wave analysis |
| Quantum Computing | Shor's algorithm for factorization |
Where:
- A = amplitude
- f_x, f_y = spatial frequencies in x and y
- Ο = phase
- Open the notebook in Colab
- Click "Runtime" β "Run all"
- When the
files.upload()cell executes, upload theEarth.pngfile
Prerequisites: Python 3.8+, pip
# 1. Clone the repository
git clone https://github.com/YOUR_USERNAME/projet-OMI-transformee-fourier.git
cd projet-OMI-transformee-fourier
# 2. Install dependencies
pip install numpy matplotlib ipywidgets jupyter
# 3. Launch Jupyter
jupyter notebook notebooks/PROJET_OMI.ipynb
β οΈ For local execution, replace thefrom google.colab import filesandfiles.upload()lines with:image_filename = "../images/Earth.png"
| Library | Purpose |
|---|---|
numpy |
Numerical computing, FFT (np.fft) |
matplotlib |
Image display and plotting |
ipywidgets |
Interactive sliders (amplitude, phase) |
google.colab |
File upload (Colab only) |