A small AI lab in public. Notes, tools, and experiments.

HomeFrequency Domain ResearchPhase vs Magnitude Showdown

🥊 Phase vs Magnitude Showdown

Discover which frequency component really controls image structure

🎯 What This Demo Reveals

This experiment shows one of the most surprising truths about images and the frequency domain: phase information dominates structure, while magnitude mainly controls brightness and contrast. This insight is crucial for understanding how diffusion models achieve global coherence so efficiently.

The Setup: We'll take two different images, swap their frequency components (magnitude and phase), and see what happens. The results will surprise you!

🎮 Interactive Experiment

Select two different images to see the phase/magnitude swap in action:

🖼️ Original Image A

Your first source image

🖼️ Original Image B

Your second source image

🔀 A's Magnitude + B's Phase

Result: Structure from Image B!

🔀 B's Magnitude + A's Phase

Result: Structure from Image A!

🤯 The Surprising Result

Phase dominates structure! The hybrid image inherits its structural layout from whichever image donated its phase information. The magnitude mainly affects brightness and local contrast, but the phase determines the spatial arrangement and recognizable patterns.

Try different combinations: Notice how the geometric structure, edges, and overall "shape" of the result follows the phase donor, even when the brightness patterns come from the magnitude donor.

📊 What's Happening Behind the Scenes

1 FFT Decomposition: We compute the Fast Fourier Transform of each image, splitting it into magnitude (how much of each frequency) and phase (where each frequency starts).
2 Component Swapping: We take the magnitude from one image and combine it with the phase from another image.
3 Inverse FFT: We convert back to the spatial domain to see the resulting hybrid image.
4 The Revelation: The phase information dominates what we perceive as the "structure" of the image.

🔮 Connection to the Diffusion Mystery

This phase dominance helps explain how diffusion models achieve global coherence efficiently. Research shows that:

While diffusion models don't explicitly work in frequency domain, they implicitly leverage the principle that structural coherence (phase-like information) can be managed separately from local details (magnitude-like information).

References:
[1] Song et al. "Score-Based Generative Modeling through Stochastic Differential Equations" ICLR 2021
[2] Ho et al. "Denoising Diffusion Probabilistic Models" NeurIPS 2020
[3] Rombach et al. "High-Resolution Image Synthesis with Latent Diffusion Models" CVPR 2022

💡 Key Implications