Want to understand how JPEG works a bit more?
Check out this brilliant video
https://www.youtube.com/watch?v=Q2aEzeMDHMA
(Edit by peterb: the animus posted this as he thought the subtleties of compression would be of interest to the photographic community. With his agreement I have moved it to a wider audience. The video is well worth watching (at least twice :)) and as always, the HEXUS community has explained it further in the thread)
Re: Want to understand how JPEG works a bit more?
I have been reading about JPEG compression recently, and only half understood it. I totally get it now!
Re: Want to understand how JPEG works a bit more?
0:40 seconds... ZZZZZZZZz
they way i always understood JPEG compression was. JPEG looks at a colour and then it's neighbours, if the colour is like it, then it is taken to be the same. So the more compression the wider the spread of neighbours.
Re: Want to understand how JPEG works a bit more?
Quote:
Originally Posted by
Bobster
0:40 seconds... ZZZZZZZZz
they way i always understood JPEG compression was. JPEG looks at a colour and then it's neighbours, if the colour is like it, then it is taken to be the same. So the more compression the wider the spread of neighbours.
That's error diffusion you're describing there, which is more to do with gradation that compression. There's more than just that going on when you start looking at compression etc.
Re: Want to understand how JPEG works a bit more?
Quote:
Originally Posted by
Bobster
they way i always understood JPEG compression was. JPEG looks at a colour and then it's neighbours, if the colour is like it, then it is taken to be the same. So the more compression the wider the spread of neighbours.
I can't understand why ignorance is something to be proud of?
If you'd bothered to watch the video, you would realise what more you need to learn, as your understanding is very wrong.
Re: Want to understand how JPEG works a bit more?
I was lost when he was going on about the waves then it started to make sense when he numbers were brought out. Interesting video, might have to browse a few more of them.
Re: Want to understand how JPEG works a bit more?
There is a bit of learning curve on stuff like this Rob, glad you made it through, the thing to really take away is the idea that an image can be represented by a bunch of waves, that have the same shape, but at increasing frequencies. Then the fun bit of this kind of 'lossful' compression is that you can be smart about which bit of the image you loose.
If you've any questions about bits you aren't sure on, feel free to ask as I'm sure I wasn't the only person on Hexus to study this stuff back at uni.
Re: Want to understand how JPEG works a bit more?
I'm really not getting the waves thing, once he showed the grid image representation of the waves I found it easier to understand that by adding a certain amount of each of those you can get an approximate representation of the image. Makes sense I guess.
Re: Want to understand how JPEG works a bit more?
Okay so let's look at this image I've nabbed from Wikipedia
http://upload.wikimedia.org/wikipedi...px-Dctjpeg.png
Let's look at that top left. Notice it's all white.
Next lets look in the one below the top left, and the one to the right.
We've got this 'gradient' of a sine wave.
We look further out on the X and Y axis, by the 3rd box, we see the 'frequency' has increased, that is, the gradient is more frequent, it occurs fully now, rather than just partially. Only looking at the top row and first column, we see it now become a twice deal. The fun thing is, when you sum them together, you get a different curve.
This is really useful, because the cosine function is known, so doesn't have to be encoded, you just need the frequency of it, which we can assume by using the 8x8 matrix, so we just need the 'weighting' for that curve.
Sum the curves together and you get a good approximation. This is a really useful feature! We know that some curve frequencies are more important than others, so we can compress some more than others. This is why photos of natural things look quite good in jpeg, but text looks more awful.
By using one or more 'functions' (maths uses bad names for everything, the function in this case is the pattern that is a cosine wave) we can represent more complex patterns. We can see this by borring a gif from wikipedia again, this time, for a fourier transform, notice how using a 'sinewave' pattern we can again make a different shape, just simply adding together different frequencies.
http://upload.wikimedia.org/wikipedi...28small%29.gif
The fun thing is, we've got a new 'function' simply by summing waves of different frequencies of a simple know function.
Re: Want to understand how JPEG works a bit more?
Quote:
Originally Posted by
TheAnimus
I can't understand why ignorance is something to be proud of?
If you'd bothered to watch the video, you would realise what more you need to learn, as your understanding is very wrong.
what do i need to learn? my images look great on screen, they look great in print using the settings i use vs file size..
Re: Want to understand how JPEG works a bit more?
Two things struck me, one was that a JPEG file is relatively fragile - if the quantisation table is damaged, the image is lost, and that different applications can use there own quantisation tables, so while another application can recover the image, the overall effect might vary because of a different table.
Re: Want to understand how JPEG works a bit more?
As a physicist with an emphasis on computer related simulation etc. I have to say that Fourier series are wonderful things. Still hate working the blighters out by hand though!
Fourier's theorem states that any periodic wave can be built of an infinite series of sine and cosine waves, and if you take the JPEG's 8x8 cell to be 1 period then you can easily make any of the patters (of course, like the video says, you have to look in 2D, but mathematically it's not harder per se, just a bit more irritating to crunch by hand).
Of course, going for compression, we don't want to use infinitely many waves, as this would require a bit too much space. However, we see that the Fourier series converges very quickly towards a good approximation of what we're looking for (especially given how "insensitive" the eye is to little variations of colour). Here's a couple of pictures from some of my older lecture notes:
http://i.imgur.com/wb17LHN.png
http://i.imgur.com/AsbTqFh.png
TheAnimus: That gif you have of the Fourier series is awesome!
Re: Want to understand how JPEG works a bit more?
God this feels like im revising for my compression exam at uni again ^_^
Re: Want to understand how JPEG works a bit more?
Quote:
Originally Posted by
Bobster
what do i need to learn? my images look great on screen, they look great in print using the settings i use vs file size..
You can lead a horse to water, but you can't make them think. If you don't want to bother understanding something, you can never be in a position to say if it was worth learning or not. There are many things I've researched which have no practical application, no 'benefit' but the journey was still a worthwhile endeavour. You can't know how something may or may not benefit you, until you know that something.
Even if after learning it, it's not applicable to you doesn't mean it's a good idea to go around spouting a falsehood whilst claiming that the education for correcting it is boring. I think it's wrong to judge people for being ignorant. But wilful ignorance, well that is damned stupid.
Re: Want to understand how JPEG works a bit more?
Quote:
Originally Posted by
peterb
Two things struck me, one was that a JPEG file is relatively fragile - if the quantisation table is damaged, the image is lost, and that different applications can use there own quantisation tables, so while another application can recover the image, the overall effect might vary because of a different table.
Yup it's not meant to be a robust format, I sort of agree with that, redundancy data, such as error correction or detection should be the concern of the storage/transmisison system. TCP/IP has built in retrying for corrupted packets, most storage drives have some recovery information, flash devices such as SSDs often have complex parity data as it's not uncommon for a bit to be corrupted.
Goobley, I stole that gif from Wikipedia on Fourier Transform, it's great isn't it. For anyone else the reason we love it is it clearly shows how the 'result' the red curve, is composed of the blue waves at increasing frequency (more ups and downs), and decreasing amplitude (the ups are less up, and the downs less down).
Also Goobley, why do you have to work some out by hand? I don't think I ever did that outside of an exam, I did implement my own FFT before in assembly for a PIC16 series, this was so we could make a friends bookshelves light up in time with the music, quite a nice little birthday gift even if you had to be rather stoned for the effect to be good! I remember telling myself, could be worse, could be working it out by hand, suddenly PIC16 assembly appeared nice.
Re: Want to understand how JPEG works a bit more?
Quote:
Originally Posted by
TheAnimus
Also Goobley, why do you have to work some out by hand? I don't think I ever did that outside of an exam, I did implement my own FFT before in assembly for a PIC16 series, this was so we could make a friends bookshelves light up in time with the music, quite a nice little birthday gift even if you had to be rather stoned for the effect to be good! I remember telling myself, could be worse, could be working it out by hand, suddenly PIC16 assembly appeared nice.
Still in Uni with these damnable exams, but I also do some work with CAS systems and don't always fully trust some of the exact answers they claim to produce (since I've seen the state of the codebases holding some of them up). Although to be fair I should probably just use Matlab outside of having to compute it myself...
WRT the PIC assembly, you must have a lot more staying power than I. I tend to look at my code in LLVM assembly, see it's inefficient, say to myself: "I could really improve these things..." then realise it feels like too much effort. (I love autovectorisers, the fewer SIMD intrinsics I have to use the better). Having never had to program in assembly the amount of work involved seems like a pain, especially handling something like a DFT matrix...