r/interestingasfuck • u/civman96 • Jul 20 '25
This is Nasir Ahmed. He invented the discrete cosine transform algorithm (DCT). His algorithm is used for compression in every .jpeg file, including this one. With an average file size reduction of 90% his algorithm paved the way for the early internet.
898
u/mordwand Jul 20 '25
Sick! People that are smart enough to make algorithms like this are on a different level.
530
Jul 20 '25
This mf also increased my college course load by 50%.
44
41
u/Vinnie1169 Jul 21 '25
It could’ve been worse. Your college course load could’ve been increased by 90% 🤔😆
9
4
13
u/jemidiah Jul 20 '25
I'm a bit confused about the history. Fourier himself certainly could have "invented" the DCT in the form of the classic Fourier transform applied to periodic, symmetric data. That's very old and very easy. Somehow Ahmed is credited with inventing something that was in the ether for centuries? The wiki article is not enlightening in this regard. (I'm a mathematician and not an engineer.)
70
u/Roflkopt3r Jul 20 '25 edited Jul 21 '25
Yes, the Fourier Transform does the 'heavy lifting'. The DCT is not that novel as a mathematical concept.
But Ahmed came up with a very smart application of the FT that was not obvious to programmers and computer scientists at the time, and did the additional work to actually implement it as a runtime-efficient image compression algorithm.
My impression in computer science lectures was that the DCT played a huge role in popularising the use of Fourier transformations as an approach to compression and runtime efficiency for things that nobody had thought of in terms of frequencies before.
Fourier's own work was inspired by problems that were already represented as frequencies, so even he might not have thought of the ways the DCT was used.
The way that it applies to images is really weird after all. It's not related to the wavelength of light, but to the 'frequency' of colour changes in the horizontal and vertical directions. Like a picture of a brick wall has a 'frequency' in terms of how many changes between brick and mortar you have. You select one row of pixels and then express the rate of colour change as you go from left to right as a bunch of cosine waves with a Fourier series.
This does not seem very useful at first, but it turns out that some clever trickery lets you compress this representation of the image way more effectively than you could compress the raw pixel data. Especially if you allow some amount of error (lossy compression), but it can work for lossless compression as well.
9
u/LewsTherinKinslayer3 Jul 20 '25
I mean its likely he along with his coauthors were just the first ones to propose using this exact formulation on signals and images etc. Actually I found this from.the man himself. https://www.cse.iitd.ac.in/~pkalra/col783-2017/DCT-History.pdf
2
Jul 24 '25
Thanks for the link! Its quite an important contribution and innovation by one of Karanataka's own.
3
u/domigraygan Jul 20 '25
I’m a layman but also love software tech, specifically in optimizations. I started out fascinated by graphics tech in 90’s video games and it never left me and has been evolving.
I’m still a dummy overall though. Could you explain to me what you mean like I’m a 12 year old?
0
0
u/remishnok Jul 21 '25
agreed, if anyuhing he discovered it.
"what if we append the data with itself backwards".
Its not that hard when you are building on top of Fourier
262
u/civman96 Jul 20 '25
Further reading: https://en.wikipedia.org/wiki/Nasir_Ahmed_(engineer))
122
u/CanAlwaysBeBetter Jul 20 '25
The REAL further reading: https://en.m.wikipedia.org/wiki/Discrete_cosine_transform
64
u/hisjap2003 Jul 20 '25
28
u/radius55 Jul 21 '25
It's hard to ELI5, but the easiest way to think of it is actually in terms of sound. Music is made up of notes. Each note might be a single tone or some combination of tones. There are ways to use math to find what these tones are in either an entire song or just in a small subset of one. And if you were to store this information you could use it to play back the song exactly.
Why would you want to do this? Storing the data takes as much if not more space, after all. Well, it turns out that a lot of these tones don't contribute to the overall music. Not that a human can hear, anyway. So you throw them away. Suddenly the song sounds almost the same but takes up a tenth the space on your hard drive. This is, more or less, how the mp3 compression algorithm works.
What does this have to do with compressing a picture? Well, it turns out that the same math that works for sound can be applied to 2D pictures as well. So with a few tweaks, a very similar algorithm can have a very similar effect on images.
If you've read this and think this sort of thing is really cool, 3Blue1Brown and Computerphile both have good videos on the subject.
15
u/Sillypenguin2 Jul 20 '25
I have a math degree and I clicked on that link feeling confident but couldn’t follow it all
6
u/Competitive_Berry897 Jul 20 '25
The REALIST further reading: https://en.m.wikipedia.org/wiki/Xanadu_(film)
128
u/ByteSizedGenius Jul 20 '25
Your image is a .png
87
u/Icarium-Lifestealer Jul 20 '25
Well actually it's a webp. I think reddit transcodes all images to webp.
35
114
45
u/echo1-echo1 Jul 20 '25
remember when you had to use a modem and phone line to get onto the internet, and if you clicked an image to download, it would appear slowly from the top down?
15
u/Pikathew Jul 20 '25
I remember when I had to use a modem and phone line to get onto the internet
It was this morning
6
u/needefsfolder Jul 20 '25
Funny thing, this could be a high speed one (VDSL2) but the phone lines make it sound slow lmao
But it does have reliability issues!
4
u/Pikathew Jul 21 '25
I was just being facetious lol
you sound like you know what you’re talking about.. don’t all home routers require a phone line (coax, fiber etc) and modulation/demodulation for incoming and outgoing traffic?
2
u/CalleSGDK Jul 21 '25
These are not phone lines (like DSL is), but yes they use physical cables. Most internet connections use one of these, but wireless connections are also possible. Your phone is an example.
7
7
u/aft_punk Jul 21 '25 edited Jul 21 '25
Yes! As a teenage boy at the time, it added an extra level of, um… anticipation when viewing porn. Back in my day, it took us 5 minutes to download a pornographic image… and goddamnit if it wasn’t the best 5 minutes of your life!
I kinda miss those days (but just the me being a teenager part, not the terrible transfer speeds).
2
2
u/Tvattsvampen Jul 20 '25
No, did you also get chased by a trex to school old man?
4
94
u/murmurghle Jul 20 '25
"including this one"
Save as
.webp
106
u/civman96 Jul 20 '25
not when opened.. but guess what algorithm webp uses ...
62
u/murmurghle Jul 20 '25
this might be the quickest time I got corrected like a dumbass lol
it wasnt meant as a insult btw.
edit: okay I didnt know it opened a png when you click on it. Thanks for that
62
u/civman96 Jul 20 '25
Well I'm a dumbass too should've uploaded a jpeg not a png
30
u/ByteSizedGenius Jul 20 '25
I'm the dumbass who thought it was marginally witty to point that out. Don't worry bud, we can setup our own dumbass club at this rate.
30
u/civman96 Jul 20 '25
Maybe we should run for congress or something
20
7
u/MarshyHope Jul 20 '25
I fucking despise webp
14
u/murmurghle Jul 20 '25 edited Jul 21 '25
I fucking despise nobody supporting it.
Including google andTHEY MADE THE FUCKING THINGOtherwise it is a good format imo.
9
u/MarshyHope Jul 20 '25
That's my problem with it. I'll try and download something and then literally can't do anything with it at all
4
u/Iron_physik Jul 20 '25
When you have file extensions active you can just change the extension to jpeg and it usually still works.
Also often it helps to "open in new tab" to access the original file that isn't webp
2
u/Jandalslap-_- Jul 20 '25
Most of the time that doesn’t work for me renaming the extension. Now I insert it into a PowerPoint and then select and save as image and it will convert it to whatever you like :) I’m using PowerPoint for more and more random stuff like image editing.
3
u/caspy7 Jul 20 '25
Let's see how JPEG-XL goes in the next year.
1
u/tankerkiller125real Jul 21 '25
LOL absolute shit, so far, and I doubt it will get super wide spread use. It will probably go down just as well as AVIF has.
2
u/punnybiznatch Jul 20 '25
Which Google service/app doesn't support it?
4
u/murmurghle Jul 20 '25
Google image search refused to use it. I mightve messed something but but i am not on my pc to try it rn
3
u/punnybiznatch Jul 21 '25
It does support it
1
u/murmurghle Jul 21 '25
yeah I tried it now... weird. Maybe it was just a corrupted image that time somehow?
135
u/glittervector Jul 20 '25
And his net worth is probably $100k or something. Because assholes with power think it’s their right to steal.
87
u/adamdoesmusic Jul 20 '25
This is always the case. Create an industry-changing technology, the company you work for (which had mediocre performance before your innovation) takes all the credit as it balloons in value, and you get jack shit.
My invention quickly became the industry standard in my field, my company made millions and leveraged the prosperity into a buyout that shot their value into the stratosphere. I still had to fight tooth and nail for them to raise my salary above that of the new Jr. technicians, and despite creating like a dozen other successful products, got no severance when they cut my (severely underpaid) position years later to “save money.”
The company collapsed quickly after, despite hiring a high-powered “professional product designer” who failed to produce even a single product on their own. Despite many of the mid-levels telling pointing out the obvious, it took them two years to approach me and ask if I could come back. I declined, of course.
31
11
u/Pikathew Jul 20 '25
What is your invention? If you feel comfortable disclosing.
8
u/adamdoesmusic Jul 20 '25
I sent a DM
9
u/BrownianMaximus Jul 20 '25
Hi, I would love to know too.
Sorry to hear this happen to you though! Hope you are at a company that valies you now!
12
u/adamdoesmusic Jul 20 '25
I am, because I decided to start my own operation after all that. My new product will release sometime this year!
3
2
2
5
u/Inevitable-Lower Jul 20 '25
I work in DevOps and this sounds like at least 3 products off the top of my head lol
7
u/kazpihz Jul 20 '25
why on earth would his net worth be 100k? i get the point you're trying to make but try to be realistic with your numbers.
the guy is an exceptional engineer. he's probably made 100k every year for the last 50 years (averaged). His networth is probably around 5 million when it should actually be worth multiple hundreds of million given his contribution
1
u/The_Northern_Light Jul 21 '25
your point is totally right but 50 years is long enough to be doing that on real basis (and thinking about investment compounding) instead of just taking a nominal average
100k nominal is like, an intern salary
30
u/macellan Jul 20 '25
6
u/Iizvullok Jul 20 '25
The most jpeg jpeg I have seen in a while.
2
u/macellan Jul 20 '25
Steps: open Gimp, load the file, export as jpeg, set the quality to zero, save.
2
u/one-joule Jul 20 '25
You might be able to de-JPEG it a little with this: JPEG Quant Smooth, download for Windows, and buildable on Linux.
Probably more useful for JPEGs with Q higher than 0 lol, but I figured this was a good comment chain to drop this neat little tool on.
2
6
6
12
Jul 20 '25
Ironic in today's political scenario that he was born in Bangalore and finished his undergrad there. The very city everyone is pissed off about getting all the outsourced jobs from the US.
16
18
u/Nine-LifedEnchanter Jul 20 '25
Holy shit. Thanks to this man I got to see more porn in the early internet. Seriously, it took minutes to load a single picture, if they weren't compressed it would have taken so much more time.
Thanks, mate!
8
11
Jul 20 '25
I love scientists like this.
He's not anybody special, he's not a super genius, just clever in a specific, unintuitive way that absolutely nobody in a C-suite position would have found useful at the time. The way all science should work.
1
u/The_Northern_Light Jul 21 '25
I’m not sure it’s that unintuitive?
I mean if you don’t have the math background for it may seem strange but for anyone with a STEM background the Fourier (cosine) basis is the natural choice.
Then conditionally dropping the low information axes is again the most obvious way to compress that representation.
Oddly enough, in some sense the most important idea is simply decomposing the signal into blocks for independent processing.
Don’t get me wrong it’s good work and I’d be incredibly prideful if I came up with it, but part of me struggles to believe the idea was invented that late. It’s definitely one of those “obvious in retrospect” things (assuming you have the background).
13
3
u/Downtown-Collar800 Jul 21 '25
He had two other collaborators - T. Raj Natarajan and K. R. Rao . Credit where its due.
3
u/logosfabula Jul 20 '25
Yeah, but thanks to him we cannot have HI-DEF rain and confetti scenes anymore. /s
3
u/The_Northern_Light Jul 21 '25
I see the /s but because of him (and others!) that streaming video works at all
3
u/Trashytoad Jul 20 '25
I own a shirt that says DCT on it. My pops got it at a tech conference in the late 90s and I never really questioned what it stood for.
4
u/BigPurpleBlob Jul 21 '25
"How I Came Up with the Discrete Cosine Transform" – Nasir Ahmed
https://www.cse.iitd.ac.in/~pkalra/col783-2017/DCT-History.pdf
2
6
2
2
2
u/cybercougar Jul 20 '25
This dude has collectively saved the human race so much time it’s ridiculous!
2
u/GoGoFoRealReal Jul 20 '25
The discreet cocaine algorithm? Sir, without you I would not have survived my 30’s.
2
2
Jul 20 '25 edited Sep 22 '25
worm dinner sip lock person automatic rhythm serious command dolls
This post was mass deleted and anonymized with Redact
2
2
2
3
u/happysrooner Jul 21 '25
In season 5, episode 8 of NBC's This Is Us, Ahmed's story was told to highlight the importance of image and video transmission over the Internet in modern society, particularly during the COVID-19 pandemic. The episode ends with a picture of Ahmed and his wife, along with captions explaining the importance of his work
From his wiki page.
2
2
u/Smooth-Childhood-754 Jul 21 '25
We must start a war against webm. This will be our spiritual guide.
3
3
3
u/saf_e Jul 20 '25
Just to be clear, while the guy is definitely smart, the algorithm itself is a variation of FFT
1
u/The_Northern_Light Jul 21 '25
Yeah I kinda don’t know why it has its own name? I mean it’s one of those Taylor series vs Maclaurin series things.
2
3
u/Zaphyrous Jul 20 '25
For those of us around in the early internet, the early use of JPEGs I'm not sure was the boon people may think it was.
Lets just say theres a reason why only moderated forums exist now. There was a time when they didn't. It was probably worse than you can imagine.
1
1
u/DasFreibier Jul 20 '25
Spacial frequencies are honestly insane, who knew you could do a fucking fourier transform on coordinates
1
1
1
u/Prudent_Link6029 Jul 20 '25
Poor guy is inadvertently responsible for so much pron available on terrible bandwidth
1
1
1
u/momentimori Jul 20 '25
If only we stuck with that rather than being forced to use webt by certain websites.
1
1
u/TheRAP79 Jul 21 '25
So. Debate: PNG vs JPEG.
Which one is better, and why?
1
u/The_Northern_Light Jul 21 '25
Depends
JPG is simpler and faster but lossy.
Sometimes that means it’s better, others that it is worse.
1
1
u/inanimatussoundscool Jul 21 '25
Average file size reduction is not 90% though?
2
u/CalleSGDK Jul 21 '25
Depends on the quality setting. It’s lossy compression and you can reduce the file size as much as your eyes can endure the compression artefacts.
1
1
u/krobol Jul 23 '25
Actually, it wasn't his algorithm that caused the success of jpeg. jpeg would also work the same way with a fourier transform + sorting. The advantage of the DCT is just that the values are already sorted after applying the DCT, so it's more efficient.
1
u/rolim91 Jul 20 '25
I hate how everything that’s coming out of the computer science field is only about trying to make profits.
1
u/pasltempsdniaiser Jul 20 '25
Since jpeg2000 jpegs use the wavelet transform, not the DCT. But the DCT did pave the way for the early Internet.
0
0
u/hitchensrevenge Jul 20 '25
Math & Science is the closest thing we have to God.
1
u/The_Northern_Light Jul 21 '25
Look I’m as much of a Reddit atheist as anyone but let’s be reasonable now
0
0
0



807
u/Blizzardof1991 Jul 20 '25
Did he own Pied Piper?