Little secret of JPEG: It actually supports two entropy coders. Huffman coding, and arithmetic coding. The arithmetic coding is superior in performance, and yet almost never used and supported by almost no software. The reason for this is historical: Back when JPEG was new, arithmetic coding was subject to multiple patents. Mostly held by IBM, but not all. That made it very difficult for any program to use arithmetic coding legally, so all the early JPEG implementations were huffman-only. Once the patents expired, it became the classic chicken-and-egg problem: No-one wants to make software that saves jpegs with arithmetic coding because all of the existing software wouldn't be able to display them, and no-one has a reason to make their software able to display arithmetic-coded JPEG because there are none in use to display. So even up to today, we are all using JPEG in the low-performance mode. If it were practical to use the arithmetic option, JPEG files could be about 10% smaller while still maintaining exactly the same quality.
Yes, this is a great tidbit of history that most people don't know! Fun fact you may already know: in video codecs such as H.264 and H.265, where compression ratios are really important in terms of saving bandwidth, most entropy based encoding is based on context-adaptive binary arithmetic coding (CABAC). The improvements of arithmetic coding vs Huffman coding were enough of an incentive for most developers of video codecs to implement this logic in both the encoding and decoding side.
@pyropulse Looks like one to me. A circular dependency: No one will use a feature that has no software support, and no-one will make software to support a feature that is never used. The problem cannot be solved because of a condition that can only be altered by solving the problem.
@@katiebarber407 no, serenity is a different project to temple os. If temple os feels like an 80s os, serenity feels like a 90s os. It's basically a Unix style system with a windows 95 style desktop environment
I did a degree in electrical/computer engineering. This is BY FAR one of the best explanations I've seen about this. Doing the math is nothing compared to the understanding this video gives you. Thank you!
I agree. One thing I would have added though, is why we used sine instead of cosine. But perhaps if this is of interest to you, then you already know the answer why😉
If you've ever studied differential equations or Fourier series in general as a mathematics student, then the concepts also make a lot more sense intuitively than I expect they might as an EE student alone. 3Blue1Brown has some great videos on this.
Other interesting compression algorithms for people to look up: - Opus, the successor to MP3/AAC that powers audio on the internet these days. - QOI, an amazingly fast and simple to understand image format (1-page specification!) - JPEG XL, the cutting-edge expansion of the original JPEG format shown in this brilliant video :-)
@@Dorumin It could be though. Opus performs really well at any bitrate, though it does excel especially at the low end. Outperforming MP3 isn't that impressive a performance though. There are lots of codecs that can make that claim. MP3 is just /old/.
I'm going to have to agree with the discussion above. Opus isn't a successor to MP3/AAC. AAC is reasonably considered a successor to MP3, but Opus is more of a peer to AAC.
@@Reducible qhy is only one coefficient in dct output if most of the cosine wave values were positive? Since the others were too low? But youd think some would still be positive and just lower positive value, no?
It should probably be phased out, really. JPEG's compression was cutting-edge when it came out, in 1992. There have many several attempt to replace it since then with more sophisticated compression that can achieve higher quality for the same size, but they've all failed because they can't compete with JPEG's universal support. The latest is WebP, which is making some progress because it has the giant of Google to promote it. JPEG2000 was a big flop. Though amusingly to me, every web browser today /does/ support it sort-of... not as a JPEG2000 file, but because it's one of the image compression methods supported within PDF files.
All/most of the image formats that followed are based on the basic idea of stacking waves, and even more so for the video formats. So in a way you are already paying homage to this genius design by watching this video! The JPEG people didn’t stop working on pictures after good ol’ JPEG either. Their latest JPEG XL comes with tricks to make it much more efficient in terms of beauty/fidelity-per-bit. It is able to go toe to toe with video-based image formats like HEIC, AV1F in terms of efficiency while staying easy on the CPU to encode and decode.
This was *really* good. Well paced, well explained with great visuals. I have a much greater appreciation for what JPEGs do now. I'd love to see a video outlining some of the other various transformations used in signal processing or some more neat applications of them!
It is no exaggeration to say that the quality of this video's presentation of the subject is beyond superb. Utterly fascinating and presented with outstanding clarity and insight. Left me wanting more, more, more of this content, please! Thank you for the effort and care you put into its creation.
This is one of the best videos I have seen about how the Fourier Transform is used in JPG compression . The amount of effort, time and money put into it is incredible. Thank you for sharing.
Thank you for this! I've watched and read many explanations of JPEG and they all talk about the DCT like that is the part that makes JPEGs smaller. Your video finally made it clear that the DCT doesn't reduce the size of the data, but does put it in a form where the less important information is easier to identify and remove, and why its okay to get rid of the high frequency content. The explanation is great and the visualizations were clear and helped a lot. Excellent work!
I always knew jpeg has got some interesting maths going behind the scenes, but man, this is like super impressive. And it actually sounds like a great coding challenge to create an actually functioning jpeg encoder/decoder Btw I can't admit the quality of the work done to bring this video to us, I just love it. Thank you a lot for what you are doing, your videos are fascinating as always
I remember coding the DCT/IDCT functions in Borland Pascal two decades ago... it was a day of work - not full JPEG scheme, just playing with the coefficient (e.g. erasing them a seeing what it does) but quite some fun
I imagine it's not a good coding challenge, since there's not much elegancy you can bring here, often coding math-related stuff is tiresome and ugly, unless you use languages like Julia.
@@comradepeter87 Well although this might actually be very true for someone, I personally feel kind of ok with coding applied math stuff. After all, coding a JPEG encoder/decoder is not only about coding a math part of it, it's also about engineering a software because that's what we, as programmers, do
I would just like to take the time and say; Thank you for making these. As a mathematical engineer, I really appreciate these type of videos, which go into something that is extremely interesting, but I don't have time to explore myself.
As a designer, I very often go through these concepts and therms without the understanding of what they actually mean. And I have to say it, this video has already helped me in an artistic experiment that translates image to audio. Beautiful work, thank you!
This video is by far one of the best explained video on JEPEG compression. Not only this video presents intuitive explanation but also puts the right amount of mathematical details for any brain to comprehend. Kudos!!
I appreciate how this video gives great length to the broad overview of compression, and then very quickly runs through specific details about the jpeg system... Very meta
What I find incredible about this excellent video is that it helped me understand something I never expected to find here. I’m currently in an Electrical Engineering program, and for months, I’ve had a very limited understanding of the Fourier series concept we covered a few months back. The way you explained the DCT so clearly and concisely somehow crystallized the concept in my head. I deeply envy your ability to keep an audience so engaged with all this math I previously thought boring. Thank you so much for the well done video!
You, sir, managed to hit all your goals, in my humble opinion: a very clear explanation of a fairly complex algorithmic pipeline, very visual examples/demos, and inspiring awe of how people can be immensely creative to problem-solve. 11/10, GREAT video!
I did a degree in Electrical Engineering but I do software engineering and this video is awesome! I love the visualizations and the explanations of signal processing concepts. If they taught signal processing like this in school I would've been MUCH more interested! Really well done!
I’m out of words for the quality of this content. Really, wtf is happening. How can this be free and always available knowledge? I’m a chemical engineer btw, I will probably have no use for this ever in my life but I’m deeply interested, specially on the math part. I just love the internet man. You sir are a hero.
I know some basic computer science, but this is way over my head. I finished the video with amazement of how complex a JPEG compression method work, even though I don't like the nature of blocky image stuff, but still impressed. Thank you.
32:14 There's also the progressive stuff like spectral selection and successive approximation that also break every assumption of your logic and makes you question why you even want to write your own JPEG decoder.
This reminds me of the way it felt when I first saw 3blue1brown‘s video showing how the Fourier transform works. I *got it*. It was miraculous. Reducible, you‘re up there with the best of them.
I've been working with multimedia encoders and decoders for most of my professional life, and I've watched many videos that try to explain what is going on behind the scenes. This is the first video I've seen that touches important technical details like chroma subsampling 4:2:0, which is literally the second thing any decoding software like FFmpeg will report to you, right after the encoder (e.g. H.264). Good job.
I’m usually not a huge fan of JPEGs and prefer highly compressed PNGs but this video made me respect the file format more. I’m mind blown by how cleverly designed this is.
When people ask if a computer science degree makes any sense in the modern world I should point them to this video. I don’t have a degree myself and work in web development, and I never ever come across a problem as localized and deep as this. Makes me think about going back to school honestly. The hardest problems I need to solve, while definitely difficult, is always about managing lots of data, managing lots of network failures, managing large code bases, managing race conditions and synchronization issues, it’s all just trying to solve these large, messy code management problems. No doubt, there are thousands of people in web development working on really deep problems like this, but they’re all working for the big 5 and making large sums of money for it. Most developers in my field just don’t need to interact with code as a mathematical problem. The math has been solved, the tools have been built, and we need to figure out how to use them as best we can. It’s definitely a different job entirely.
Most of the things people interact with nowadays during their typical day is brought to you by electrical engineering and computer science. The fact that people take this for granted is a compliment to the fields, albeit can be frustrating at times. This also applies to many other fields of science, including chemistry, biology, math, physics, and all fields composed of those base sciences. Just think about the things you use, own, and touch, all created because of material science bred from those sciences.
Such an amazing explanation!! as someone who started to watch the video without any information about the topic, but still understood everything in detail, I must say this was a great video
This is a great explanation, we actually implemented a simplified image decompressor with an image format based on JPEG but without 2D downsampling and without huffman decoding on an FPGA in undergrad.
These same concepts (run-length encoding, bandwidth compression) work pretty well with radar images as well for certain classes of radars. Some radar signals need to be captured, compressed, transmitted over long distances, and reconstructed to its original form (warts and all) for further processing. Thinking of an image as a signal processing problem is very logical. Excellent video.
You clarified a lot of the math involved in JPEG compression so that now I think I understand it, or at least the most important parts. Great explanation!
I work for years in JPEG decoding IP, especially in Huffman Decoding Algorithm. and swear that JPEG is wonderful. other little secret is JPEG also has "Head" which contain information for decoding purpose while still maintain the entire file in small size. and JPEG Header Analyze is also a very interesting topic. I hope I could watch this video in my early year of my career in JPEG codec. I just refer this video nowadays for other people who ask me about the JPEG.
You sir, just earned a new sub, absolutely brilliant content quality! I'm loving how many new channels are adapting the 3blue1brown style of teaching, I honestly find these videos so clear I'm learning faster than I've ever before!
I’ve actually been studying a lot of control theory and signal processing on my own time, continuous and discrete. The moment you said to look at the brightness component, and how if you move along it it’s like a signal in a way, I put my phone down and went “Oh. My. GOD.” I immediately knew exactly what was about to happen: pick out the lower frequencies and just store those, and reconstruct the signal later. That is absolutely INCREDIBLE. Incredible video. I’m also very proud of myself for recognizing that so naturally
I added this to watch later and really wanted to watch it after work. But I was hooked, I couldn't stop the video even if I wanted to. Awesome video and amazing engagement!
Not only the content of the video is interesting and well explained, but also the animations are incredible. I dream of one day being 10% as good as you are with Manim.
It is incredible how complex and thought through technology is that we use without thinking about it. This video Really makes you appreciate the hard work and genius ideas that have been put into what we use today. It always amazes me to understand and learn how things work. Thank you for explaining it.
This is a excellent video, I really appreciate your putting so much effort into both covering the actual math and also giving a visual run-through of it's implications. So often this stuff is explained with a page of equations and maybe single figure of featuring the DCT 2D basis functions. This was way better than that! This is a great example of how a well-done video with good illustrations and animations can explain concepts way better than a text book can, though at the cost of making it much harder to skim ahead when part of the information presented was already understood.
I've been lurking around DFT/FFT explanations for the past couple of days, both in your channel and 3b1b including some others, I understood many underlined concepts but why cosine functions itself pull out the contribution info out of the input was mystery, this video solved it for me on that vector similarity based on dot product part. I was blown away by the simplicity of the concept. Next I plan to check more on orthogonality. Great video as well, mate! My utmost respect!
your explanation and quality of video is so amazing. It really reflects the amount of hardwork you have committed for this cause. Thanks a lot for your service to humanity,
This topic has been honestly stuck in my head for so long, but I found no content satisfying my need to learn it until now!! this has been greatly explained, awesome job!
So pixel art as PNG and photographs as JPEG. Got it. Also it's so cool to see easily graspable applications for vector and matrix mathematics like this.
Thank you for such wonderful visuals. Even though I honestly don't get all these concepts at all, I find it super interesting to watch these concepts explained visually. I hope this video will be a vital complement to my upcoming signal processing course.
Thanks for this. How video compression actually works is something thats not easy to explain to most people. I can certainly see my self referring people to this video instead of trying to explain it myself. You've done a much better job explaining it than I could have.
Holy crap, that was a ride. I knew JPEG used DCTs and I did dabble in signal compression a bit back, but the other details putting it all together was very illuminating. ngl I was not expecting that the JPEG quality slider I see in some software is actually from a set of quantization tables set by standard. Or that stuff like Huffman coding was used to clean up after eliminating the high frequencies.
Perception is such a massively important field in IT. This is why they teach cognitive psychology as part of a software engineering degree (or at least they did when I studied).
It depends on what exactly you're majoring in. Computer science and software engineering are vast fields. I touched on those things because I liked doing usability stuff, but I could just as easily have avoided if I hadn't.
Theoretically, you have to give up some efficiency in order to compress any sort of information. The difficult part is about by keeping the data as original or comprehensible as possible, how much would you give up. But yeah, nowadays we have bigger and cheaper digital storage, so the problem of jpg is gradually getting noticed.
There are better alternatives to DCT available nowadays. For example, JPEG2000 uses wavelets: when you push the compression too far on these, instead of getting blocky like DCT, they become fuzzy, which is generally less objectionable.
There are some terrifyingly brilliant people in this world that will never get the recognition they deserve, all because they refuse to make clowns of themselves.
Great video, I never took the time to understand the jpeg algorithm but this video really explains it efficiently, with relevant illustrations. Well done ! The only remark I would make is about the curve you plot on the frequency coefficients (when you explain the DCT). I think it kills the idea that it is a discrete sequence of coefficients. The interpolating values have absolutely no meaning, whereas the curve on the left (the signal) is relevant because it represents the "real" signal that was sampled.
Yeah, very good point! Now that I think about it, you are right. I think I wanted some visual symmetry when I made it, but truth be told, it serves no purpose. Sometimes, when you are so deep into a project, you can forget how something so superficial can possibly lead to some confusion. Thanks for the feedback!
It's not only a discrete sequence (as the sequence of samples would be), but it's still discrete when you consider the extension to continuous signals. On the time domain you can interpolate using the cosines. Thus, on the left side I think the continuous line is helpful. In the frequency domain, you would still see discrete delta impulses, because the dct requires (assumes) your signal to be periodic. Other than that, great video! Thanks
@@Reducible I think the continuous line does serve some purpose. It makes it easier to understand why the discrete values are the way they are when you slowly shift the frequency between integers.
Though the interpolating values have no meaning, they serve as a reminder that cosines are in fact, continuous and not discrete. Also the signal transformation is better to visualize and understand with this in mind. This is ultimately what the step of quantization gets rid of, as it samples this continuous interval back to discrete space. In my mind it was definitely not in vain to have it included and visualized.
@@Reducible I think one problem is that it's a bit hard to spot the actual coefficient points because they're the same colour as the curve, which is why making the curve less bright is a valid solution.
This is extremly amazing! I loved the technology, the maths, the cleverness, the explanation. This one of the best ways I have invest my time in weeks. Thank you for this video!!
As someone who hasn't touched math since High School "special needs" classes, it's insane how intuitive you made this. Of course I don't understand some stuff like *how* a signal gets transformed with a DCT in the middle of the video and why the transformed values get so weird at a first glance, but otherwise... I've got a vague understanding of how this works now, even how you can use a collection of "fixed" cosine waves to roughly represent values. And I can see how the large-scale luma / chroma simplification leads to the sort of splotchy patches you see in heavily compressed JPEGs.
This is also the first time for me to know about that transformation. If you have a line with an angle with x axis, its projection on x axis represents how much it is not so steep right. Consider extreme case, a horizontal line, its projection on x axis is itself (a non zero value), its projection on y axis is zero, so we knew that it somehow align with x axis. Same here we are not projecting on x and y axis, but projecting on cosine! We need to know how much our signal resembles or look similar to cosine wave of certain frequency so we multiply the samples of our signal by samples from that cosine wave and sum them. If they align well, the multiplications will be all positive and sum of positive is positive. If they dont align well, some multiplications will be positive and some are negative, there sum are small. If signal is just a cos x, then multiplying with cos x and summing give a number, if we multiplied it with cos 2x, the sum will be zero. So we knew that our signal contained a large component of frequency of 1 (in this example it is the only component). In other signals, it is not clear whst cosines are in our signal, so we do that operation and from the result we know which frequencies and how much they algin (exist) in our signal. It is just a projection and the summation or integration.
Your videos are really great. Your delivery is quite simple to 3blue1brown. I mean that as a complement. You take time to explain things very clearly, your cadence is rhythmic, and your voice is pleasing to the ears.
As a pixel artist, I admit that I somehow hate JPEG, mostly because of its qualities. It's a lossy image format that is decent at what it does in most cases. The main issue is that pixel art is one of these rare cases where JPEG is the worst option; it's only sharp and sudden transition from one pixel to another in terms of colour or contrast, just what JPEG "hates". A lot of websites automatically convert your image into JPEG if it's not animated or not transparent; which can absolutely ruins your work. So there is this old trick of leaving a single pixel transparent on your image to keep it as a PNG instead. So, now I still hate JPEG, but at least I understand a bit more why.
It's annoying that everything is forced through lossy photo compression, especially when pixel art is already so insanely compressible. A detailed 320x240 32-color piece can be 20KB, but it must be upscaled and converted to a fuzzy JPEG that's an order of magnitude larger than the original.
Lossy encoders were designed with mainstream usage in mind. You, as a professional with strict requirements and technical knowledge, are responsible to find another medium and suitable file format to carry your information. Although JPEG was somewhat forced onto Internet users as digital hardware and software grew in usability and prevalence, there was never a point in computer history when you couldn't use a lossless format or find another lossless workaround, mostly because raw solutions are FAR EASIER to implement and far more robust and cost effective, and rarely have anything to do with fashion or industry trends. I am a DTP professional and a graphic designer from the early 90's, I still remember IFF and PCX file formats on the Amiga. Don't mingle 'technology for the masses' with the 'technology as is'. Since the 2000's I remember people were struggling to find a good carrier for print-ready photography in certain workflows. TIFFs with ZIP compression were widely available and offered a superior lossless compression both in CMYK and RGB. We also had EPS DCS2 which would natively store grayscale color separations for high-resolution film development. Video and audio were something else due to monstrous demands on the memory for the time, but pixel art? Man. It all started from indexed palettes and simple pixel art. Why would it ever devolve into media intended for megapixels and high-freq noise? Vector graphics took more than 10 years to develop fully and it's still quite a niche technique if we look outside the DTP, but pixel art was there from the very beginning. Though, to be fair, I remember one historical gap. It was thanks to the holders of the LZW patent (used by GIF) on one side, and thanks to Apple pushing for high color palettes on the other, and so the browsers were caught between a rock and a hard place, but only browsers! It was some time before CompuServe finally got PNGs running throughout the ecosystem, in the late 90's. Though Microsoft always had the Bitmap format, the most native thing one can imagine, but it was completely discouraged on the Internet. In any case, since the 2000's, *having* to use JPEGs for anything it wasn't made for (high-res photos and common image interchange), was definitely not a thing if it ever was. Whoever had to mess around with upscaled JPEGs was someone who figured out stuff very wrongly.
That's because pixel art is pretty much the opposite of natural vision. It's also the reason why you can never use chroma subsampling on a PC monitor (it will screw up the GUI and text) and why desktop recordings without zoom look so horrible.
29:00 well this is clever, I thought you'd just store the matrix of the DCT and then change everything but the top right to zeros, but the actual way means that if this block has a lot of higher frequency signals, it is retained after the rounding.
Had a course in signals and systems where we learned Fourier transforms. Decided to try using a 2D FFT transform of an image, then essentially cropping or removing high frequency components, then doing an inverse FFT to make a very crude image compression algorithm. It still achieved a filesize reduction to about 20-30% of the original before obvious artifacts became visible. Not bad for not doing any block operations or other data compression. Got real interesting applying matrix operations to create filters like blur, sharpen, edge detection, and color shifting.
I finally understood the concept after watching a fee computerphile videos on it. But I also had some information theory classes in university since. This video does a great job explaining all the details and I believe I have found another one of those gem channels. Will look for a video on JPEG2000 wavelet compression if it exists
in one of my university courses we made a few image filters using the SIMD instructions set in assembler. now i understand the horror of the professor when someone said they wanted to make a jpeg encoder in ASM
I only really absorbed maybe 25% of this video, I don’t do math, I don’t have an intuitive understanding as to what a lot of the terminology actually refers to. But, I got the overall gist, and I have a deep respect for the process and the creative conceptual leaps that people can make in order to crack these fascinating problems.
I understood several of the words in this explanation. Seriously though, this was very useful. I have an extremely hard time learning math without a real-world example to tie it to (e.g., FM radio is a real-world example of calculus derivatives), and I made it to age 39 before finally finding a real-world example of linear algebra in this video. I still don't understand what linear algebra _is,_ but now I at least have a starting point.
Man this channel is so good, I love it Breaking down serious computer science with great quality audio-visuals and leaving it there for anyone to learn, fantastic.
Little secret of JPEG: It actually supports two entropy coders. Huffman coding, and arithmetic coding. The arithmetic coding is superior in performance, and yet almost never used and supported by almost no software. The reason for this is historical: Back when JPEG was new, arithmetic coding was subject to multiple patents. Mostly held by IBM, but not all. That made it very difficult for any program to use arithmetic coding legally, so all the early JPEG implementations were huffman-only. Once the patents expired, it became the classic chicken-and-egg problem: No-one wants to make software that saves jpegs with arithmetic coding because all of the existing software wouldn't be able to display them, and no-one has a reason to make their software able to display arithmetic-coded JPEG because there are none in use to display. So even up to today, we are all using JPEG in the low-performance mode. If it were practical to use the arithmetic option, JPEG files could be about 10% smaller while still maintaining exactly the same quality.
Yes, this is a great tidbit of history that most people don't know! Fun fact you may already know: in video codecs such as H.264 and H.265, where compression ratios are really important in terms of saving bandwidth, most entropy based encoding is based on context-adaptive binary arithmetic coding (CABAC). The improvements of arithmetic coding vs Huffman coding were enough of an incentive for most developers of video codecs to implement this logic in both the encoding and decoding side.
@pyropulse Looks like one to me. A circular dependency: No one will use a feature that has no software support, and no-one will make software to support a feature that is never used. The problem cannot be solved because of a condition that can only be altered by solving the problem.
Sounds like someone working on serenity os has a chance to do things their way and support that format just because.
@@Bobbias is that the temple on thing
@@katiebarber407 no, serenity is a different project to temple os. If temple os feels like an 80s os, serenity feels like a 90s os. It's basically a Unix style system with a windows 95 style desktop environment
I did a degree in electrical/computer engineering. This is BY FAR one of the best explanations I've seen about this. Doing the math is nothing compared to the understanding this video gives you. Thank you!
I agree. One thing I would have added though, is why we used sine instead of cosine. But perhaps if this is of interest to you, then you already know the answer why😉
If you've ever studied differential equations or Fourier series in general as a mathematics student, then the concepts also make a lot more sense intuitively than I expect they might as an EE student alone.
3Blue1Brown has some great videos on this.
totally agree. it's the visualization of behavior as parameters are varied that is so powerful. great job @Reducible!
That's great where did you do your degree I'm assuming you are indian
As a network engineer, thank you for not being a code monkey. Welcome to the Machine, priest. You're one of us!
Other interesting compression algorithms for people to look up:
- Opus, the successor to MP3/AAC that powers audio on the internet these days.
- QOI, an amazingly fast and simple to understand image format (1-page specification!)
- JPEG XL, the cutting-edge expansion of the original JPEG format shown in this brilliant video :-)
XL sounds like the file sizes will be bigger
Opus is only used for voice streaming or voice compression, it's definitely not an mp3 killer
@@Dorumin It could be though. Opus performs really well at any bitrate, though it does excel especially at the low end.
Outperforming MP3 isn't that impressive a performance though. There are lots of codecs that can make that claim. MP3 is just /old/.
@@Dorumin UA-cam also uses opus for many videos
I'm going to have to agree with the discussion above. Opus isn't a successor to MP3/AAC. AAC is reasonably considered a successor to MP3, but Opus is more of a peer to AAC.
This channel has some of the most well produced content right now
going to save more images as JPEGs out of sheer respect from now on
Ha, this cracked me up! Great comment!
No NFT is save
@@Reducible qhy is only one coefficient in dct output if most of the cosine wave values were positive? Since the others were too low? But youd think some would still be positive and just lower positive value, no?
It should probably be phased out, really. JPEG's compression was cutting-edge when it came out, in 1992. There have many several attempt to replace it since then with more sophisticated compression that can achieve higher quality for the same size, but they've all failed because they can't compete with JPEG's universal support. The latest is WebP, which is making some progress because it has the giant of Google to promote it.
JPEG2000 was a big flop. Though amusingly to me, every web browser today /does/ support it sort-of... not as a JPEG2000 file, but because it's one of the image compression methods supported within PDF files.
All/most of the image formats that followed are based on the basic idea of stacking waves, and even more so for the video formats. So in a way you are already paying homage to this genius design by watching this video!
The JPEG people didn’t stop working on pictures after good ol’ JPEG either. Their latest JPEG XL comes with tricks to make it much more efficient in terms of beauty/fidelity-per-bit. It is able to go toe to toe with video-based image formats like HEIC, AV1F in terms of efficiency while staying easy on the CPU to encode and decode.
This was *really* good. Well paced, well explained with great visuals. I have a much greater appreciation for what JPEGs do now. I'd love to see a video outlining some of the other various transformations used in signal processing or some more neat applications of them!
Yup, there are quite a few on the list, but no promises on when I'll get to them :)
I didn't expect you to be here lol, might join one day making the same videos on this platform?
@@harryguanous7198 Welp, I am a cs major after all :p
@@vcubingx your name and profile picture are amazing
@@Reducible At 14:56 where isbthe corresponding negative DCt value?? Ther shoukd be one if there is a positive one..
The level of elegance and attention to detail in the presentation was absolutely amazing 😭
It is no exaggeration to say that the quality of this video's presentation of the subject is beyond superb. Utterly fascinating and presented with outstanding clarity and insight. Left me wanting more, more, more of this content, please! Thank you for the effort and care you put into its creation.
This is one of the best videos I have seen about how the Fourier Transform is used in JPG compression . The amount of effort, time and money put into it is incredible. Thank you for sharing.
Thank you for this! I've watched and read many explanations of JPEG and they all talk about the DCT like that is the part that makes JPEGs smaller. Your video finally made it clear that the DCT doesn't reduce the size of the data, but does put it in a form where the less important information is easier to identify and remove, and why its okay to get rid of the high frequency content. The explanation is great and the visualizations were clear and helped a lot. Excellent work!
JPEG really was massively ahead of it’s time and accelerated the practical use of images in computing by years
I always knew jpeg has got some interesting maths going behind the scenes, but man, this is like super impressive.
And it actually sounds like a great coding challenge to create an actually functioning jpeg encoder/decoder
Btw I can't admit the quality of the work done to bring this video to us, I just love it. Thank you a lot for what you are doing, your videos are fascinating as always
I remember coding the DCT/IDCT functions in Borland Pascal two decades ago... it was a day of work - not full JPEG scheme, just playing with the coefficient (e.g. erasing them a seeing what it does) but quite some fun
I imagine it's not a good coding challenge, since there's not much elegancy you can bring here, often coding math-related stuff is tiresome and ugly, unless you use languages like Julia.
@@comradepeter87 Well although this might actually be very true for someone, I personally feel kind of ok with coding applied math stuff. After all, coding a JPEG encoder/decoder is not only about coding a math part of it, it's also about engineering a software because that's what we, as programmers, do
@@kodirovsshik this. There's the beauty of engineering a complex function into code that is readable, easy to grasp, maintainable and performant.
@@kuma9239 true!!
I would just like to take the time and say; Thank you for making these. As a mathematical engineer, I really appreciate these type of videos, which go into something that is extremely interesting, but I don't have time to explore myself.
As a designer, I very often go through these concepts and therms without the understanding of what they actually mean. And I have to say it, this video has already helped me in an artistic experiment that translates image to audio. Beautiful work, thank you!
This video is by far one of the best explained video on JEPEG compression. Not only this video presents intuitive explanation but also puts the right amount of mathematical details for any brain to comprehend. Kudos!!
This is such an incredibly well-structured, well-paced, and well-presented lecture, I'm in awe. Thank you so much for this, you outdid yourself here!
I appreciate how this video gives great length to the broad overview of compression, and then very quickly runs through specific details about the jpeg system... Very meta
Topics like this tickle my brain in just the right way. Fantastic video, we need more DSP content like this.
What I find incredible about this excellent video is that it helped me understand something I never expected to find here. I’m currently in an Electrical Engineering program, and for months, I’ve had a very limited understanding of the Fourier series concept we covered a few months back. The way you explained the DCT so clearly and concisely somehow crystallized the concept in my head. I deeply envy your ability to keep an audience so engaged with all this math I previously thought boring. Thank you so much for the well done video!
The production value of these video's are out of this world. Mad respect. Contents and visuals on point!
Always happy to see a new reducible video in my recommended
I am working on medical digital image processing and this is by far one of the best videos on this topic!!!!
You, sir, managed to hit all your goals, in my humble opinion: a very clear explanation of a fairly complex algorithmic pipeline, very visual examples/demos, and inspiring awe of how people can be immensely creative to problem-solve. 11/10, GREAT video!
I did a degree in Electrical Engineering but I do software engineering and this video is awesome! I love the visualizations and the explanations of signal processing concepts. If they taught signal processing like this in school I would've been MUCH more interested! Really well done!
I was curious about DCT and this was a great intro!
This video left me with no choice other than turning on all notifications for your channel! ❤️
This is hands down the best explanation of JPEG I’ve ever seen.
I’m out of words for the quality of this content. Really, wtf is happening. How can this be free and always available knowledge? I’m a chemical engineer btw, I will probably have no use for this ever in my life but I’m deeply interested, specially on the math part. I just love the internet man. You sir are a hero.
I know some basic computer science, but this is way over my head. I finished the video with amazement of how complex a JPEG compression method work, even though I don't like the nature of blocky image stuff, but still impressed. Thank you.
32:14 There's also the progressive stuff like spectral selection and successive approximation that also break every assumption of your logic and makes you question why you even want to write your own JPEG decoder.
This reminds me of the way it felt when I first saw 3blue1brown‘s video showing how the Fourier transform works. I *got it*. It was miraculous. Reducible, you‘re up there with the best of them.
This is hands down the best video on DCT on the internet, period. Well done
I've been working with multimedia encoders and decoders for most of my professional life, and I've watched many videos that try to explain what is going on behind the scenes.
This is the first video I've seen that touches important technical details like chroma subsampling 4:2:0, which is literally the second thing any decoding software like FFmpeg will report to you, right after the encoder (e.g. H.264).
Good job.
This channel is the best I have found this year, and I think it will remain the best find for the rest of it.
I’m usually not a huge fan of JPEGs and prefer highly compressed PNGs but this video made me respect the file format more. I’m mind blown by how cleverly designed this is.
When people ask if a computer science degree makes any sense in the modern world I should point them to this video. I don’t have a degree myself and work in web development, and I never ever come across a problem as localized and deep as this. Makes me think about going back to school honestly.
The hardest problems I need to solve, while definitely difficult, is always about managing lots of data, managing lots of network failures, managing large code bases, managing race conditions and synchronization issues, it’s all just trying to solve these large, messy code management problems.
No doubt, there are thousands of people in web development working on really deep problems like this, but they’re all working for the big 5 and making large sums of money for it. Most developers in my field just don’t need to interact with code as a mathematical problem. The math has been solved, the tools have been built, and we need to figure out how to use them as best we can. It’s definitely a different job entirely.
It's literally the most employee degree, currently.
Most of the things people interact with nowadays during their typical day is brought to you by electrical engineering and computer science. The fact that people take this for granted is a compliment to the fields, albeit can be frustrating at times. This also applies to many other fields of science, including chemistry, biology, math, physics, and all fields composed of those base sciences. Just think about the things you use, own, and touch, all created because of material science bred from those sciences.
a lot of these specific numerical methods are explored more deeply in the math encountered in electrical engineering
This is a great introduction, really nice work. I’d never thought about the DCT as being a vector dot product but that absolutely makes sense.
You pretty much taught the entire signal processing class I took in college in 30 minutes. Bravo.
Such an amazing explanation!! as someone who started to watch the video without any information about the topic, but still understood everything in detail, I must say this was a great video
This is a great explanation, we actually implemented a simplified image decompressor with an image format based on JPEG but without 2D downsampling and without huffman decoding on an FPGA in undergrad.
These same concepts (run-length encoding, bandwidth compression) work pretty well with radar images as well for certain classes of radars. Some radar signals need to be captured, compressed, transmitted over long distances, and reconstructed to its original form (warts and all) for further processing. Thinking of an image as a signal processing problem is very logical. Excellent video.
Wow I have never seen such an amazing visual representation of the JPEG algorithm. Love it!
You clarified a lot of the math involved in JPEG compression so that now I think I understand it, or at least the most important parts. Great explanation!
The amount of work behind this video is astonishing, 1000/10
This is, by far, the most visually appealing video I think I've ever seen!
I work for years in JPEG decoding IP, especially in Huffman Decoding Algorithm. and swear that JPEG is wonderful. other little secret is JPEG also has "Head" which contain information for decoding purpose while still maintain the entire file in small size. and JPEG Header Analyze is also a very interesting topic. I hope I could watch this video in my early year of my career in JPEG codec. I just refer this video nowadays for other people who ask me about the JPEG.
There’s a brilliant video by “Reducible” about the concept of signal processing and jpegs. It’s totally worth watching!
Thank you for the amazing video. Truly astounding visualisations that teach a complex topic with such effectiveness
Thank you brother, this is the best explanation I have encountered about this subject in the whole internet. You are the best!
You sir, just earned a new sub, absolutely brilliant content quality! I'm loving how many new channels are adapting the 3blue1brown style of teaching, I honestly find these videos so clear I'm learning faster than I've ever before!
So much information. Feeling overwhelmed, will tune in after having some food.
I’ve actually been studying a lot of control theory and signal processing on my own time, continuous and discrete. The moment you said to look at the brightness component, and how if you move along it it’s like a signal in a way, I put my phone down and went “Oh. My. GOD.” I immediately knew exactly what was about to happen: pick out the lower frequencies and just store those, and reconstruct the signal later. That is absolutely INCREDIBLE. Incredible video. I’m also very proud of myself for recognizing that so naturally
I added this to watch later and really wanted to watch it after work. But I was hooked, I couldn't stop the video even if I wanted to. Awesome video and amazing engagement!
Not only the content of the video is interesting and well explained, but also the animations are incredible. I dream of one day being 10% as good as you are with Manim.
It is incredible how complex and thought through technology is that we use without thinking about it. This video Really makes you appreciate the hard work and genius ideas that have been put into what we use today. It always amazes me to understand and learn how things work. Thank you for explaining it.
This is a excellent video, I really appreciate your putting so much effort into both covering the actual math and also giving a visual run-through of it's implications. So often this stuff is explained with a page of equations and maybe single figure of featuring the DCT 2D basis functions. This was way better than that! This is a great example of how a well-done video with good illustrations and animations can explain concepts way better than a text book can, though at the cost of making it much harder to skim ahead when part of the information presented was already understood.
I don't even remember subscribing to your channel, but I have a feeling it's great
One of the best visual explanation for JPEG, can't wait for the h264 video :)
I've been lurking around DFT/FFT explanations for the past couple of days, both in your channel and 3b1b including some others, I understood many underlined concepts but why cosine functions itself pull out the contribution info out of the input was mystery, this video solved it for me on that vector similarity based on dot product part. I was blown away by the simplicity of the concept. Next I plan to check more on orthogonality. Great video as well, mate! My utmost respect!
I've never thought image compression could be this interesting!
Thank you for this incredibly well explained video!
What an outstanding video - the graphics, explanation, pacing, everything. Thanks for creating it.
BEST VIDEO EVER! So clearly explained,so clear audio, perfect slides. 🎉😊
your explanation and quality of video is so amazing. It really reflects the amount of hardwork you have committed for this cause. Thanks a lot for your service to humanity,
This topic has been honestly stuck in my head for so long, but I found no content satisfying my need to learn it until now!! this has been greatly explained, awesome job!
Wow - absolutely amazing video - lots of ground covered and a great way of simplifying quite a complex topic!
Hands down to one of the best videos made with manim.
Great video quality! Crisp explanations and beautifully crafted visuals, that are exactly on point.
This is incredible. This might now be one of my most favorite algorithms yet
So pixel art as PNG and photographs as JPEG. Got it. Also it's so cool to see easily graspable applications for vector and matrix mathematics like this.
Thank you for such wonderful visuals. Even though I honestly don't get all these concepts at all, I find it super interesting to watch these concepts explained visually. I hope this video will be a vital complement to my upcoming signal processing course.
For people like you and your work, it is worth spending time on UA-cam. Thank you, keep up the good work.
Thanks for this. How video compression actually works is something thats not easy to explain to most people. I can certainly see my self referring people to this video instead of trying to explain it myself. You've done a much better job explaining it than I could have.
Fun fact, I actually thought about explaining H.264 first, but then realized it would probably be a 2 hour video so I stuck with JPEG.
Holy crap, that was a ride.
I knew JPEG used DCTs and I did dabble in signal compression a bit back, but the other details putting it all together was very illuminating. ngl I was not expecting that the JPEG quality slider I see in some software is actually from a set of quantization tables set by standard. Or that stuff like Huffman coding was used to clean up after eliminating the high frequencies.
Perception is such a massively important field in IT. This is why they teach cognitive psychology as part of a software engineering degree (or at least they did when I studied).
It depends on what exactly you're majoring in. Computer science and software engineering are vast fields. I touched on those things because I liked doing usability stuff, but I could just as easily have avoided if I hadn't.
Just the best explanation of JPEG I've seen. Thanks.
I don't like JPEGs because of their lossiness, but I will admit there's some cool math behind them!
So to summarize: you don't like JPEG the image format, but you do like JPEG the algorithm :p
@@susmitislam1910 yes haha
Theoretically, you have to give up some efficiency in order to compress any sort of information. The difficult part is about by keeping the data as original or comprehensible as possible, how much would you give up. But yeah, nowadays we have bigger and cheaper digital storage, so the problem of jpg is gradually getting noticed.
There are better alternatives to DCT available nowadays. For example, JPEG2000 uses wavelets: when you push the compression too far on these, instead of getting blocky like DCT, they become fuzzy, which is generally less objectionable.
There is nothing wrong With Lossy compression, i dont understand whats your problem, everything has Advantages and disadvantages
There are some terrifyingly brilliant people in this world that will never get the recognition they deserve, all because they refuse to make clowns of themselves.
Great video, I never took the time to understand the jpeg algorithm but this video really explains it efficiently, with relevant illustrations. Well done !
The only remark I would make is about the curve you plot on the frequency coefficients (when you explain the DCT). I think it kills the idea that it is a discrete sequence of coefficients. The interpolating values have absolutely no meaning, whereas the curve on the left (the signal) is relevant because it represents the "real" signal that was sampled.
Yeah, very good point! Now that I think about it, you are right. I think I wanted some visual symmetry when I made it, but truth be told, it serves no purpose. Sometimes, when you are so deep into a project, you can forget how something so superficial can possibly lead to some confusion. Thanks for the feedback!
It's not only a discrete sequence (as the sequence of samples would be), but it's still discrete when you consider the extension to continuous signals. On the time domain you can interpolate using the cosines. Thus, on the left side I think the continuous line is helpful. In the frequency domain, you would still see discrete delta impulses, because the dct requires (assumes) your signal to be periodic. Other than that, great video! Thanks
@@Reducible I think the continuous line does serve some purpose. It makes it easier to understand why the discrete values are the way they are when you slowly shift the frequency between integers.
Though the interpolating values have no meaning, they serve as a reminder that cosines are in fact, continuous and not discrete. Also the signal transformation is better to visualize and understand with this in mind. This is ultimately what the step of quantization gets rid of, as it samples this continuous interval back to discrete space. In my mind it was definitely not in vain to have it included and visualized.
@@Reducible I think one problem is that it's a bit hard to spot the actual coefficient points because they're the same colour as the curve, which is why making the curve less bright is a valid solution.
What a beautiful explanation of the JPEG compression algorithm! Very understandable and somewhat easy to remember ^^
This is extremly amazing!
I loved the technology, the maths, the cleverness, the explanation. This one of the best ways I have invest my time in weeks. Thank you for this video!!
I admire your thinking patterns and hard work you do to make these videos. I don't think you have any competition on UA-cam.
As someone who hasn't touched math since High School "special needs" classes, it's insane how intuitive you made this. Of course I don't understand some stuff like *how* a signal gets transformed with a DCT in the middle of the video and why the transformed values get so weird at a first glance, but otherwise... I've got a vague understanding of how this works now, even how you can use a collection of "fixed" cosine waves to roughly represent values. And I can see how the large-scale luma / chroma simplification leads to the sort of splotchy patches you see in heavily compressed JPEGs.
This is also the first time for me to know about that transformation.
If you have a line with an angle with x axis, its projection on x axis represents how much it is not so steep right. Consider extreme case, a horizontal line, its projection on x axis is itself (a non zero value), its projection on y axis is zero, so we knew that it somehow align with x axis.
Same here we are not projecting on x and y axis, but projecting on cosine!
We need to know how much our signal resembles or look similar to cosine wave of certain frequency so we multiply the samples of our signal by samples from that cosine wave and sum them. If they align well, the multiplications will be all positive and sum of positive is positive. If they dont align well, some multiplications will be positive and some are negative, there sum are small. If signal is just a cos x, then multiplying with cos x and summing give a number, if we multiplied it with cos 2x, the sum will be zero. So we knew that our signal contained a large component of frequency of 1 (in this example it is the only component). In other signals, it is not clear whst cosines are in our signal, so we do that operation and from the result we know which frequencies and how much they algin (exist) in our signal.
It is just a projection and the summation or integration.
Incredible descriptions. Really wish I had these during my masters.
Fantastic work, thank you!
Your videos are really great. Your delivery is quite simple to 3blue1brown. I mean that as a complement. You take time to explain things very clearly, your cadence is rhythmic, and your voice is pleasing to the ears.
As a pixel artist, I admit that I somehow hate JPEG, mostly because of its qualities.
It's a lossy image format that is decent at what it does in most cases.
The main issue is that pixel art is one of these rare cases where JPEG is the worst option; it's only sharp and sudden transition from one pixel to another in terms of colour or contrast, just what JPEG "hates".
A lot of websites automatically convert your image into JPEG if it's not animated or not transparent; which can absolutely ruins your work. So there is this old trick of leaving a single pixel transparent on your image to keep it as a PNG instead.
So, now I still hate JPEG, but at least I understand a bit more why.
It's annoying that everything is forced through lossy photo compression, especially when pixel art is already so insanely compressible. A detailed 320x240 32-color piece can be 20KB, but it must be upscaled and converted to a fuzzy JPEG that's an order of magnitude larger than the original.
dirac impulse goes ↑
Lossy encoders were designed with mainstream usage in mind.
You, as a professional with strict requirements and technical knowledge, are responsible to find another medium and suitable file format to carry your information.
Although JPEG was somewhat forced onto Internet users as digital hardware and software grew in usability and prevalence, there was never a point in computer history when you couldn't use a lossless format or find another lossless workaround, mostly because raw solutions are FAR EASIER to implement and far more robust and cost effective, and rarely have anything to do with fashion or industry trends.
I am a DTP professional and a graphic designer from the early 90's, I still remember IFF and PCX file formats on the Amiga. Don't mingle 'technology for the masses' with the 'technology as is'.
Since the 2000's I remember people were struggling to find a good carrier for print-ready photography in certain workflows. TIFFs with ZIP compression were widely available and offered a superior lossless compression both in CMYK and RGB. We also had EPS DCS2 which would natively store grayscale color separations for high-resolution film development.
Video and audio were something else due to monstrous demands on the memory for the time, but pixel art? Man. It all started from indexed palettes and simple pixel art. Why would it ever devolve into media intended for megapixels and high-freq noise? Vector graphics took more than 10 years to develop fully and it's still quite a niche technique if we look outside the DTP, but pixel art was there from the very beginning.
Though, to be fair, I remember one historical gap. It was thanks to the holders of the LZW patent (used by GIF) on one side, and thanks to Apple pushing for high color palettes on the other, and so the browsers were caught between a rock and a hard place, but only browsers! It was some time before CompuServe finally got PNGs running throughout the ecosystem, in the late 90's. Though Microsoft always had the Bitmap format, the most native thing one can imagine, but it was completely discouraged on the Internet.
In any case, since the 2000's, *having* to use JPEGs for anything it wasn't made for (high-res photos and common image interchange), was definitely not a thing if it ever was. Whoever had to mess around with upscaled JPEGs was someone who figured out stuff very wrongly.
That's because pixel art is pretty much the opposite of natural vision. It's also the reason why you can never use chroma subsampling on a PC monitor (it will screw up the GUI and text) and why desktop recordings without zoom look so horrible.
when saving JPEG, turn off the chroma subsampling (use 1:1) and your colour contrast will be retained - plus there is lossless JPEG scheme as well
wow that was awesome to watch. When you said I could go deeper I was like (you don't say!) You're awesome bro keep it up
People like you are why I am gonna pass my masters degree. Thank you so much!
Beautiful. Thank you!
I definitely didn't come across this video at 4AM wondering of what my image file's features are. Awesome video!
29:00 well this is clever, I thought you'd just store the matrix of the DCT and then change everything but the top right to zeros, but the actual way means that if this block has a lot of higher frequency signals, it is retained after the rounding.
Indeed
Had a course in signals and systems where we learned Fourier transforms. Decided to try using a 2D FFT transform of an image, then essentially cropping or removing high frequency components, then doing an inverse FFT to make a very crude image compression algorithm. It still achieved a filesize reduction to about 20-30% of the original before obvious artifacts became visible. Not bad for not doing any block operations or other data compression. Got real interesting applying matrix operations to create filters like blur, sharpen, edge detection, and color shifting.
I finally understood the concept after watching a fee computerphile videos on it. But I also had some information theory classes in university since.
This video does a great job explaining all the details and I believe I have found another one of those gem channels. Will look for a video on JPEG2000 wavelet compression if it exists
Great video, I learned about and experimented with F.T. and Z transform in my last semester of ECE, so this was right up memory lane haha
in one of my university courses we made a few image filters using the SIMD instructions set in assembler. now i understand the horror of the professor when someone said they wanted to make a jpeg encoder in ASM
Amazing video. Very well explained and beautifully animated. Thank you for all your effort
I only really absorbed maybe 25% of this video, I don’t do math, I don’t have an intuitive understanding as to what a lot of the terminology actually refers to.
But, I got the overall gist, and I have a deep respect for the process and the creative conceptual leaps that people can make in order to crack these fascinating problems.
I love how I see a vid from this channel and I like the vid before even watching it. Keep up the great work!
You make fantastic videos!
I understood several of the words in this explanation.
Seriously though, this was very useful. I have an extremely hard time learning math without a real-world example to tie it to (e.g., FM radio is a real-world example of calculus derivatives), and I made it to age 39 before finally finding a real-world example of linear algebra in this video. I still don't understand what linear algebra _is,_ but now I at least have a starting point.
Man this channel is so good, I love it
Breaking down serious computer science with great quality audio-visuals and leaving it there for anyone to learn, fantastic.