Fourier Transforms – The Math Trick Behind MP3s, JPEGs, and Homer Simpson’s Face
1–10 of 105 posts
Re: Fourier Transforms – The Math Trick Behind MP3s, JPEGs, and Homer Simpson’s Face
#2The reason we can get away with throwing away low frequencies in JPEG is because humans are prone to notice significant details rather than tiny details.
High frequencies of a Fourier transform of an image == tiny detail (like being able to distinguish individual hairs)
Low frequencies of a Fourier transform of an image == huge details (like someone's face).
So you transform, set part of the result to zeroes, and compress. To display it you uncompress, transform back, and display it. The zeroes manifest themselves as an almost-imperceptible blur.
Re: Fourier Transforms – The Math Trick Behind MP3s, JPEGs, and Homer Simpson’s Face
#3Re: Fourier Transforms – The Math Trick Behind MP3s, JPEGs, and Homer Simpson’s Face
#4When you're talking about a digital signal, it is the sample rate that determines the maximum frequency you can represent. It's not MP3s that "throw out the really high notes" -- it's any digital signal. A discrete fourier transform actually is lossless, but it is bandwidth limited.
The reason audiophiles prefer Flac to MP3s, for instance, is because MP3s do more than just "throw out the high notes." Both are bandwidth limited, but MP3s also throw out other information based on psychoacoustic principles.
Re: Fourier Transforms – The Math Trick Behind MP3s, JPEGs, and Homer Simpson’s Face
#5Re: Fourier Transforms – The Math Trick Behind MP3s, JPEGs, and Homer Simpson’s Face
#6Re: Fourier Transforms – The Math Trick Behind MP3s, JPEGs, and Homer Simpson’s Face
#7EDIT: I mixed up high vs low frequencies, as the reply pointed out, so I've edited this to be correct now. The reason we can get away with throwing away low frequencies in JPEG is because humans are prone to notice significant details rather than tiny details. High frequencies of a Fourier transform of an image == tiny detail (like being able to distinguish individual hairs) Low frequencies of a Fourier transform of…
Re: Fourier Transforms – The Math Trick Behind MP3s, JPEGs, and Homer Simpson’s Face
#8This is a great post, but it's a little bit misleading when talking about MP3s and lossy compression and conflates analog fourier analysis with discrete analysis. When you're talking about a digital signal, it is the sample rate that determines the maximum frequency you can represent. It's not MP3s that "throw out the really high notes" -- it's any digital signal. A discrete fourier transform actually is lossless, bu…
Re: Fourier Transforms – The Math Trick Behind MP3s, JPEGs, and Homer Simpson’s Face
#9Hi Hacker News - I'm the author of the piece, also on twitter @aatishb. Look forward to hearing your thoughts. I encourage you to share your thoughts and insights with other readers by leaving a comment on the post, particularly if you know of other interesting applications about the Fourier transform. Cheers!
> The sound wave produced by a piano note is a simple sine wave.
No, it's not. A piano note is a complicated stack of overtones (some of which are harmonic and some of which aren't) and transients. If it was just a sine wave, it would sound like a sine wave and not like a piano.
This is part of why things like Shazam are so difficult: musical notes aren't just a single frequency in the FFT, they are a stack of them.
> You could just tell them a handful of numbers—the sizes of the different circles in the picture above.
This is actually the exact same number of numbers as in the time-domain series. Taking the FFT on its own doesn't reduce the amount of data, it's about discarding or compressing some of the frequencies after you do.
> The really high notes aren’t so important (our ears can barely hear them), so MP3s throw them out, resulting in added data compression.
This is only part of what MP3's do, and at high bitrates this really is inaudible. The main source of compression is that the precision of the numbers used to represent the amplitude of the sine waves is reduced.
When you have a loud sound and a quiet sound at the same time, the loud sound will "drown out" the quiet one (called "auditory masking"). You won't be able to hear the quiet one, or one be able to hear it precisely. MP3 and other audio codecs take advantage of that by encoding quieter frequencies with less fidelity when there are other louder frequencies at the same time. You don't notice the loss of precision since it's buried under louder sounds.
> Just as MP3s throw out the really high notes, JPEGs throw out the really tiny circles.
This is off too. If JPEG discarded high-frequency signals, you would just be blurring the entire image. It would be exactly like saving it scaled down and then scaling it back up with some smooth interpolation.
Obviously, JPEGs don't appear to be stretched out thumbnails, so that isn't what happens. Instead, it's not that high-frequency signals are discarded, it's that their precision is reduced.
Human eyes are quite good at detecting sharp edges and fine details. What they aren't good at is detecting how sharp an edge is. We can definitely see a break between two colors, but we can't accurately detect the magnitude of that the difference.
JPEG takes advantage of that by rounding off those high-frequency variances to nearby values. That means there are fewer possible values at high frequencies, so fewer bits are needed to encode them.
I realize I'm being a negative Nancy here. I really liked your post and I agree 100% on how awesome the Fourier transform is. It's also quite hard to describe it in an approachable way, and you've done an admirable job. I just get bugged when simplifications for a lay audience are actually off the mark.
Re: Fourier Transforms – The Math Trick Behind MP3s, JPEGs, and Homer Simpson’s Face
#10This is a great post, but it's a little bit misleading when talking about MP3s and lossy compression and conflates analog fourier analysis with discrete analysis. When you're talking about a digital signal, it is the sample rate that determines the maximum frequency you can represent. It's not MP3s that "throw out the really high notes" -- it's any digital signal. A discrete fourier transform actually is lossless, bu…
However, MP3s throw more high frequencies than the digital signal at that given sampling rate allows.